From: Manuel Nickschas Date: Sun, 22 Dec 2013 23:48:45 +0000 (+0100) Subject: Fix fullscreen mode X-Git-Tag: 0.10-beta1~71 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=47a6910aed00018c7230cc2cc90ae8e80fa77dda Fix fullscreen mode In some setups, the FullScreen action would get out of sync with the actual window state and thus kick Quassel into an endless loop and finally a crash when toggling full screen mode. Turns out reading the docs for KToggleFullScreenAction helped doing this properly (avoiding this and other bugs when using QWidget's methods). Thanks to yofel and hays for reporting, and apachelogger for putting me on the right track for fixing this. Fixes #1153, fixes #1258. --- diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 9019e24c..d5e9b0cd 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -385,13 +385,13 @@ void MainWin::setupActions() 0, 0))->setCheckable(true); #ifdef HAVE_KDE - QAction *fullScreenAct = KStandardAction::fullScreen(this, SLOT(toggleFullscreen()), this, coll); + QAction *fullScreenAct = KStandardAction::fullScreen(this, SLOT(onFullScreenToggled()), this, coll); #else QAction *fullScreenAct = new Action(SmallIcon("view-fullscreen"), tr("&Full Screen Mode"), coll, - this, SLOT(toggleFullscreen()), QKeySequence(Qt::Key_F11)); + this, SLOT(onFullScreenToggled()), QKeySequence(Qt::Key_F11)); fullScreenAct->setCheckable(true); #endif - coll->addAction("ToggleFullscreen", fullScreenAct); + coll->addAction("ToggleFullScreen", fullScreenAct); // Settings QAction *configureShortcutsAct = new Action(SmallIcon("configure-shortcuts"), tr("Configure &Shortcuts..."), coll, @@ -920,7 +920,7 @@ void MainWin::setupTopicWidget() void MainWin::setupViewMenuTail() { _viewMenu->addSeparator(); - _viewMenu->addAction(QtUi::actionCollection("General")->action("ToggleFullscreen")); + _viewMenu->addAction(QtUi::actionCollection("General")->action("ToggleFullScreen")); } @@ -1358,12 +1358,24 @@ void MainWin::showShortcutsDlg() } -void MainWin::toggleFullscreen() +void MainWin::onFullScreenToggled() { - if (isFullScreen()) - showNormal(); + // Relying on QWidget::isFullScreen is discouraged, see the KToggleFullScreenAction docs + // Also, one should not use showFullScreen() or showNormal(), as those reset all other window flags + + QAction *action = QtUi::actionCollection("General")->action("ToggleFullScreen"); + if (!action) + return; + +#ifdef HAVE_KDE + KToggleFullScreenAction *kAct = static_cast(action); + kAct->setFullScreen(this, kAct->isChecked()); +#else + if (action->isChecked()) + setWindowState(windowState() | Qt::WindowFullScreen); else - showFullScreen(); + setWindowState(windowState() & ~Qt::WindowFullScreen); +#endif } diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h index 9104654e..9ae9a2a2 100644 --- a/src/qtui/mainwin.h +++ b/src/qtui/mainwin.h @@ -122,7 +122,7 @@ private slots: void showNotificationsDlg(); void showIgnoreList(QString newRule = QString()); void showShortcutsDlg(); - void toggleFullscreen(); + void onFullScreenToggled(); void handleCoreConnectionError(const QString &errorMsg); void userAuthenticationRequired(CoreAccount *, bool *valid, const QString &errorMessage);