Commit c2e8c892 authored by Peter Mühlenpfordt's avatar Peter Mühlenpfordt

Keep statusbar visibility in sync with KToggleAction and persist states

Summary:
When switching to fullscreen view mode the statusbar is hidden but the
`KToggleAction` is not updated. This leads to unhiding the statusbar
after applying config dialog and forcing the user to press {key F3}
twice to show the statusbar.
This patch keeps visibility and action state in sync by using persistent
`GwenviewConfig` values for browse mode and normal/fullscreen view
modes like sidebar.

Test Plan:
Switch browse/view, normal/fullscreen modes.
The statusbar state should always restore to previous setting.
Three different states are (re)stored:
* Browse mode (always equal in normal/fullscreen mode)
* View mode normal (windowed) mode
* View mode fullscreen mode

Reviewers: #gwenview, rkflx

Reviewed By: #gwenview, rkflx

Subscribers: rkflx

Differential Revision: https://phabricator.kde.org/D10577
parent 543f0b9c
......@@ -463,7 +463,7 @@ struct MainWindow::Private
q->setStandardToolBarMenuEnabled(true);
mShowMenuBarAction = static_cast<KToggleAction*>(view->addAction(KStandardAction::ShowMenubar, q, SLOT(toggleMenuBar())));
mShowStatusBarAction = static_cast<KToggleAction*>(view->addAction(KStandardAction::ShowStatusbar, q, SLOT(toggleStatusBar())));
mShowStatusBarAction = static_cast<KToggleAction*>(view->addAction(KStandardAction::ShowStatusbar, q, SLOT(toggleStatusBar(bool))));
actionCollection->setDefaultShortcut(mShowStatusBarAction, Qt::Key_F3);
......@@ -726,6 +726,42 @@ struct MainWindow::Private
GwenviewConfig::setSideBarPage(mSideBar->currentPage());
}
bool statusBarVisibility() const
{
switch (mCurrentMainPageId) {
case StartMainPageId:
GV_WARN_AND_RETURN_VALUE(false, "Statusbar not implemented on start page");
break;
case BrowseMainPageId:
return GwenviewConfig::statusBarVisibleBrowseMode();
break;
case ViewMainPageId:
return q->isFullScreen()
? GwenviewConfig::statusBarVisibleViewModeFullScreen()
: GwenviewConfig::statusBarVisibleViewMode();
break;
}
return false;
}
void setStatusBarVisibility(const bool visible)
{
switch (mCurrentMainPageId) {
case StartMainPageId:
GV_WARN_AND_RETURN("Statusbar not implemented on start page");
break;
case BrowseMainPageId:
GwenviewConfig::setStatusBarVisibleBrowseMode(visible);
break;
case ViewMainPageId:
q->isFullScreen()
? GwenviewConfig::setStatusBarVisibleViewModeFullScreen(visible)
: GwenviewConfig::setStatusBarVisibleViewMode(visible);
break;
}
}
void setScreenSaverEnabled(bool enabled)
{
// Always delete mNotificationRestrictions, it does not hurt
......@@ -905,6 +941,7 @@ void MainWindow::setActiveViewModeAction(QAction* action)
}
d->loadSideBarConfig();
d->autoAssignThumbnailProvider();
toggleStatusBar(d->statusBarVisibility());
emit viewModeChanged();
}
......@@ -1070,10 +1107,13 @@ void MainWindow::toggleSideBar(bool on)
d->mSideBar->setVisible(on);
}
void MainWindow::toggleStatusBar()
void MainWindow::toggleStatusBar(bool visible)
{
d->mViewMainPage->setStatusBarVisible(d->mShowStatusBarAction->isChecked());
d->mBrowseMainPage->setStatusBarVisible(d->mShowStatusBarAction->isChecked());
d->mShowStatusBarAction->setChecked(visible);
d->setStatusBarVisibility(visible);
d->mViewMainPage->setStatusBarVisible(visible);
d->mBrowseMainPage->setStatusBarVisible(visible);
}
void MainWindow::updateToggleSideBarAction()
......@@ -1286,7 +1326,6 @@ void MainWindow::toggleFullScreen(bool checked)
d->mSlideShow->stop();
KToggleFullScreenAction::setFullScreen(this, false);
menuBar()->setVisible(d->mShowMenuBarAction->isChecked());
toggleStatusBar();
toolBar()->setVisible(d->mStateBeforeFullScreen.mToolBarVisible);
d->setScreenSaverEnabled(true);
......@@ -1301,6 +1340,7 @@ void MainWindow::toggleFullScreen(bool checked)
d->mSaveBar->setFullScreenMode(checked);
d->loadSideBarConfig();
toggleStatusBar(d->statusBarVisibility());
setUpdatesEnabled(true);
d->autoAssignThumbnailProvider();
......@@ -1466,15 +1506,11 @@ void MainWindow::loadConfig()
d->mViewMainPage->loadConfig();
d->mBrowseMainPage->loadConfig();
d->mContextManager->loadConfig();
d->mShowStatusBarAction->setChecked(GwenviewConfig::statusBarIsVisible());
toggleStatusBar();
}
void MainWindow::saveConfig()
{
d->mFileOpenRecentAction->saveEntries(KConfigGroup(KSharedConfig::openConfig(), "Recent Files"));
GwenviewConfig::setStatusBarIsVisible(d->mShowStatusBarAction->isChecked());
d->mViewMainPage->saveConfig();
d->mBrowseMainPage->saveConfig();
d->mContextManager->saveConfig();
......
......@@ -125,7 +125,7 @@ private Q_SLOTS:
void preloadNextUrl();
void toggleMenuBar();
void toggleStatusBar();
void toggleStatusBar(bool visible);
void showFirstDocumentReached();
void showLastDocumentReached();
......
......@@ -492,8 +492,6 @@ void ViewMainPage::setStatusBarVisible(bool visible)
void ViewMainPage::setFullScreenMode(bool fullScreenMode)
{
d->mStatusBarContainer->setVisible(!fullScreenMode);
if (fullScreenMode) {
d->mThumbnailBarVisibleBeforeFullScreen = d->mToggleThumbnailBarAction->isChecked();
if (d->mThumbnailBarVisibleBeforeFullScreen) {
......
......@@ -43,9 +43,6 @@
<entry name="ThumbnailBarIsVisible" type="Bool">
<default>false</default>
</entry>
<entry name="StatusBarIsVisible" type="Bool">
<default>true</default>
</entry>
<entry name="LastTargetDir" type="Path">
<default code="true">
......@@ -295,4 +292,15 @@
</entry>
</group>
<group name="StatusBar">
<entry name="StatusBarVisibleBrowseMode" key="IsVisible BrowseMode" type="Bool">
<default>true</default>
</entry>
<entry name="StatusBarVisibleViewMode" key="IsVisible ViewMode" type="Bool">
<default>true</default>
</entry>
<entry name="StatusBarVisibleViewModeFullScreen" key="IsVisible ViewMode FullScreen" type="Bool">
<default>false</default>
</entry>
</group>
</kcfg>
Markdown is supported
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