Skip to content

Commit

Permalink
Move KeyString's enable/disable logic to separate class
Browse files Browse the repository at this point in the history
  • Loading branch information
pylbrecht committed Jul 7, 2024
1 parent 1b0b802 commit 2c05e9f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion qutebrowser/mainwindow/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ def _connect_signals(self):

# commands
mode_manager.keystring_updated.connect(
self.status.keystring.on_keystring_updated)
self.status.keystring.widget.on_keystring_updated)
self.status.cmd.got_cmd[str].connect(self._commandrunner.run_safely)
self.status.cmd.got_cmd[str, int].connect(self._commandrunner.run_safely)
self.status.cmd.returnPressed.connect(self.tabbed_browser.on_cmd_return_pressed)
Expand Down
6 changes: 3 additions & 3 deletions qutebrowser/mainwindow/statusbar/bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def __init__(self, *, win_id, private, parent=None):
self.percentage = percentage.Percentage(widget=percentage.PercentageWidget())
self.backforward = backforward.Backforward(widget=backforward.BackforwardWidget())
self.tabindex = tabindex.TabIndex()
self.keystring = keystring.KeyString()
self.keystring = keystring.KeyString(widget=keystring.KeyStringWidget())
self.prog = progress.Progress(widget=progress.ProgressWidget(self))
self.clock = clock.Clock(widget=clock.ClockWidget())
self._text_widgets = []
Expand Down Expand Up @@ -247,7 +247,7 @@ def _draw_widgets(self):
# instances for all widgets.
if isinstance(widget, (url.UrlText, backforward.Backforward,
progress.Progress, percentage.Percentage,
clock.Clock)):
clock.Clock, keystring.KeyString)):
widget = widget.widget

self._hbox.addWidget(widget)
Expand Down Expand Up @@ -278,7 +278,7 @@ def _clear_widgets(self):
# Start with widgets hidden and show them when needed
for widget in [self.url.widget, self.percentage.widget,
self.backforward.widget, self.tabindex,
self.keystring, self.prog.widget, self.clock.widget, *self._text_widgets]:
self.keystring.widget, self.prog.widget, self.clock.widget, *self._text_widgets]:
assert isinstance(widget, QWidget)
if widget in [self.prog.widget, self.backforward.widget]:
widget.enabled = False # type: ignore[attr-defined]
Expand Down
13 changes: 12 additions & 1 deletion qutebrowser/mainwindow/statusbar/keystring.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,21 @@
from qutebrowser.utils import usertypes


class KeyString(textbase.TextBase):
class KeyStringWidget(textbase.TextBase):

"""Keychain string displayed in the statusbar."""

@pyqtSlot(usertypes.KeyMode, str)
def on_keystring_updated(self, _mode, keystr):
self.setText(keystr)


class KeyString:

Check warning on line 22 in qutebrowser/mainwindow/statusbar/keystring.py

View workflow job for this annotation

GitHub Actions / linters (pylint)

Missing class docstring

Check warning on line 22 in qutebrowser/mainwindow/statusbar/keystring.py

View workflow job for this annotation

GitHub Actions / linters (flake8)

Missing docstring in public class
def __init__(self, widget: KeyStringWidget):
self.widget = widget

def enable(self):
self.widget.show()

def disable(self):
self.widget.hide()

0 comments on commit 2c05e9f

Please sign in to comment.