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/widgets/qmenubar.cpp | |
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/widgets/qmenubar.cpp')
-rw-r--r-- | src/widgets/widgets/qmenubar.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index fd48058ec3..5284c16ab0 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -60,6 +60,7 @@ #include <qpa/qplatformtheme.h> #include "private/qguiapplication_p.h" #include "qpa/qplatformintegration.h" +#include <private/qdesktopwidget_p.h> #ifndef QT_NO_MENUBAR @@ -322,7 +323,7 @@ void QMenuBarPrivate::popupAction(QAction *action, bool activateFirst) QSize popup_size = activeMenu->sizeHint(); //we put the popup menu on the screen containing the bottom-center of the action rect - QRect screenRect = QApplication::desktop()->screenGeometry(pos + QPoint(adjustedActionRect.width() / 2, 0)); + QRect screenRect = QDesktopWidgetPrivate::screenGeometry(pos + QPoint(adjustedActionRect.width() / 2, 0)); pos = QPoint(qMax(pos.x(), screenRect.x()), qMax(pos.y(), screenRect.y())); const bool fitUp = (q->mapToGlobal(adjustedActionRect.topLeft()).y() >= popup_size.height()); @@ -1566,7 +1567,7 @@ QSize QMenuBar::minimumSizeHint() const int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this); int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this); if(as_gui_menubar) { - int w = parentWidget() ? parentWidget()->width() : QApplication::desktop()->width(); + int w = parentWidget() ? parentWidget()->width() : QDesktopWidgetPrivate::width(); d->calcActionRects(w - (2 * fw), 0); for (int i = 0; ret.isNull() && i < d->actions.count(); ++i) ret = d->actionRects.at(i).size(); @@ -1618,7 +1619,7 @@ QSize QMenuBar::sizeHint() const int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this); int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this); if(as_gui_menubar) { - const int w = parentWidget() ? parentWidget()->width() : QApplication::desktop()->width(); + const int w = parentWidget() ? parentWidget()->width() : QDesktopWidgetPrivate::width(); d->calcActionRects(w - (2 * fw), 0); for (int i = 0; i < d->actionRects.count(); ++i) { const QRect &actionRect = d->actionRects.at(i); |