Make Qt apply fullscreen change from UI as well

This commit is contained in:
iota97 committed 2020-10-10 16:26:07 +02:00
1 parent cd42f8b3a6
commit 4c0908ef44
1 file changed
+10 -10
+10 -10
View File
@@ -24,13 +24,6 @@ MainWindow::MainWindow(QWidget *parent, bool fullscreen) :
nextState(CORE_POWERDOWN),
lastUIState(UISTATE_MENU)
{
QDesktopWidget *desktop = QApplication::desktop();
int screenNum = QProcessEnvironment::systemEnvironment().value("SDL_VIDEO_FULLSCREEN_HEAD", "0").toInt();
// Move window to the center of selected screen
QRect rect = desktop->screenGeometry(screenNum);
move((rect.width() - frameGeometry().width()) / 4, (rect.height() - frameGeometry().height()) / 4);
setWindowIcon(QIcon(qApp->applicationDirPath() + "/assets/icon_regular_72.png"));
SetGameTitle("");
@@ -64,6 +57,9 @@ void MainWindow::newFrame()
updateMenus();
}
if (g_Config.bFullScreen != isFullScreen())
SetFullScreen(g_Config.bFullScreen);
std::unique_lock<std::mutex> lock(msgMutex_);
while (!msgQueue_.empty()) {
MainWindowMsg msg = msgQueue_.front();
@@ -112,9 +108,6 @@ void MainWindow::updateMenus()
void MainWindow::bootDone()
{
if (g_Config.bFullScreen != isFullScreen())
SetFullScreen(g_Config.bFullScreen);
if (nextState == CORE_RUNNING)
runAct();
updateMenus();
@@ -389,6 +382,13 @@ void MainWindow::SetFullScreen(bool fullscreen) {
if (GetUIState() == UISTATE_INGAME && QApplication::overrideCursor())
QApplication::restoreOverrideCursor();
QDesktopWidget *desktop = QApplication::desktop();
int screenNum = QProcessEnvironment::systemEnvironment().value("SDL_VIDEO_FULLSCREEN_HEAD", "0").toInt();
// Move window to the center of selected screen
QRect rect = desktop->screenGeometry(screenNum);
move((rect.width() - frameGeometry().width()) / 4, (rect.height() - frameGeometry().height()) / 4);
}
}