move screenForItem in the dpointer

This commit is contained in:
Marco Martin 2014-03-18 21:40:36 +01:00
parent f412d1a9d0
commit 7e07bd7a3e
2 changed files with 17 additions and 19 deletions

View File

@ -59,6 +59,8 @@ public:
{
}
QScreen* screenForItem(QQuickItem *item) const;
Dialog *q;
QTimer *syncTimer;
Plasma::Types::Location location;
@ -77,6 +79,19 @@ public:
QWeakPointer <QObject> 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();
}
Dialog::Dialog(QQuickItem *parent)
: QQuickWindow(parent ? parent->window() : 0),
@ -273,7 +288,7 @@ QPoint Dialog::popupPosition(QQuickItem *item, const QSize &size, Qt::AlignmentF
//If no item was specified try to align at the center of the parent view
QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent());
if (parentItem) {
QScreen *screen = screenForItem(parentItem);
QScreen *screen = d->screenForItem(parentItem);
switch (d->location) {
case Plasma::Types::TopEdge:
@ -362,7 +377,7 @@ QPoint Dialog::popupPosition(QQuickItem *item, const QSize &size, Qt::AlignmentF
//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 = screenForItem(item)->availableGeometry();
QRect avail = d->screenForItem(item)->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
@ -727,18 +742,6 @@ void Dialog::setTransientParentAndNotify(QWindow *parent)
}
//find the screen which contains the item
QScreen* Dialog::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 Dialog::updateMinimumWidth()
{
if (d->mainItemLayout) {

View File

@ -34,10 +34,6 @@
class QQuickItem;
class QScreen;
namespace Plasma
{
class FrameSvgItem;
}
class DialogPrivate;
@ -190,7 +186,6 @@ private Q_SLOTS:
void updateMaximumHeight();
private:
QScreen* screenForItem(QQuickItem *item) const;
DialogPrivate *const d;
};