diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 5f04ed9f9..634394b88 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -534,7 +534,7 @@ def data(readonly=False): ('title-format', SettingValue(typ.FormatString( fields=['perc', 'perc_raw', 'title', 'title_sep', 'index', - 'id']), '{index}: {title}'), + 'id', 'scroll_pos']), '{index}: {title}'), "The format to use for the tab title. The following placeholders " "are defined:\n\n" "* `{perc}`: The percentage as a string like `[10%]`.\n" diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 893af0748..84e95b094 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -112,6 +112,15 @@ class TabWidget(QTabWidget): fields['index'] = idx + 1 fields['id'] = widget.tab_id fields['title_sep'] = ' - ' if page_title else '' + y = widget.scroll_pos[1] + if y <= 0: + scroll_pos = 'top' + elif y >= 100: + scroll_pos = 'bot' + else: + scroll_pos = '{:2}%'.format(y) + + fields['scroll_pos'] = '{}'.format(scroll_pos) fmt = config.get('tabs', 'title-format') self.tabBar().setTabText(idx, fmt.format(**fields)) @@ -158,6 +167,7 @@ class TabWidget(QTabWidget): text = text_or_empty new_idx = super().addTab(page, icon, '') self.set_page_title(new_idx, text) + page.scroll_pos_changed.connect(lambda: self.update_tab_title(new_idx)) return new_idx def insertTab(self, idx, page, icon_or_text, text_or_empty=None): @@ -188,6 +198,7 @@ class TabWidget(QTabWidget): text = text_or_empty new_idx = super().insertTab(idx, page, icon, '') self.set_page_title(new_idx, text) + page.scroll_pos_changed.connect(lambda: self.update_tab_title(new_idx)) return new_idx @pyqtSlot(int)