From d7a7a4fb83dac17f5f75d62ad9cc35062753785b Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Tue, 5 Aug 2014 19:48:28 +0200 Subject: [PATCH] Use Qt API for figuring out the dialog screen At the moment it's trying to translate the item position and iterating through all screens, but we can get the screen through the item's window. REVIEW: 119603 --- src/plasmaquick/dialog.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/plasmaquick/dialog.cpp b/src/plasmaquick/dialog.cpp index fb33ffa65..64fb4a974 100644 --- a/src/plasmaquick/dialog.cpp +++ b/src/plasmaquick/dialog.cpp @@ -71,7 +71,6 @@ public: Window }; - QScreen *screenForItem(QQuickItem *item) const; void updateInputShape(); //SLOTS @@ -107,18 +106,6 @@ public: QWeakPointer mainItemLayout; }; -//find the screen which contains the item -QScreen *DialogPrivate::screenForItem(QQuickItem *item) const -{ - const QPoint globalPosition = item->window()->mapToGlobal(item->position().toPoint()); - foreach (QScreen *screen, QGuiApplication::screens()) { - if (screen->geometry().contains(globalPosition)) { - return screen; - } - } - return QGuiApplication::primaryScreen(); -} - void DialogPrivate::syncBorders() { // FIXME: QWindow::screen() never ever changes if the window is moved across @@ -589,7 +576,7 @@ QPoint Dialog::popupPosition(QQuickItem *item, const QSize &size) //If no item was specified try to align at the center of the parent view QQuickItem *parentItem = qobject_cast(parent()); if (parentItem) { - QScreen *screen = d->screenForItem(parentItem); + QScreen *screen = parentItem->window()->screen(); switch (d->location) { case Plasma::Types::TopEdge: @@ -658,7 +645,7 @@ QPoint Dialog::popupPosition(QQuickItem *item, const QSize &size) //we do not rely on item->window()->screen() because //QWindow::screen() is always only the screen where the window gets first created //not actually the current window. See QWindow::screen() documentation - QRect avail = d->screenForItem(item)->availableGeometry(); + QRect avail = item->window()->screen()->availableGeometry(); if (outsideParentWindow && d->frameSvgItem->enabledBorders() != Plasma::FrameSvg::AllBorders) { //make the panel look it's inside the panel, in order to not make it look cutted