From 9cc040a806fd2e6f1458e801a99311168d594c77 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Mon, 9 Sep 2019 16:11:48 +0200 Subject: Prepare for deprecating the QDesktopWidget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QDesktopWidget is marked as obsolete in docs, but it is not yet completely deprecated, some of its methods are still in use. Replace uses of the following methods marked as obsolete: - QDesktopWidget::screenNumber(QWidget*) -> QWidget::screen() - QDesktopWidget::screenGeometry(QWidget*) -> QWidget::screen()->geometry() - QDesktopWidget::availableGeometry(QWidget*) -> QWidget::screen()->availableGeometry() Task-number: QTBUG-76491 Change-Id: I2cca30f2b4caa6e6848e8190e09f959d2c272f33 Reviewed-by: Tor Arne Vestbø --- examples/widgets/desktop/screenshot/main.cpp | 5 +++-- examples/widgets/desktop/screenshot/screenshot.cpp | 2 +- examples/widgets/dialogs/standarddialogs/main.cpp | 4 ++-- examples/widgets/itemviews/dirview/main.cpp | 4 ++-- examples/widgets/mainwindows/application/mainwindow.cpp | 2 +- examples/widgets/mainwindows/mdi/mainwindow.cpp | 2 +- examples/widgets/mainwindows/sdi/mainwindow.cpp | 4 ++-- examples/widgets/richtext/textedit/main.cpp | 4 ++-- examples/widgets/tools/codecs/mainwindow.cpp | 6 +++--- examples/widgets/tools/codecs/previewform.cpp | 4 ++-- examples/widgets/tools/settingseditor/mainwindow.cpp | 4 ++-- examples/widgets/tools/settingseditor/settingstree.cpp | 4 ++-- examples/widgets/widgets/charactermap/mainwindow.cpp | 3 ++- examples/widgets/widgets/icons/main.cpp | 4 ++-- 14 files changed, 27 insertions(+), 25 deletions(-) (limited to 'examples/widgets') 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 -#include +#include #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 +#include #include -#include #include #include #include @@ -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 -#include #include #include +#include #include #include #include @@ -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 -#include #include #include +#include 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 #include -#include #include #include #include #include #include +#include #include #include @@ -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 #include -#include #include #include #include #include #include +#include #include #include @@ -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 #include -#include #include #include #include #include #include +#include #include #include @@ -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 -#include #include +#include #include 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 #include #include +#include #include #include #include @@ -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 #include -#include +#include #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); -- cgit v1.2.3