diff options
29 files changed, 60 insertions, 65 deletions
diff --git a/examples/corelib/mimetypes/mimetypebrowser/main.cpp b/examples/corelib/mimetypes/mimetypebrowser/main.cpp index cf87004a01..679d97dc7b 100644 --- a/examples/corelib/mimetypes/mimetypebrowser/main.cpp +++ b/examples/corelib/mimetypes/mimetypebrowser/main.cpp @@ -51,7 +51,7 @@ #include "mainwindow.h" #include <QApplication> -#include <QDesktopWidget> +#include <QScreen> #include <QCommandLineParser> #include <QCommandLineOption> @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) parser.process(app); MainWindow mainWindow; - const QRect availableGeometry = QApplication::desktop()->availableGeometry(&mainWindow); + const QRect availableGeometry = mainWindow.screen()->availableGeometry(); mainWindow.resize(availableGeometry.width() / 3, availableGeometry.height() / 2); mainWindow.show(); diff --git a/examples/network/http/main.cpp b/examples/network/http/main.cpp index b7d254ff22..f126c7846a 100644 --- a/examples/network/http/main.cpp +++ b/examples/network/http/main.cpp @@ -49,8 +49,8 @@ ****************************************************************************/ #include <QApplication> -#include <QDesktopWidget> #include <QDir> +#include <QScreen> #include "httpwindow.h" @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); HttpWindow httpWin; - const QRect availableSize = QApplication::desktop()->availableGeometry(&httpWin); + const QRect availableSize = httpWin.screen()->availableGeometry(); httpWin.resize(availableSize.width() / 5, availableSize.height() / 5); httpWin.move((availableSize.width() - httpWin.width()) / 2, (availableSize.height() - httpWin.height()) / 2); diff --git a/examples/opengl/threadedqopenglwidget/main.cpp b/examples/opengl/threadedqopenglwidget/main.cpp index 983f608543..975def030b 100644 --- a/examples/opengl/threadedqopenglwidget/main.cpp +++ b/examples/opengl/threadedqopenglwidget/main.cpp @@ -50,7 +50,7 @@ #include <QApplication> #include <QMainWindow> -#include <QDesktopWidget> +#include <QScreen> #include <QSurfaceFormat> #include <QOpenGLContext> #include <QCommandLineParser> @@ -90,7 +90,7 @@ int main( int argc, char ** argv ) // The rendering for the four QOpenGLWidgets happens on four separate threads. GLWidget topLevelGlWidget; - QPoint pos = QApplication::desktop()->availableGeometry(&topLevelGlWidget).topLeft() + QPoint(200, 200); + QPoint pos = topLevelGlWidget.screen()->availableGeometry().topLeft() + QPoint(200, 200); topLevelGlWidget.setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example top level")); topLevelGlWidget.resize(200, 200); topLevelGlWidget.move(pos); diff --git a/examples/widgets/desktop/screenshot/main.cpp b/examples/widgets/desktop/screenshot/main.cpp index 825c40b236..96b0d57daa 100644 --- a/examples/widgets/desktop/screenshot/main.cpp +++ b/examples/widgets/desktop/screenshot/main.cpp @@ -49,7 +49,7 @@ ****************************************************************************/ #include <QApplication> -#include <QDesktopWidget> +#include <QScreen> #include "screenshot.h" @@ -58,7 +58,8 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); Screenshot screenshot; - screenshot.move(QApplication::desktop()->availableGeometry(&screenshot).topLeft() + QPoint(20, 20)); + screenshot.move(screenshot.screen()->availableGeometry().topLeft() + QPoint(20, 20)); screenshot.show(); + return app.exec(); } diff --git a/examples/widgets/desktop/screenshot/screenshot.cpp b/examples/widgets/desktop/screenshot/screenshot.cpp index 715e6c780e..ce5597bbdd 100644 --- a/examples/widgets/desktop/screenshot/screenshot.cpp +++ b/examples/widgets/desktop/screenshot/screenshot.cpp @@ -59,7 +59,7 @@ Screenshot::Screenshot() screenshotLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); screenshotLabel->setAlignment(Qt::AlignCenter); - const QRect screenGeometry = QApplication::desktop()->screenGeometry(this); + const QRect screenGeometry = screen()->geometry(); screenshotLabel->setMinimumSize(screenGeometry.width() / 8, screenGeometry.height() / 8); QVBoxLayout *mainLayout = new QVBoxLayout(this); diff --git a/examples/widgets/dialogs/standarddialogs/main.cpp b/examples/widgets/dialogs/standarddialogs/main.cpp index f7417f0e45..19ed2bf66f 100644 --- a/examples/widgets/dialogs/standarddialogs/main.cpp +++ b/examples/widgets/dialogs/standarddialogs/main.cpp @@ -49,8 +49,8 @@ ****************************************************************************/ #include <QApplication> +#include <QScreen> #include <QStyleHints> -#include <QDesktopWidget> #include <QTranslator> #include <QLocale> #include <QLibraryInfo> @@ -73,7 +73,7 @@ int main(int argc, char *argv[]) Dialog dialog; if (!QGuiApplication::styleHints()->showIsFullScreen() && !QGuiApplication::styleHints()->showIsMaximized()) { - const QRect availableGeometry = QApplication::desktop()->availableGeometry(&dialog); + const QRect availableGeometry = dialog.screen()->availableGeometry(); dialog.resize(availableGeometry.width() / 3, availableGeometry.height() * 2 / 3); dialog.move((availableGeometry.width() - dialog.width()) / 2, (availableGeometry.height() - dialog.height()) / 2); diff --git a/examples/widgets/itemviews/dirview/main.cpp b/examples/widgets/itemviews/dirview/main.cpp index 9fecffda40..fcdf4c7ba4 100644 --- a/examples/widgets/itemviews/dirview/main.cpp +++ b/examples/widgets/itemviews/dirview/main.cpp @@ -49,9 +49,9 @@ ****************************************************************************/ #include <QApplication> -#include <QDesktopWidget> #include <QFileSystemModel> #include <QFileIconProvider> +#include <QScreen> #include <QTreeView> #include <QCommandLineParser> #include <QCommandLineOption> @@ -92,7 +92,7 @@ int main(int argc, char *argv[]) tree.setAnimated(false); tree.setIndentation(20); tree.setSortingEnabled(true); - const QSize availableSize = QApplication::desktop()->availableGeometry(&tree).size(); + const QSize availableSize = tree.screen()->availableGeometry().size(); tree.resize(availableSize / 2); tree.setColumnWidth(0, tree.width() / 3); diff --git a/examples/widgets/mainwindows/application/mainwindow.cpp b/examples/widgets/mainwindows/application/mainwindow.cpp index 7886c4afac..d0c009427f 100644 --- a/examples/widgets/mainwindows/application/mainwindow.cpp +++ b/examples/widgets/mainwindows/application/mainwindow.cpp @@ -281,7 +281,7 @@ void MainWindow::readSettings() QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName()); const QByteArray geometry = settings.value("geometry", QByteArray()).toByteArray(); if (geometry.isEmpty()) { - const QRect availableGeometry = QApplication::desktop()->availableGeometry(this); + const QRect availableGeometry = screen()->availableGeometry(); resize(availableGeometry.width() / 3, availableGeometry.height() / 2); move((availableGeometry.width() - width()) / 2, (availableGeometry.height() - height()) / 2); diff --git a/examples/widgets/mainwindows/mdi/mainwindow.cpp b/examples/widgets/mainwindows/mdi/mainwindow.cpp index b952d19e2e..ccfa7435d7 100644 --- a/examples/widgets/mainwindows/mdi/mainwindow.cpp +++ b/examples/widgets/mainwindows/mdi/mainwindow.cpp @@ -464,7 +464,7 @@ void MainWindow::readSettings() QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName()); const QByteArray geometry = settings.value("geometry", QByteArray()).toByteArray(); if (geometry.isEmpty()) { - const QRect availableGeometry = QApplication::desktop()->availableGeometry(this); + const QRect availableGeometry = screen()->availableGeometry(); resize(availableGeometry.width() / 3, availableGeometry.height() / 2); move((availableGeometry.width() - width()) / 2, (availableGeometry.height() - height()) / 2); diff --git a/examples/widgets/mainwindows/sdi/mainwindow.cpp b/examples/widgets/mainwindows/sdi/mainwindow.cpp index a1fb42158e..c3cd131923 100644 --- a/examples/widgets/mainwindows/sdi/mainwindow.cpp +++ b/examples/widgets/mainwindows/sdi/mainwindow.cpp @@ -167,7 +167,7 @@ void MainWindow::tile(const QMainWindow *previous) if (!topFrameWidth) topFrameWidth = 40; const QPoint pos = previous->pos() + 2 * QPoint(topFrameWidth, topFrameWidth); - if (QApplication::desktop()->availableGeometry(this).contains(rect().bottomRight() + pos)) + if (screen()->availableGeometry().contains(rect().bottomRight() + pos)) move(pos); } @@ -290,7 +290,7 @@ void MainWindow::readSettings() QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName()); const QByteArray geometry = settings.value("geometry", QByteArray()).toByteArray(); if (geometry.isEmpty()) { - const QRect availableGeometry = QApplication::desktop()->availableGeometry(this); + const QRect availableGeometry = screen()->availableGeometry(); resize(availableGeometry.width() / 3, availableGeometry.height() / 2); move((availableGeometry.width() - width()) / 2, (availableGeometry.height() - height()) / 2); diff --git a/examples/widgets/richtext/textedit/main.cpp b/examples/widgets/richtext/textedit/main.cpp index aef186aa77..256d183811 100644 --- a/examples/widgets/richtext/textedit/main.cpp +++ b/examples/widgets/richtext/textedit/main.cpp @@ -51,9 +51,9 @@ #include "textedit.h" #include <QApplication> -#include <QDesktopWidget> #include <QCommandLineParser> #include <QCommandLineOption> +#include <QScreen> int main(int argc, char *argv[]) { @@ -72,7 +72,7 @@ int main(int argc, char *argv[]) TextEdit mw; - const QRect availableGeometry = QApplication::desktop()->availableGeometry(&mw); + const QRect availableGeometry = mw.screen()->availableGeometry(); mw.resize(availableGeometry.width() / 2, (availableGeometry.height() * 2) / 3); mw.move((availableGeometry.width() - mw.width()) / 2, (availableGeometry.height() - mw.height()) / 2); diff --git a/examples/widgets/tools/codecs/mainwindow.cpp b/examples/widgets/tools/codecs/mainwindow.cpp index 6b601062b6..dc72fa73b7 100644 --- a/examples/widgets/tools/codecs/mainwindow.cpp +++ b/examples/widgets/tools/codecs/mainwindow.cpp @@ -54,12 +54,12 @@ #include <QAction> #include <QApplication> -#include <QDesktopWidget> #include <QFileDialog> #include <QMenuBar> #include <QMessageBox> #include <QPlainTextEdit> #include <QRegularExpression> +#include <QScreen> #include <QTextCodec> #include <QTextStream> @@ -78,7 +78,7 @@ MainWindow::MainWindow() setWindowTitle(tr("Codecs")); - const QRect screenGeometry = QApplication::desktop()->screenGeometry(this); + const QRect screenGeometry = screen()->geometry(); resize(screenGeometry.width() / 2, screenGeometry.height() * 2 / 3); } @@ -216,7 +216,7 @@ void MainWindow::encodingDialog() { if (!m_encodingDialog) { m_encodingDialog = new EncodingDialog(this); - const QRect screenGeometry = QApplication::desktop()->screenGeometry(this); + const QRect screenGeometry = screen()->geometry(); m_encodingDialog->setMinimumWidth(screenGeometry.width() / 4); } m_encodingDialog->show(); diff --git a/examples/widgets/tools/codecs/previewform.cpp b/examples/widgets/tools/codecs/previewform.cpp index ec75ebb9fa..f48651335a 100644 --- a/examples/widgets/tools/codecs/previewform.cpp +++ b/examples/widgets/tools/codecs/previewform.cpp @@ -52,12 +52,12 @@ #include <QApplication> #include <QComboBox> -#include <QDesktopWidget> #include <QDialogButtonBox> #include <QGridLayout> #include <QLabel> #include <QPlainTextEdit> #include <QPushButton> +#include <QScreen> #include <QTextCodec> #include <QTextStream> @@ -183,7 +183,7 @@ PreviewForm::PreviewForm(QWidget *parent) mainLayout->addWidget(statusLabel, 2, 0, 1, 2); mainLayout->addWidget(buttonBox, 3, 0, 1, 2); - const QRect screenGeometry = QApplication::desktop()->screenGeometry(this); + const QRect screenGeometry = screen()->geometry(); resize(screenGeometry.width() * 2 / 5, screenGeometry.height() / 2); } diff --git a/examples/widgets/tools/settingseditor/mainwindow.cpp b/examples/widgets/tools/settingseditor/mainwindow.cpp index b9c2193ccb..ccca16ffcd 100644 --- a/examples/widgets/tools/settingseditor/mainwindow.cpp +++ b/examples/widgets/tools/settingseditor/mainwindow.cpp @@ -54,12 +54,12 @@ #include <QAction> #include <QApplication> -#include <QDesktopWidget> #include <QFileDialog> #include <QInputDialog> #include <QLineEdit> #include <QMenuBar> #include <QMessageBox> +#include <QScreen> #include <QStandardPaths> #include <QStatusBar> @@ -74,7 +74,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) fallbacksAct->setChecked(true); setWindowTitle(QCoreApplication::applicationName()); - const QRect availableGeometry = QApplication::desktop()->availableGeometry(this); + const QRect availableGeometry = screen()->availableGeometry(); adjustSize(); move((availableGeometry.width() - width()) / 2, (availableGeometry.height() - height()) / 2); } diff --git a/examples/widgets/tools/settingseditor/settingstree.cpp b/examples/widgets/tools/settingseditor/settingstree.cpp index b263746847..49d299bf72 100644 --- a/examples/widgets/tools/settingseditor/settingstree.cpp +++ b/examples/widgets/tools/settingseditor/settingstree.cpp @@ -52,8 +52,8 @@ #include "variantdelegate.h" #include <QApplication> -#include <QDesktopWidget> #include <QHeaderView> +#include <QScreen> #include <QSettings> SettingsTree::SettingsTree(QWidget *parent) @@ -93,7 +93,7 @@ void SettingsTree::setSettingsObject(const SettingsPtr &newSettings) QSize SettingsTree::sizeHint() const { - const QRect availableGeometry = QApplication::desktop()->availableGeometry(this); + const QRect availableGeometry = screen()->availableGeometry(); return QSize(availableGeometry.width() * 2 / 3, availableGeometry.height() * 2 / 3); } diff --git a/examples/widgets/widgets/charactermap/mainwindow.cpp b/examples/widgets/widgets/charactermap/mainwindow.cpp index 25c4503ddb..b0f9705c21 100644 --- a/examples/widgets/widgets/charactermap/mainwindow.cpp +++ b/examples/widgets/widgets/charactermap/mainwindow.cpp @@ -64,6 +64,7 @@ #include <QMenuBar> #include <QPlainTextEdit> #include <QPushButton> +#include <QScreen> #include <QScrollArea> #include <QStatusBar> #include <QTextStream> @@ -302,7 +303,7 @@ QString FontInfoDialog::text() const void MainWindow::showInfo() { - const QRect screenGeometry = QApplication::desktop()->screenGeometry(this); + const QRect screenGeometry = screen()->geometry(); FontInfoDialog *dialog = new FontInfoDialog(this); dialog->setWindowTitle(tr("Fonts")); dialog->setAttribute(Qt::WA_DeleteOnClose); diff --git a/examples/widgets/widgets/icons/main.cpp b/examples/widgets/widgets/icons/main.cpp index a045ea765a..632795c18c 100644 --- a/examples/widgets/widgets/icons/main.cpp +++ b/examples/widgets/widgets/icons/main.cpp @@ -50,7 +50,7 @@ #include <QApplication> #include <QCommandLineParser> -#include <QDesktopWidget> +#include <QScreen> #include "mainwindow.h" @@ -77,7 +77,7 @@ int main(int argc, char *argv[]) if (!commandLineParser.positionalArguments().isEmpty()) mainWin.loadImages(commandLineParser.positionalArguments()); - const QRect availableGeometry = QApplication::desktop()->availableGeometry(&mainWin); + const QRect availableGeometry = mainWin.screen()->availableGeometry(); mainWin.resize(availableGeometry.width() / 2, availableGeometry.height() * 2 / 3); mainWin.move((availableGeometry.width() - mainWin.width()) / 2, (availableGeometry.height() - mainWin.height()) / 2); diff --git a/examples/xml/dombookmarks/mainwindow.cpp b/examples/xml/dombookmarks/mainwindow.cpp index fade2dfc96..b8f2e12918 100644 --- a/examples/xml/dombookmarks/mainwindow.cpp +++ b/examples/xml/dombookmarks/mainwindow.cpp @@ -63,7 +63,7 @@ MainWindow::MainWindow() statusBar()->showMessage(tr("Ready")); setWindowTitle(tr("DOM Bookmarks")); - const QSize availableSize = QApplication::desktop()->availableGeometry(this).size(); + const QSize availableSize = screen()->availableGeometry().size(); resize(availableSize.width() / 2, availableSize.height() / 3); } diff --git a/examples/xml/saxbookmarks/mainwindow.cpp b/examples/xml/saxbookmarks/mainwindow.cpp index 0583cd82cf..8b7733081f 100644 --- a/examples/xml/saxbookmarks/mainwindow.cpp +++ b/examples/xml/saxbookmarks/mainwindow.cpp @@ -74,7 +74,7 @@ MainWindow::MainWindow() statusBar()->showMessage(tr("Ready")); setWindowTitle(tr("SAX Bookmarks")); - const QSize availableSize = QApplication::desktop()->availableGeometry(this).size(); + const QSize availableSize = screen()->availableGeometry().size(); resize(availableSize.width() / 2, availableSize.height() / 3); } diff --git a/examples/xml/streambookmarks/mainwindow.cpp b/examples/xml/streambookmarks/mainwindow.cpp index c9a18fa3c4..d0e7bf30c9 100644 --- a/examples/xml/streambookmarks/mainwindow.cpp +++ b/examples/xml/streambookmarks/mainwindow.cpp @@ -75,7 +75,7 @@ MainWindow::MainWindow() statusBar()->showMessage(tr("Ready")); setWindowTitle(tr("QXmlStream Bookmarks")); - const QSize availableSize = QApplication::desktop()->availableGeometry(this).size(); + const QSize availableSize = screen()->availableGeometry().size(); resize(availableSize.width() / 2, availableSize.height() / 3); } //! [0] diff --git a/src/widgets/util/qscroller.cpp b/src/widgets/util/qscroller.cpp index 1e84237253..df05bbf71c 100644 --- a/src/widgets/util/qscroller.cpp +++ b/src/widgets/util/qscroller.cpp @@ -1031,7 +1031,8 @@ void QScrollerPrivate::setDpi(const QPointF &dpi) */ void QScrollerPrivate::setDpiFromWidget(QWidget *widget) { - const QScreen *screen = QGuiApplication::screens().at(QApplication::desktop()->screenNumber(widget)); + const QScreen *screen = widget ? widget->screen() : QGuiApplication::primaryScreen(); + Q_ASSERT(screen); setDpi(QPointF(screen->physicalDotsPerInchX(), screen->physicalDotsPerInchY())); } diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp index 13dc924f93..54bb8fe0bd 100644 --- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp +++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp @@ -26,7 +26,7 @@ ** ****************************************************************************/ -#include <QtWidgets/QDesktopWidget> +#include <QtGui/QScreen> #include <QtWidgets/QGraphicsItem> #include <QtWidgets/QGraphicsScene> #include <QtWidgets/QGraphicsView> @@ -617,7 +617,7 @@ void tst_QTouchEvent::basicRawEventTranslation() QPointF pos = touchWidget.rect().center(); QPointF screenPos = touchWidget.mapToGlobal(pos.toPoint()); QPointF delta(10, 10); - QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget); + QRectF screenGeometry = touchWidget.screen()->geometry(); QTouchEvent::TouchPoint rawTouchPoint; rawTouchPoint.setId(0); @@ -753,7 +753,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() QPointF leftScreenPos = leftWidget.mapToGlobal(leftPos.toPoint()); QPointF rightScreenPos = rightWidget.mapToGlobal(rightPos.toPoint()); QPointF centerScreenPos = touchWidget.mapToGlobal(centerPos.toPoint()); - QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget); + QRectF screenGeometry = touchWidget.screen()->geometry(); QList<QTouchEvent::TouchPoint> rawTouchPoints; rawTouchPoints.append(QTouchEvent::TouchPoint(0)); @@ -968,7 +968,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens() QPointF pos = touchWidget.rect().center(); QPointF screenPos = touchWidget.mapToGlobal(pos.toPoint()); QPointF delta(10, 10); - QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget); + QRectF screenGeometry = touchWidget.screen()->geometry(); QVector<QTouchEvent::TouchPoint> rawTouchPoints(3); rawTouchPoints[0].setId(0); @@ -1131,7 +1131,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() QPointF leftScreenPos = leftWidget.mapToGlobal(leftPos.toPoint()); QPointF rightScreenPos = rightWidget.mapToGlobal(rightPos.toPoint()); QPointF centerScreenPos = touchWidget.mapToGlobal(centerPos.toPoint()); - QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget); + QRectF screenGeometry = touchWidget.screen()->geometry(); QList<QTouchEvent::TouchPoint> rawTouchPoints; rawTouchPoints.append(QTouchEvent::TouchPoint(0)); @@ -1348,7 +1348,7 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds() screenPos << touchWidget.mapToGlobal(pos[i].toPoint()); } QPointF delta(10, 10); - QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget); + QRectF screenGeometry = touchWidget.screen()->geometry(); QVector<QPointF> rawPosList; rawPosList << QPointF(12, 34) << QPointF(56, 78); @@ -1629,7 +1629,7 @@ void tst_QTouchEvent::deleteInRawEventTranslation() QPointF leftScreenPos = leftWidget->mapToGlobal(leftPos.toPoint()); QPointF centerScreenPos = centerWidget->mapToGlobal(centerPos.toPoint()); QPointF rightScreenPos = rightWidget->mapToGlobal(rightPos.toPoint()); - QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget); + QRectF screenGeometry = touchWidget.screen()->geometry(); QList<QTouchEvent::TouchPoint> rawTouchPoints; rawTouchPoints.append(QTouchEvent::TouchPoint(0)); diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 0b08586f7d..af0dd9b0f0 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -10977,7 +10977,7 @@ static QList<QTouchEvent::TouchPoint> tp.setStartScreenPos(screenPos); tp.setLastScreenPos(screenPos); tp.setEllipseDiameters(ellipseDiameters); - const QSizeF screenSize = QApplication::desktop()->screenGeometry(&view).size(); + const QSizeF screenSize = view.screen()->geometry().size(); tp.setNormalizedPos(QPointF(screenPos.x() / screenSize.width(), screenPos.y() / screenSize.height())); return QList<QTouchEvent::TouchPoint>() << tp; } diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 3e372b76f5..40377eb946 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -5383,7 +5383,7 @@ void tst_QWidget::moveChild() parent.setStyle(style.data()); ColorWidget child(&parent, Qt::Widget, Qt::blue); - parent.setGeometry(QRect(QPoint(QApplication::desktop()->availableGeometry(&parent).topLeft()) + QPoint(50, 50), + parent.setGeometry(QRect(parent.screen()->availableGeometry().topLeft() + QPoint(50, 50), QSize(200, 200))); child.setGeometry(25, 25, 50, 50); #ifndef QT_NO_CURSOR // Try to make sure the cursor is not in a taskbar area to prevent tooltips or window highlighting @@ -5430,8 +5430,7 @@ void tst_QWidget::showAndMoveChild() const QScopedPointer<QStyle> style(QStyleFactory::create(QLatin1String("Windows"))); parent.setStyle(style.data()); - QDesktopWidget desktop; - QRect desktopDimensions = desktop.availableGeometry(&parent); + QRect desktopDimensions = parent.screen()->availableGeometry(); desktopDimensions = desktopDimensions.adjusted(64, 64, -64, -64); #ifndef QT_NO_CURSOR // Try to make sure the cursor is not in a taskbar area to prevent tooltips or window highlighting @@ -7708,7 +7707,7 @@ void tst_QWidget::repaintWhenChildDeleted() #endif ColorWidget w(nullptr, Qt::FramelessWindowHint, Qt::red); w.setWindowTitle(QLatin1String(QTest::currentTestFunction())); - QPoint startPoint = QApplication::desktop()->availableGeometry(&w).topLeft(); + QPoint startPoint = w.screen()->availableGeometry().topLeft(); startPoint.rx() += 50; startPoint.ry() += 50; w.setGeometry(QRect(startPoint, QSize(100, 100))); @@ -7733,7 +7732,7 @@ void tst_QWidget::hideOpaqueChildWhileHidden() { ColorWidget w(nullptr, Qt::FramelessWindowHint, Qt::red); w.setWindowTitle(QLatin1String(QTest::currentTestFunction())); - QPoint startPoint = QApplication::desktop()->availableGeometry(&w).topLeft(); + QPoint startPoint = w.screen()->availableGeometry().topLeft(); startPoint.rx() += 50; startPoint.ry() += 50; w.setGeometry(QRect(startPoint, QSize(100, 100))); @@ -9601,8 +9600,7 @@ void tst_QWidget::rectOutsideCoordinatesLimit_task144779() palette.setColor(QPalette::Window, Qt::red); main.setPalette(palette); - QDesktopWidget desktop; - QRect desktopDimensions = desktop.availableGeometry(&main); + QRect desktopDimensions = main.screen()->availableGeometry(); QSize mainSize(400, 400); mainSize = mainSize.boundedTo(desktopDimensions.size()); main.resize(mainSize); diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp index 5a51f15008..27ae41fc4f 100644 --- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp @@ -1765,7 +1765,7 @@ void tst_QCompleter::QTBUG_52028_tabAutoCompletes() auto le = new QLineEdit; w.layout()->addWidget(le); - const auto pos = QApplication::desktop()->availableGeometry(&w).topLeft() + QPoint(200,200); + const auto pos = w.screen()->availableGeometry().topLeft() + QPoint(200,200); w.move(pos); w.show(); QApplication::setActiveWindow(&w); @@ -1806,7 +1806,7 @@ void tst_QCompleter::QTBUG_51889_activatedSentTwice() w.layout()->addWidget(new QLineEdit); - const auto pos = QApplication::desktop()->availableGeometry(&w).topLeft() + QPoint(200,200); + const auto pos = w.screen()->availableGeometry().topLeft() + QPoint(200,200); w.move(pos); w.show(); QApplication::setActiveWindow(&w); diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 4e16edaca8..b7869a0653 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -34,7 +34,6 @@ #include <qpa/qplatformtheme.h> #include <qfontcombobox.h> -#include <qdesktopwidget.h> #include <qapplication.h> #include <qpushbutton.h> #include <qdialog.h> @@ -2212,15 +2211,13 @@ void tst_QComboBox::itemListPosition() QFontComboBox combo(&topLevel); layout->addWidget(&combo); - //the code to get the available screen space is copied from QComboBox code - const int scrNumber = QApplication::desktop()->screenNumber(&combo); bool useFullScreenForPopupMenu = false; if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) useFullScreenForPopupMenu = theme->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool(); const QRect screen = useFullScreenForPopupMenu ? - QApplication::screens().at(scrNumber)->geometry() : - QApplication::screens().at(scrNumber)->availableGeometry(); + combo.screen()->geometry() : + combo.screen()->availableGeometry(); topLevel.move(screen.width() - topLevel.sizeHint().width() - 10, 0); //puts the combo to the top-right corner @@ -2440,8 +2437,7 @@ void tst_QComboBox::task248169_popupWithMinimalSize() #if defined QT_BUILD_INTERNAL QFrame *container = comboBox.findChild<QComboBoxPrivateContainer *>(); QVERIFY(container); - QDesktopWidget desktop; - QTRY_VERIFY(desktop.screenGeometry(container).contains(container->geometry())); + QTRY_VERIFY(container->screen()->geometry().contains(container->geometry())); #endif } diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index d6ba85d61f..417d6e3124 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -34,7 +34,6 @@ #include <qstyle.h> #include <qproxystyle.h> #include <qstylefactory.h> -#include <qdesktopwidget.h> #include <qaction.h> #include <qstyleoption.h> #include <QVBoxLayout> @@ -1149,8 +1148,8 @@ void tst_QMenuBar::check_menuPosition() Menu menu; menu.setTitle("&menu"); - QRect availRect = QApplication::desktop()->availableGeometry(&w); - QRect screenRect = QApplication::desktop()->screenGeometry(&w); + QRect availRect = w.screen()->availableGeometry(); + QRect screenRect = w.screen()->geometry(); while(menu.sizeHint().height() < (screenRect.height()*2/3)) { menu.addAction("item"); diff --git a/tests/manual/dialogs/printdialogpanel.cpp b/tests/manual/dialogs/printdialogpanel.cpp index 8d64d2f6a6..b7447e3d64 100644 --- a/tests/manual/dialogs/printdialogpanel.cpp +++ b/tests/manual/dialogs/printdialogpanel.cpp @@ -710,8 +710,7 @@ void PrintDialogPanel::showPreviewDialog() applySettings(m_printer.data()); PrintPreviewDialog dialog(m_printer.data(), this); #if QT_VERSION >= 0x050000 - const int screenNumber = QApplication::desktop()->screenNumber(this); - const QSize availableSize = QGuiApplication::screens().at(screenNumber)->availableSize(); + const QSize availableSize = screen()->availableSize(); #else const QSize availableSize = QApplication::desktop()->availableGeometry().size(); #endif diff --git a/tests/manual/qcursor/qcursorhighdpi/main.cpp b/tests/manual/qcursor/qcursorhighdpi/main.cpp index 017f41eccd..e70be333fd 100644 --- a/tests/manual/qcursor/qcursorhighdpi/main.cpp +++ b/tests/manual/qcursor/qcursorhighdpi/main.cpp @@ -218,7 +218,7 @@ protected: VerticalRuler::VerticalRuler(QWidget *parent) : QWidget(parent) { - const int screenWidth = QApplication::desktop()->screenGeometry(this).width(); + const int screenWidth = screen()->geometry().width(); setFixedWidth(screenWidth / 48); // 1920 pixel monitor ->40 } |