Skip to content

Commit

Permalink
Move TabIndex'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 2c05e9f commit 61834b9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion qutebrowser/mainwindow/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ def _connect_signals(self):
self.tabbed_browser.cur_scroll_perc_changed.connect(
self.status.percentage.widget.set_perc)
self.tabbed_browser.widget.tab_index_changed.connect(
self.status.tabindex.on_tab_index_changed)
self.status.tabindex.widget.on_tab_index_changed)

self.tabbed_browser.cur_url_changed.connect(
self.status.url.widget.set_url)
Expand Down
4 changes: 2 additions & 2 deletions qutebrowser/mainwindow/statusbar/bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def __init__(self, *, win_id, private, parent=None):
self.url = url.UrlText(widget=url.UrlTextWidget())
self.percentage = percentage.Percentage(widget=percentage.PercentageWidget())
self.backforward = backforward.Backforward(widget=backforward.BackforwardWidget())
self.tabindex = tabindex.TabIndex()
self.tabindex = tabindex.TabIndex(widget=tabindex.TabIndexWidget())
self.keystring = keystring.KeyString(widget=keystring.KeyStringWidget())
self.prog = progress.Progress(widget=progress.ProgressWidget(self))
self.clock = clock.Clock(widget=clock.ClockWidget())
Expand Down Expand Up @@ -277,7 +277,7 @@ def _clear_widgets(self):
"""Clear widgets before redrawing them."""
# Start with widgets hidden and show them when needed
for widget in [self.url.widget, self.percentage.widget,
self.backforward.widget, self.tabindex,
self.backforward.widget, self.tabindex.widget,
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]:
Expand Down
13 changes: 12 additions & 1 deletion qutebrowser/mainwindow/statusbar/tabindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,22 @@
from qutebrowser.mainwindow.statusbar import textbase


class TabIndex(textbase.TextBase):
class TabIndexWidget(textbase.TextBase):

"""Shows current tab index and number of tabs in the statusbar."""

@pyqtSlot(int, int)
def on_tab_index_changed(self, current, count):
"""Update tab index when tab changed."""
self.setText('[{}/{}]'.format(current + 1, count))


class TabIndex:

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

View workflow job for this annotation

GitHub Actions / linters (flake8)

Missing docstring in public class

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

View workflow job for this annotation

GitHub Actions / linters (pylint)

Missing class docstring
def __init__(self, widget: TabIndexWidget):
self.widget = widget

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

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

0 comments on commit 61834b9

Please sign in to comment.