Keep statusbar visibility in sync with KToggleAction and persist states
ClosedPublic

Authored by muhlenpfordt on Feb 16 2018, 11:12 AM.

Details

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 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

Diff Detail

Repository
R260 Gwenview
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
muhlenpfordt requested review of this revision.Feb 16 2018, 11:12 AM
muhlenpfordt created this revision.

The statusbar unhiding after applying config dialog was addressed in D10501.

app/mainwindow.cpp
1470–1471

Not needed anymore since toggleStatusBar() is called when setting view/browse mode initially.

1477

Not needed anymore since GwenviewConfig is always up to date now.

rkflx added a subscriber: rkflx.Feb 16 2018, 11:53 PM

Much better than before, but I wonder if we should go all the way and make the statusbar behave like the sidebar (I'm only talking about View mode here). Currently it works like this:

  • Browse mode: State of both sidebar and statusbar remembered globally, i.e. it does not matter whether Fullscreen or not. Perfect!
  • View mode: State of sidebar remembered separately for Fullscreen and normal mode. However, currently the statusbar state is only remembered for normal mode, but always set to disabled initially in Fullscreen.

I feel that in general it makes sense that FullscreenView mode does neither show statusbar nor sidebar. However, if someone enables the sidebar and the statusbar for whatever reason, it does not make sense to only remember this choice for one element instead of both.

Much better than before, but I wonder if we should go all the way and make the statusbar behave like the sidebar

Why not, should be no big deal and getting the same behaviour like the sidebar can't be wrong. ;)
Using the GwenviewConfig we also don't need any new class variables.

muhlenpfordt retitled this revision from Keep statusbar visibility in sync with KToggleAction state to Keep statusbar visibility in sync with KToggleAction and persist states.
muhlenpfordt edited the summary of this revision. (Show Details)
muhlenpfordt edited the test plan for this revision. (Show Details)

Save different states according display mode analogous to sidebar

ATM the config is saved in a new group with 3 entries, the existing sidebar config uses 3 groups of 1 entry each (and IMHO a complicated implementation to access them):

~/.config/gwenviewrc
[StatusBar]
IsVisible BrowseMode=true
IsVisible ViewMode Normal=true
IsVisible ViewMode FullScreen=false

[SideBar-BrowseMode]
IsVisible=true
[SideBar-FullScreenMode]
IsVisible=true
[SideBar-ViewMode]
IsVisible=true

What do you think?
Better adjust the statusbar to sidebar config or vice versa (sometime), keep it mixed or use a completely different syntax?

Works great, almost ready ;)


IsVisible ViewMode Normal=true

If you ever wanted to introduce BrowseMode FullScreen and keep BrowseMode for compatibility, the ViewMode Normal would look odd, while if you wanted to remove ViewMode FullScreen, a simple BrowseMode would still look good. IOW, I would drop the Normal postfix.

Other than that, I vastly prefer your new approach over the old one. Even if it is less generic, the overall idea is expressed better.

What about the sidebar? Cleaner code is good, but I wonder if it is really worth the disruption for the user… We could provide backwards compatibility via kconf_update, but again I'm not sure the (IMO) less important toggling states warrant putting too much work into it. As you are already resetting the statusbar for users, let's either change the sidebar now too (new Diff), or don't change the sidebar at all for the time being.

app/mainwindow.cpp
729

statusBarConfigstatusBarVisibility?

Your are only returning a single bool, but not the complete internal config state.

733–737

Use the ternary operator?

742

I would keep the order as defined in the enum, but that's just me.

750

setStatusBarConfigsaveStatusBarVisibility?

I'd keep it focussed on the visibility for now. When we need to save more, we need a different save/load API design anyway. OTOH, I don't like my names too much either…

muhlenpfordt marked 4 inline comments as done.

Minor renames and rearrangements

If you ever wanted to introduce BrowseMode FullScreen and keep BrowseMode for compatibility, the ViewMode Normal would look odd, while if you wanted to remove ViewMode FullScreen, a simple BrowseMode would still look good. IOW, I would drop the Normal postfix.

Accepted. :)

We could provide backwards compatibility via kconf_update

Good to know. I ever wondered if there is such a thing but didn't searched for it yet.
I'll take a look at the sidebar config, shouldn't be too much work since it's not that different to the statusbar.

app/mainwindow.cpp
729

I wanted to use a different name to not mix it with *MainPage::statusBarVisible() - but statusBarVisibility() is different enough and more to the point. ;)

rkflx accepted this revision.Feb 19 2018, 1:14 PM

Thanks!

app/mainwindow.cpp
742

start → browse → view?

755–759

Ternary operator? (In general this kind of nitpicking in reviews is horrible and I only want to bring it up a single time per author ever, but once we started it, there's the urge to make it consistent…)

This revision is now accepted and ready to land.Feb 19 2018, 1:14 PM
muhlenpfordt marked an inline comment as done.

Switch order 0, 1, 2 / if -> ternary operator

app/mainwindow.cpp
755–759

Oops, never thought about using this without a return value. ;)

rkflx accepted this revision.Feb 19 2018, 1:36 PM
This revision was automatically updated to reflect the committed changes.