From 1f2a1efee5a03400823897e47a5e54954ead6a9f Mon Sep 17 00:00:00 2001 From: Ray Chason Date: Wed, 29 Dec 2021 01:44:02 -0500 Subject: [PATCH] Use QApplication::desktop for screen size on Qt5 5.15 has QWidget::screen, but older versions don't. --- win/Qt/qt_bind.cpp | 9 +++++++-- win/Qt/qt_main.cpp | 9 +++++++-- win/Qt/qt_menu.cpp | 7 ++++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/win/Qt/qt_bind.cpp b/win/Qt/qt_bind.cpp index 94f54f528..d1c007e4e 100644 --- a/win/Qt/qt_bind.cpp +++ b/win/Qt/qt_bind.cpp @@ -95,8 +95,13 @@ NetHackQtBind::NetHackQtBind(int& argc, char** argv) : lsplash->setFixedSize(pm.size()); lsplash->setMask(QBitmap(pm)); } - splash->move((splash->screen()->size().width()-pm.width())/2, - (splash->screen()->size().height()-pm.height())/2); +#if QT_VERSION < 0x060000 + QSize screensize = QApplication::desktop()->size(); +#else + QSize screensize = splash->screen()->size(); +#endif + splash->move((screensize.width()-pm.width())/2, + (screensize.height()-pm.height())/2); //splash->setGeometry(0,0,100,100); if ( qt_compact_mode ) { splash->showMaximized(); diff --git a/win/Qt/qt_main.cpp b/win/Qt/qt_main.cpp index fb990bfc6..465d61a3f 100644 --- a/win/Qt/qt_main.cpp +++ b/win/Qt/qt_main.cpp @@ -861,9 +861,14 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) : setMenu (menubar); #endif +#if QT_VERSION < 0x060000 + QSize screensize = QApplication::desktop()->size(); +#else + QSize screensize = screen()->size(); +#endif int x=0,y=0; - int w=screen()->size().width()-10; // XXX arbitrary extra space for frame - int h=screen()->size().height()-50; + int w=screensize.width()-10; // XXX arbitrary extra space for frame + int h=screensize.height()-50; int maxwn; int maxhn; diff --git a/win/Qt/qt_menu.cpp b/win/Qt/qt_menu.cpp index c5403f7c8..4425b8a35 100644 --- a/win/Qt/qt_menu.cpp +++ b/win/Qt/qt_menu.cpp @@ -1133,7 +1133,12 @@ void NetHackQtTextWindow::Display(bool block UNUSED) search.show(); rip.hide(); } - int mh = screen()->size().height()*3/5; +#if QT_VERSION < 0x060000 + QSize screensize = QApplication::desktop()->size(); +#else + QSize screensize = screen()->size(); +#endif + int mh = screensize.height()*3/5; if ( (qt_compact_mode && lines->TotalHeight() > mh) || use_rip ) { // big, so make it fill showMaximized();