Merge branch 'scroll_in_title' of https://github.com/averrin/qutebrowser into averrin-scroll_in_title
This commit is contained in:
commit
7fcbbc98f6
@ -299,7 +299,8 @@ def data(readonly=False):
|
||||
|
||||
('window-title-format',
|
||||
SettingValue(typ.FormatString(fields=['perc', 'perc_raw', 'title',
|
||||
'title_sep', 'id']),
|
||||
'title_sep', 'id',
|
||||
'scroll_pos']),
|
||||
'{perc}{title}{title_sep}qutebrowser'),
|
||||
"The format to use for the window title. The following "
|
||||
"placeholders are defined:\n\n"
|
||||
@ -308,7 +309,8 @@ def data(readonly=False):
|
||||
"* `{title}`: The title of the current web page\n"
|
||||
"* `{title_sep}`: The string ` - ` if a title is set, empty "
|
||||
"otherwise.\n"
|
||||
"* `{id}`: The internal window ID of this window."),
|
||||
"* `{id}`: The internal window ID of this window.\n"
|
||||
"* `{scroll_pos}`: The page scroll position."),
|
||||
|
||||
('hide-mouse-cursor',
|
||||
SettingValue(typ.Bool(), 'false'),
|
||||
@ -534,7 +536,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"
|
||||
@ -543,7 +545,8 @@ def data(readonly=False):
|
||||
"* `{title_sep}`: The string ` - ` if a title is set, empty "
|
||||
"otherwise.\n"
|
||||
"* `{index}`: The index of this tab.\n"
|
||||
"* `{id}`: The internal tab ID of this tab."),
|
||||
"* `{id}`: The internal tab ID of this tab.\n"
|
||||
"* `{scroll_pos}`: The page scroll position."),
|
||||
|
||||
('mousewheel-tab-switching',
|
||||
SettingValue(typ.Bool(), 'true'),
|
||||
|
@ -165,6 +165,15 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
fields['title'] = tabtitle
|
||||
fields['title_sep'] = ' - ' if tabtitle else ''
|
||||
fields['id'] = self._win_id
|
||||
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'] = str(scroll_pos)
|
||||
fmt = config.get('ui', 'window-title-format')
|
||||
self.window().setWindowTitle(fmt.format(**fields))
|
||||
|
||||
@ -185,6 +194,7 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
self._filter.create(self.cur_statusbar_message, tab))
|
||||
tab.scroll_pos_changed.connect(
|
||||
self._filter.create(self.cur_scroll_perc_changed, tab))
|
||||
tab.scroll_pos_changed.connect(self.on_scroll_pos_changed)
|
||||
tab.url_text_changed.connect(
|
||||
self._filter.create(self.cur_url_text_changed, tab))
|
||||
tab.load_status_changed.connect(
|
||||
@ -577,6 +587,12 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
if idx == self.currentIndex():
|
||||
self.update_window_title()
|
||||
|
||||
@pyqtSlot()
|
||||
def on_scroll_pos_changed(self):
|
||||
"""Update tab and window title when scroll position changed."""
|
||||
self.update_window_title()
|
||||
self.update_tab_titles()
|
||||
|
||||
def resizeEvent(self, e):
|
||||
"""Extend resizeEvent of QWidget to emit a resized signal afterwards.
|
||||
|
||||
|
@ -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'] = str(scroll_pos)
|
||||
|
||||
fmt = config.get('tabs', 'title-format')
|
||||
self.tabBar().setTabText(idx, fmt.format(**fields))
|
||||
|
Loading…
Reference in New Issue
Block a user