From 4f0034911a49c0c4f4ff06fe013666e649e8f2cb Mon Sep 17 00:00:00 2001 From: thuck Date: Tue, 8 Nov 2016 07:56:13 +0100 Subject: [PATCH] title-format-pinned initial work Created configuration configdata. Load and use template defined on configdata. TODO: ability to conserve information between restart TODO: ability to update title on configuration change --- qutebrowser/config/configdata.py | 17 +++++++++++++++++ qutebrowser/mainwindow/tabwidget.py | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 6664e4b8e..1dadb4fb1 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -679,6 +679,23 @@ def data(readonly=False): "* `{scroll_pos}`: The page scroll position.\n" "* `{host}`: The host of the current web page."), + ('title-format-pinned', + SettingValue(typ.FormatString( + fields=['perc', 'perc_raw', 'title', 'title_sep', 'index', + 'id', 'scroll_pos', 'host'], none_ok=True), + '{index}'), + "The format to use for the pinned tab title." + " The following placeholders are defined:\n\n" + "* `{perc}`: The percentage as a string like `[10%]`.\n" + "* `{perc_raw}`: The raw percentage, e.g. `10`\n" + "* `{title}`: The title of the current web page\n" + "* `{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.\n" + "* `{scroll_pos}`: The page scroll position.\n" + "* `{host}`: The host of the current web page."), + ('title-alignment', SettingValue(typ.TextAlignment(), 'left'), "Alignment of the text inside of tabs"), diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index ac9c0ede3..e22c7a75f 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -107,9 +107,10 @@ class TabWidget(QTabWidget): fields['index'] = idx + 1 fmt = config.get('tabs', 'title-format') + fmt_pinned = config.get('tabs', 'title-format-pinned') if fields['pinned']: - title = '{index}'.format(**fields) + title = fmt_pinned.format(**fields) else: title = '' if fmt is None else fmt.format(**fields)