Use QApplication::desktop for screen size on Qt5

5.15 has QWidget::screen, but older versions don't.
This commit is contained in:
Ray Chason
2021-12-30 10:56:07 -08:00
committed by PatR
parent 1f7541e496
commit 1f2a1efee5
3 changed files with 20 additions and 5 deletions
+7 -2
View File
@@ -95,8 +95,13 @@ NetHackQtBind::NetHackQtBind(int& argc, char** argv) :
lsplash->setFixedSize(pm.size()); lsplash->setFixedSize(pm.size());
lsplash->setMask(QBitmap(pm)); lsplash->setMask(QBitmap(pm));
} }
splash->move((splash->screen()->size().width()-pm.width())/2, #if QT_VERSION < 0x060000
(splash->screen()->size().height()-pm.height())/2); 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); //splash->setGeometry(0,0,100,100);
if ( qt_compact_mode ) { if ( qt_compact_mode ) {
splash->showMaximized(); splash->showMaximized();
+7 -2
View File
@@ -861,9 +861,14 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
setMenu (menubar); setMenu (menubar);
#endif #endif
#if QT_VERSION < 0x060000
QSize screensize = QApplication::desktop()->size();
#else
QSize screensize = screen()->size();
#endif
int x=0,y=0; int x=0,y=0;
int w=screen()->size().width()-10; // XXX arbitrary extra space for frame int w=screensize.width()-10; // XXX arbitrary extra space for frame
int h=screen()->size().height()-50; int h=screensize.height()-50;
int maxwn; int maxwn;
int maxhn; int maxhn;
+6 -1
View File
@@ -1133,7 +1133,12 @@ void NetHackQtTextWindow::Display(bool block UNUSED)
search.show(); search.show();
rip.hide(); 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 ) { if ( (qt_compact_mode && lines->TotalHeight() > mh) || use_rip ) {
// big, so make it fill // big, so make it fill
showMaximized(); showMaximized();