diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-08-13 15:19:20 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-08-18 13:10:23 +0000 |
commit | 23697466cae8f1a49537fed1e60db8cea79207b4 (patch) | |
tree | de527385caf854ddd810b39369370c8730c5306e /src/widgets/dialogs | |
parent | 52ad5afe1c1d8f8d47fccbdf474f8c6119b94608 (diff) |
Reduce usage of QDesktopWidget to resolve screen properties in QtWidgets
Removes the need to initialize QDesktopWidget, just to look up which
screen a widget would map to, the geometry of a screen, number of
screens, etc.
Change-Id: Ieb153b9ff6d3fba645fc528d6e430e8392f990bf
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r-- | src/widgets/dialogs/qcolordialog.cpp | 5 | ||||
-rw-r--r-- | src/widgets/dialogs/qdialog.cpp | 11 | ||||
-rw-r--r-- | src/widgets/dialogs/qmessagebox.cpp | 3 | ||||
-rw-r--r-- | src/widgets/dialogs/qwizard.cpp | 3 |
4 files changed, 13 insertions, 9 deletions
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index f361770c3e..9465575b3b 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -41,6 +41,7 @@ #include "qapplication.h" #include "qdesktopwidget.h" +#include <private/qdesktopwidget_p.h> #include "qdrawutil.h" #include "qevent.h" #include "qimage.h" @@ -1698,7 +1699,7 @@ void QColorDialogPrivate::initWidgets() #else // small displays (e.g. PDAs) cannot fit the full color dialog, // so just use the color picker. - smallDisplay = (QApplication::desktop()->width() < 480 || QApplication::desktop()->height() < 350); + smallDisplay = (QDesktopWidgetPrivate::width() < 480 || QDesktopWidgetPrivate::height() < 350); const int lumSpace = topLay->spacing() / 2; #endif @@ -1744,7 +1745,7 @@ void QColorDialogPrivate::initWidgets() } else { // better color picker size for small displays #if defined(QT_SMALL_COLORDIALOG) - QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size(); + QSize screenSize = QDesktopWidgetPrivate::availableGeometry(QCursor::pos()).size(); pWidth = pHeight = qMin(screenSize.width(), screenSize.height()); pHeight -= 20; if(screenSize.height() > screenSize.width()) diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 1cd587b78d..9e62f79a8e 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -50,6 +50,7 @@ #include "qevent.h" #include "qdesktopwidget.h" +#include <private/qdesktopwidget_p.h> #include "qapplication.h" #include "qlayout.h" #include "qsizegrip.h" @@ -811,13 +812,13 @@ void QDialog::adjustPosition(QWidget* w) w = w->window(); QRect desk; if (w) { - scrn = QApplication::desktop()->screenNumber(w); - } else if (QApplication::desktop()->isVirtualDesktop()) { - scrn = QApplication::desktop()->screenNumber(QCursor::pos()); + scrn = QDesktopWidgetPrivate::screenNumber(w); + } else if (QDesktopWidgetPrivate::isVirtualDesktop()) { + scrn = QDesktopWidgetPrivate::screenNumber(QCursor::pos()); } else { - scrn = QApplication::desktop()->screenNumber(this); + scrn = QDesktopWidgetPrivate::screenNumber(this); } - desk = QApplication::desktop()->availableGeometry(scrn); + desk = QDesktopWidgetPrivate::availableGeometry(scrn); QWidgetList list = QApplication::topLevelWidgets(); for (int i = 0; (extraw == 0 || extrah == 0) && i < list.size(); ++i) { diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 6a55f62e53..0693f4bea8 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -60,6 +60,7 @@ #include <QtGui/qfont.h> #include <QtGui/qfontmetrics.h> #include <QtGui/qclipboard.h> +#include <private/qdesktopwidget_p.h> #ifdef Q_OS_WIN # include <QtCore/qt_windows.h> @@ -357,7 +358,7 @@ void QMessageBoxPrivate::updateSize() if (!q->isVisible()) return; - QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size(); + QSize screenSize = QDesktopWidgetPrivate::availableGeometry(QCursor::pos()).size(); int hardLimit = qMin(screenSize.width() - 480, 1000); // can never get bigger than this // on small screens allows the messagebox be the same size as the screen if (screenSize.width() <= 1024) diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index 431447734d..3d9b6a3d62 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -46,6 +46,7 @@ #include "qboxlayout.h" #include "qlayoutitem.h" #include "qdesktopwidget.h" +#include <private/qdesktopwidget_p.h> #include "qevent.h" #include "qframe.h" #include "qlabel.h" @@ -396,7 +397,7 @@ void QWizardHeader::setup(const QWizardLayoutInfo &info, const QString &title, /* There is no widthForHeight() function, so we simulate it with a loop. */ - int candidateSubTitleWidth = qMin(512, 2 * QApplication::desktop()->width() / 3); + int candidateSubTitleWidth = qMin(512, 2 * QDesktopWidgetPrivate::width() / 3); int delta = candidateSubTitleWidth >> 1; while (delta > 0) { if (subTitleLabel->heightForWidth(candidateSubTitleWidth - delta) |