diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 8f40c1444..654fe4af0 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -280,9 +280,9 @@ |<>|Name of the session to save by default. |<>|Load a restored tab as soon as it takes focus. |<>|Languages to use for spell checking. -|<>|Hide the statusbar unless a message is shown. |<>|Padding (in pixels) for the statusbar. |<>|Position of the status bar. +|<>|When to show the statusbar. |<>|List of widgets displayed in the statusbar. |<>|Open new tabs (middleclick/ctrl+click) in the background. |<>|Mouse button with which to close tabs. @@ -3585,14 +3585,6 @@ On QtWebEngine, this setting requires Qt 5.8 or newer. On QtWebKit, this setting is unavailable. -[[statusbar.hide]] -=== statusbar.hide -Hide the statusbar unless a message is shown. - -Type: <> - -Default: +pass:[false]+ - [[statusbar.padding]] === statusbar.padding Padding (in pixels) for the statusbar. @@ -3619,6 +3611,20 @@ Valid values: Default: +pass:[bottom]+ +[[statusbar.show]] +=== statusbar.show +When to show the statusbar. + +Type: <> + +Valid values: + + * +always+: Always show the statusbar. + * +never+: Always hide the statusbar unless a message is shown. + * +in-mode+: Only show the statusbar when in modes other than normal mode or when a message is shown. + +Default: +pass:[always]+ + [[statusbar.widgets]] === statusbar.widgets List of widgets displayed in the statusbar. diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index 700c3b851..963533a1b 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -1559,10 +1559,17 @@ spellcheck.languages: ## statusbar -statusbar.hide: - type: Bool - default: false - desc: Hide the statusbar unless a message is shown. +statusbar.show: + default: always + type: + name: String + valid_values: + - always: Always show the statusbar. + - never: Always hide the statusbar unless a message is shown. + - in-mode: >- + Only show the statusbar when in modes other than normal mode or + when a message is shown. + desc: When to show the statusbar. statusbar.padding: type: Padding diff --git a/qutebrowser/config/configfiles.py b/qutebrowser/config/configfiles.py index c5148f6cb..635702b01 100644 --- a/qutebrowser/config/configfiles.py +++ b/qutebrowser/config/configfiles.py @@ -332,6 +332,11 @@ class YamlMigrations(QObject): new_name='tabs.mode_on_change', true_value='persist', false_value='normal') + self._migrate_renamed_bool( + old_name='statusbar.hide', + new_name='statusbar.show', + true_value='never', + false_value='always') for setting in ['tabs.title.format', 'tabs.title.format_pinned', diff --git a/qutebrowser/keyinput/modeman.py b/qutebrowser/keyinput/modeman.py index 880b1ec93..eb96020f3 100644 --- a/qutebrowser/keyinput/modeman.py +++ b/qutebrowser/keyinput/modeman.py @@ -68,6 +68,14 @@ class NotInModeError(Exception): """Exception raised when we want to leave a mode we're not in.""" +class UnavailableError(Exception): + + """Exception raised when trying to access modeman before initialization. + + Thrown by instance() if modeman has not been initialized yet. + """ + + def init(win_id: int, parent: QObject) -> 'ModeManager': """Initialize the mode manager and the keyparsers for the given win_id.""" modeman = ModeManager(win_id, parent) @@ -169,8 +177,16 @@ def init(win_id: int, parent: QObject) -> 'ModeManager': def instance(win_id: Union[int, str]) -> 'ModeManager': - """Get a modemanager object.""" - return objreg.get('mode-manager', scope='window', window=win_id) + """Get a modemanager object. + + Raises UnavailableError if there is no instance available yet. + """ + mode_manager = objreg.get('mode-manager', scope='window', window=win_id, + default=None) + if mode_manager is not None: + return mode_manager + else: + raise UnavailableError("ModeManager is not initialized yet.") def enter(win_id: int, diff --git a/qutebrowser/mainwindow/statusbar/bar.py b/qutebrowser/mainwindow/statusbar/bar.py index 91bdb0b6e..f83c77db9 100644 --- a/qutebrowser/mainwindow/statusbar/bar.py +++ b/qutebrowser/mainwindow/statusbar/bar.py @@ -203,7 +203,7 @@ class StatusBar(QWidget): @pyqtSlot(str) def _on_config_changed(self, option): - if option == 'statusbar.hide': + if option == 'statusbar.show': self.maybe_hide() elif option == 'statusbar.padding': self._set_hbox_padding() @@ -254,12 +254,26 @@ class StatusBar(QWidget): @pyqtSlot() def maybe_hide(self): """Hide the statusbar if it's configured to do so.""" + strategy = config.val.statusbar.show tab = self._current_tab() - hide = config.val.statusbar.hide - if hide or (tab is not None and tab.data.fullscreen): + if tab is not None and tab.data.fullscreen: self.hide() - else: + elif strategy == 'never': + self.hide() + elif strategy == 'in-mode': + try: + mode_manager = modeman.instance(self._win_id) + except modeman.UnavailableError: + self.hide() + else: + if mode_manager.mode == usertypes.KeyMode.normal: + self.hide() + else: + self.show() + elif strategy == 'always': self.show() + else: + raise utils.Unreachable def _set_hbox_padding(self): padding = config.val.statusbar.padding @@ -336,6 +350,8 @@ class StatusBar(QWidget): def on_mode_entered(self, mode): """Mark certain modes in the commandline.""" mode_manager = modeman.instance(self._win_id) + if config.val.statusbar.show == 'in-mode': + self.show() if mode_manager.parsers[mode].passthrough: self._set_mode_text(mode.name) if mode in [usertypes.KeyMode.insert, @@ -350,6 +366,8 @@ class StatusBar(QWidget): def on_mode_left(self, old_mode, new_mode): """Clear marked mode.""" mode_manager = modeman.instance(self._win_id) + if config.val.statusbar.show == 'in-mode': + self.hide() if mode_manager.parsers[old_mode].passthrough: if mode_manager.parsers[new_mode].passthrough: self._set_mode_text(new_mode.name)