diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2021-09-24 06:39:09 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2021-09-24 13:57:39 +0200 |
commit | 84c25d55fe03f693a86816ad11f614bc7d07ed1a (patch) | |
tree | b75e6aa2a4531170a8d57ba7442837a75a8a2bae /vcl/qt5 | |
parent | fe040e71343cb894f97a0781f77805fd046178ca (diff) |
qt5: Port Qt5Frame away from deprecated QDesktopWidget
Most of QDesktopWidget's methods were deprecated in
Qt 5.11 and QDesktopWidget was removed in Qt 6.
Since 'QScreen *QGuiApplication::screenAt(const QPoint &point)'
was only introduced in 5.10, keep using
'QDesktopWidget::screenNumber' for older Qt versions.
Change-Id: I915fda0ea00b018945974ad82c1927a5fac99145
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122548
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl/qt5')
-rw-r--r-- | vcl/qt5/Qt5Frame.cxx | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx index 2c2b439be225..43ca9cdbf802 100644 --- a/vcl/qt5/Qt5Frame.cxx +++ b/vcl/qt5/Qt5Frame.cxx @@ -45,7 +45,9 @@ #include <QtWidgets/QStyle> #include <QtWidgets/QToolTip> #include <QtWidgets/QApplication> +#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) #include <QtWidgets/QDesktopWidget> +#endif #include <QtWidgets/QMenuBar> #include <QtWidgets/QMainWindow> @@ -482,26 +484,26 @@ Size Qt5Frame::CalcDefaultSize() if (!m_bFullScreen) { const QScreen* pScreen = screen(); - SAL_WNODEPRECATED_DECLARATIONS_PUSH - aSize = bestmaxFrameSizeForScreenSize( - toSize(pScreen ? pScreen->size() : QApplication::desktop()->screenGeometry(0).size())); - SAL_WNODEPRECATED_DECLARATIONS_POP + if (!pScreen) + pScreen = QGuiApplication::screens().at(0); + aSize = bestmaxFrameSizeForScreenSize(toSize(pScreen->size())); } else { if (!m_bFullScreenSpanAll) { - SAL_WNODEPRECATED_DECLARATIONS_PUSH - aSize = toSize( - QApplication::desktop()->screenGeometry(maGeometry.nDisplayScreenNumber).size()); - SAL_WNODEPRECATED_DECLARATIONS_POP + aSize = toSize(QGuiApplication::screens().at(maGeometry.nDisplayScreenNumber)->size()); } else { - SAL_WNODEPRECATED_DECLARATIONS_PUSH +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) + QScreen* pScreen = QGuiApplication::screenAt(QPoint(0, 0)); +#else + // QGuiApplication::screenAt was added in Qt 5.10, use deprecated QDesktopWidget int nLeftScreen = QApplication::desktop()->screenNumber(QPoint(0, 0)); - SAL_WNODEPRECATED_DECLARATIONS_POP - aSize = toSize(QApplication::screens()[nLeftScreen]->availableVirtualGeometry().size()); + QScreen* pScreen = QGuiApplication::screens()[nLeftScreen]; +#endif + aSize = toSize(pScreen->availableVirtualGeometry().size()); } } @@ -1216,23 +1218,25 @@ void Qt5Frame::SetScreenNumber(unsigned int nScreen) if (!m_bFullScreenSpanAll) { - SAL_WNODEPRECATED_DECLARATIONS_PUSH - screenGeo = QApplication::desktop()->screenGeometry(nScreen); - SAL_WNODEPRECATED_DECLARATIONS_POP + screenGeo = QGuiApplication::screens().at(nScreen)->geometry(); pWindow->setScreen(QApplication::screens()[nScreen]); } else // special case: fullscreen over all available screens { assert(m_bFullScreen); // left-most screen - SAL_WNODEPRECATED_DECLARATIONS_PUSH +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) + QScreen* pScreen = QGuiApplication::screenAt(QPoint(0, 0)); +#else + // QGuiApplication::screenAt was added in Qt 5.10, use deprecated QDesktopWidget int nLeftScreen = QApplication::desktop()->screenNumber(QPoint(0, 0)); - SAL_WNODEPRECATED_DECLARATIONS_POP + QScreen* pScreen = QGuiApplication::screens()[nLeftScreen]; +#endif // entire virtual desktop - screenGeo = QApplication::screens()[nLeftScreen]->availableVirtualGeometry(); - pWindow->setScreen(QApplication::screens()[nLeftScreen]); + screenGeo = pScreen->availableVirtualGeometry(); + pWindow->setScreen(pScreen); pWindow->setGeometry(screenGeo); - nScreen = nLeftScreen; + nScreen = screenNumber(pScreen); } // setScreen by itself has no effect, explicitly move the widget to |