diff --git a/doc/TODO b/doc/TODO index 0d3a5558f..540cb097c 100644 --- a/doc/TODO +++ b/doc/TODO @@ -42,7 +42,6 @@ New big features Improvements / minor features ============================= -- Color statusbar in insert mode - set_toggle to toggle setting between two states - Customizable statusbar - Show size of widgets in __repr__ diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 4117d9f03..ec9052836 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -839,6 +839,10 @@ DATA = OrderedDict([ SettingValue(types.Color(), 'darkblue'), "Background color of the statusbar if there is a prompt."), + ('statusbar.bg.insert', + SettingValue(types.Color(), 'darkgreen'), + "Background color of the statusbar in insert mode."), + ('statusbar.progress.bg', SettingValue(types.Color(), 'white'), "Background color of the progress bar."), diff --git a/qutebrowser/widgets/statusbar/bar.py b/qutebrowser/widgets/statusbar/bar.py index 029f1850e..b7886f06e 100644 --- a/qutebrowser/widgets/statusbar/bar.py +++ b/qutebrowser/widgets/statusbar/bar.py @@ -75,6 +75,12 @@ class StatusBar(QWidget): For some reason we need to have this as class attribute so pyqtProperty works correctly. + _insert_active: If we're currently in insert mode, accessed through the + insert_active property. + + For some reason we need to have this as class attribute + so pyqtProperty works correctly. + Signals: resized: Emitted when the statusbar has resized, so the completion widget can adjust its size to it. @@ -88,6 +94,7 @@ class StatusBar(QWidget): moved = pyqtSignal('QPoint') _error = False _prompt_active = False + _insert_active = False STYLESHEET = """ QWidget#StatusBar {{ @@ -102,6 +109,10 @@ class StatusBar(QWidget): {color[statusbar.bg.prompt]} }} + QWidget#StatusBar[insert_active="true"] {{ + {color[statusbar.bg.insert]} + }} + QWidget {{ {color[statusbar.fg]} {font[statusbar]} @@ -184,13 +195,13 @@ class StatusBar(QWidget): @pyqtProperty(bool) def prompt_active(self): - """Getter for self.prompt, so it can be used as Qt property.""" + """Getter for self.prompt_active, so it can be used as Qt property.""" # pylint: disable=method-hidden return self._prompt_active @prompt_active.setter def prompt_active(self, val): - """Setter for self.prompt, so it can be used as Qt property. + """Setter for self.prompt_active, so it can be used as Qt property. Re-set the stylesheet after setting the value, so everything gets updated by Qt properly. @@ -198,6 +209,22 @@ class StatusBar(QWidget): self._prompt_active = val self.setStyleSheet(get_stylesheet(self.STYLESHEET)) + @pyqtProperty(bool) + def insert_active(self): + """Getter for self.insert_active, so it can be used as Qt property.""" + # pylint: disable=method-hidden + return self._insert_active + + @insert_active.setter + def insert_active(self, val): + """Setter for self.insert_active, so it can be used as Qt property. + + Re-set the stylesheet after setting the value, so everything gets + updated by Qt properly. + """ + self._insert_active = val + self.setStyleSheet(get_stylesheet(self.STYLESHEET)) + def _pop_text(self): """Display a text in the statusbar and pop it from _text_queue.""" try: @@ -331,12 +358,16 @@ class StatusBar(QWidget): """Mark certain modes in the commandline.""" if mode in modeman.instance().passthrough: self.txt.normaltext = "-- {} MODE --".format(mode.upper()) + if mode == 'insert': + self.insert_active = True @pyqtSlot(str) def on_mode_left(self, mode): """Clear marked mode.""" if mode in modeman.instance().passthrough: self.txt.normaltext = "" + if mode == 'insert': + self.insert_active = False @pyqtSlot(str, str) def on_config_changed(self, section, option):