summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Mühlenpfordt <[email protected]>2018-02-06 13:10:50 +0100
committerPeter Mühlenpfordt <[email protected]>2018-02-09 13:40:39 +0100
commit0d917337122fcc02270586effa99997df881a32d (patch)
tree53facb0d82ebb0c156218ac010c7c8dd28899d56
parent7608ae8a5f8197d92160736990eb71f1503041d1 (diff)
Keep Gwenview fullscreen mode in sync with window manager
Summary: Toggling fullscreen mode in Gwenview does not reflect in window manager and vice versa. This patch changes toggling fullscreen mode from `setWindowState()` to `KToggleFullScreenAction::setFullScreen()` as the api doc recommends. BUG: 195046 Test Plan: Start Gwenview in windowed or fullscreen mode and toggle by window manager, e.g. {nav Alt+F3 > More Actions > Fullscreen}. Use other tools to toggle Gwenview's fullscreen mode: ``` kstart --fullscreen gwenview image.jpg wmctrl -i -r <WINID> -b add,fullscreen wmctrl -i -r <WINID> -b remove,fullscreen ``` Reviewers: rkflx, ngraham Reviewed By: rkflx Subscribers: broulik Differential Revision: https://phabricator.kde.org/D10360
-rw-r--r--app/mainwindow.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp
index e13ca4c..56a1b0d 100644
--- a/app/mainwindow.cpp
+++ b/app/mainwindow.cpp
@@ -130,7 +130,6 @@ enum MainPageId {
struct MainWindowState
{
bool mToolBarVisible;
- Qt::WindowStates mWindowState;
};
/*
@@ -189,7 +188,7 @@ struct MainWindow::Private
QAction * mGoToFirstAction;
QAction * mGoToLastAction;
KToggleAction* mToggleSideBarAction;
- KToggleFullScreenAction* mFullScreenAction;
+ QAction* mFullScreenAction;
QAction * mToggleSlideShowAction;
KToggleAction* mShowMenuBarAction;
KToggleAction* mShowStatusBarAction;
@@ -394,7 +393,7 @@ struct MainWindow::Private
connect(mViewModeActionGroup, SIGNAL(triggered(QAction*)),
q, SLOT(setActiveViewModeAction(QAction*)));
- mFullScreenAction = static_cast<KToggleFullScreenAction*>(view->addAction(KStandardAction::FullScreen, q, SLOT(toggleFullScreen(bool))));
+ mFullScreenAction = KStandardAction::fullScreen(q, &MainWindow::toggleFullScreen, q, actionCollection);
QList<QKeySequence> shortcuts = mFullScreenAction->shortcuts();
shortcuts.append(QKeySequence(Qt::Key_F11));
actionCollection->setDefaultShortcuts(mFullScreenAction, shortcuts);
@@ -1260,16 +1259,16 @@ void MainWindow::toggleFullScreen(bool checked)
// Save MainWindow config now, this way if we quit while in
// fullscreen, we are sure latest MainWindow changes are remembered.
KConfigGroup saveConfigGroup = autoSaveConfigGroup();
- saveMainWindowSettings(saveConfigGroup);
+ if (!isFullScreen()) {
+ // Save state if window manager did not already switch to fullscreen.
+ saveMainWindowSettings(saveConfigGroup);
+ d->mStateBeforeFullScreen.mToolBarVisible = toolBar()->isVisible();
+ }
setAutoSaveSettings(saveConfigGroup, false);
resetAutoSaveSettings();
- // Save state
- d->mStateBeforeFullScreen.mToolBarVisible = toolBar()->isVisible();
- d->mStateBeforeFullScreen.mWindowState = windowState();
-
// Go full screen
- setWindowState(windowState() | Qt::WindowFullScreen);
+ KToggleFullScreenAction::setFullScreen(this, true);
menuBar()->hide();
toolBar()->hide();
@@ -1298,7 +1297,7 @@ void MainWindow::toggleFullScreen(bool checked)
d->mViewMainPage->setFullScreenMode(false);
d->mSlideShow->stop();
d->mSaveBar->setFullScreenMode(false);
- setWindowState(d->mStateBeforeFullScreen.mWindowState);
+ KToggleFullScreenAction::setFullScreen(this, false);
menuBar()->setVisible(d->mShowMenuBarAction->isChecked());
toggleStatusBar();
toolBar()->setVisible(d->mStateBeforeFullScreen.mToolBarVisible);