Commit 0d917337 authored by Peter Mühlenpfordt's avatar Peter Mühlenpfordt
Browse files

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
parent 7608ae8a
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment