Skip to content

Commit

Permalink
Gui: replace deprecated QDesktopWidget with QScreen
Browse files Browse the repository at this point in the history
Since Qt5.11 QDesktopWidget is marked as deprecated and has been removed in Qt6. New code has to use QScreen instead.
  • Loading branch information
wwmayer committed Oct 11, 2023
1 parent 5449281 commit 4eee90f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Gui/MainWindow.cpp
Expand Up @@ -31,7 +31,6 @@
# include <QCloseEvent>
# include <QContextMenuEvent>
# include <QDesktopServices>
# include <QDesktopWidget>
# include <QDockWidget>
# include <QFontMetrics>
# include <QKeySequence>
Expand Down Expand Up @@ -262,7 +261,7 @@ struct MainWindowP
int actionUpdateDelay = 0;
QMap<QString, QPointer<UrlHandler> > urlHandler;
std::string hiddenDockWindows;
int screen = -1;
QPointer<QScreen> screen;
boost::signals2::scoped_connection connParam;
ParameterGrp::handle hGrp;
bool _restoring = false;
Expand Down Expand Up @@ -1666,7 +1665,8 @@ void MainWindow::loadWindowSettings()
QString qtver = QStringLiteral("Qt%1.%2").arg(major).arg(minor);
QSettings config(vendor, application);

QRect rect = QApplication::desktop()->availableGeometry(d->screen);
QRect rect = d->screen ? d->screen->availableGeometry()
: QApplication::primaryScreen()->availableGeometry();

config.beginGroup(qtver);
QPoint pos = config.value(QStringLiteral("Position"), this->pos()).toPoint();
Expand Down Expand Up @@ -1804,10 +1804,15 @@ void MainWindow::startSplasher()
if (hGrp->GetBool("ShowSplasher", true)) {
d->splashscreen = new SplashScreen(this->splashImage());
d->splashscreen->show();
d->screen = QApplication::desktop()->screenNumber(d->splashscreen);
#if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
d->screen = d->splashscreen->screen();
#else
d->screen = QApplication::primaryScreen();
#endif
}
else
else {
d->splashscreen = nullptr;
}
}
}

Expand Down

0 comments on commit 4eee90f

Please sign in to comment.