From 7a297e2e3f1464c2711e4e0aecae530264a3bb92 Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Wed, 9 May 2018 18:28:05 -0700 Subject: [PATCH 1/6] Add support for muting tabs --- qutebrowser/browser/browsertab.py | 9 +++++++++ qutebrowser/browser/commands.py | 17 +++++++++++++++++ qutebrowser/browser/webengine/webenginetab.py | 9 +++++++++ qutebrowser/browser/webkit/webkittab.py | 7 +++++++ qutebrowser/config/configdata.yml | 4 ++++ qutebrowser/mainwindow/tabbedbrowser.py | 14 ++++++++++++++ qutebrowser/mainwindow/tabwidget.py | 1 + 7 files changed, 61 insertions(+) diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py index 2a9662eef..17376dc7f 100644 --- a/qutebrowser/browser/browsertab.py +++ b/qutebrowser/browser/browsertab.py @@ -649,6 +649,7 @@ class AbstractTab(QWidget): fullscreen_requested = pyqtSignal(bool) renderer_process_terminated = pyqtSignal(TerminationStatus, int) predicted_navigation = pyqtSignal(QUrl) + audio_muted_changed = pyqtSignal(bool) def __init__(self, *, win_id, mode_manager, private, parent=None): self.private = private @@ -923,3 +924,11 @@ class AbstractTab(QWidget): def is_deleted(self): return sip.isdeleted(self._widget) + + def set_muted(self, muted: bool): + """Set this tab as muted or not.""" + raise NotImplementedError + + def is_muted(self): + """Whether this tab is muted.""" + raise NotImplementedError diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 60844029f..e4d75777b 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -2230,3 +2230,20 @@ class CommandDispatcher: window = self._tabbed_browser.widget.window() window.setWindowState(window.windowState() ^ Qt.WindowFullScreen) + + @cmdutils.register(instance='command-dispatcher', scope='window', + name='tab-mute') + @cmdutils.argument('count', count=True) + def tab_mute(self, count=None): + """Mute/Unmute the current/[count]th tab. + + Args: + count: The tab index to pin or unpin, or None + """ + tab = self._cntwidget(count) + if tab is None: + return + try: + tab.set_muted(not tab.is_muted()) + except browsertab.WebTabError as e: + raise cmdexc.CommandError(e) diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index fb04dc120..a0339180b 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -1092,6 +1092,7 @@ class WebEngineTab(browsertab.AbstractTab): page.fullScreenRequested.connect(self._on_fullscreen_requested) page.contentsSizeChanged.connect(self.contents_size_changed) page.navigation_request.connect(self._on_navigation_request) + page.audioMutedChanged.connect(self.audio_muted_changed) view.titleChanged.connect(self.title_changed) view.urlChanged.connect(self._on_url_changed) @@ -1116,3 +1117,11 @@ class WebEngineTab(browsertab.AbstractTab): def event_target(self): return self._widget.focusProxy() + + def set_muted(self, muted: bool): + page = self._widget.page() + page.setAudioMuted(muted) + + def is_muted(self): + page = self._widget.page() + return page.isAudioMuted() diff --git a/qutebrowser/browser/webkit/webkittab.py b/qutebrowser/browser/webkit/webkittab.py index 9d5305f10..ae3a09463 100644 --- a/qutebrowser/browser/webkit/webkittab.py +++ b/qutebrowser/browser/webkit/webkittab.py @@ -828,3 +828,10 @@ class WebKitTab(browsertab.AbstractTab): def event_target(self): return self._widget + + def set_muted(self, muted: bool): + raise browsertab.WebTabError('Muting is not supported on QtWebKit!') + + def is_muted(self): + # Dummy value for things that read muted status + return False diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index 1784e4b7d..cdbaa328b 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -1359,6 +1359,7 @@ tabs.title.format: - private - current_url - protocol + - muted none_ok: true desc: | Format to use for the tab title. @@ -1376,6 +1377,7 @@ tabs.title.format: * `{private}`: Indicates when private mode is enabled. * `{current_url}`: URL of the current web page. * `{protocol}`: Protocol (http/https/...) of the current web page. + * `{muted}`: Icon if the tab is muted tabs.title.format_pinned: default: '{index}' @@ -1393,6 +1395,7 @@ tabs.title.format_pinned: - private - current_url - protocol + - muted none_ok: true desc: Format to use for the tab title for pinned tabs. The same placeholders like for `tabs.title.format` are defined. @@ -1560,6 +1563,7 @@ window.title_format: - private - current_url - protocol + - muted default: '{perc}{title}{title_sep}qutebrowser' desc: | Format to use for the window title. The same placeholders like for diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index 2d674e280..cc290ba1e 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -238,6 +238,8 @@ class TabbedBrowser(QWidget): functools.partial(self.on_window_close_requested, tab)) tab.renderer_process_terminated.connect( functools.partial(self._on_renderer_process_terminated, tab)) + tab.audio_muted_changed.connect( + functools.partial(self.on_mute_changed, tab)) tab.new_tab_requested.connect(self.tabopen) if not self.private: web_history = objreg.get('web-history') @@ -733,6 +735,18 @@ class TabbedBrowser(QWidget): self._update_window_title('scroll_pos') self.widget.update_tab_title(idx, 'scroll_pos') + @pyqtSlot() + def on_mute_changed(self, tab, muted): + """Update tab and window title when scroll position changed.""" + try: + idx = self._tab_index(tab) + except TabDeletedError: + # We can get signals for tabs we already deleted... + return + self.widget.update_tab_title(idx, 'muted') + if idx == self.widget.currentIndex(): + self._update_window_title('muted') + def _on_renderer_process_terminated(self, tab, status, code): """Show an error when a renderer process terminated.""" if status == browsertab.TerminationStatus.normal: diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 6a6eac901..ace938592 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -172,6 +172,7 @@ class TabWidget(QTabWidget): fields['perc_raw'] = tab.progress() fields['backend'] = objects.backend.name fields['private'] = ' [Private Mode] ' if tab.private else '' + fields['muted'] = '[M] ' if tab.is_muted() else '' if tab.load_status() == usertypes.LoadStatus.loading: fields['perc'] = '[{}%] '.format(tab.progress()) From 0642695c7da375c103b67b348d670494b99784e7 Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Wed, 9 May 2018 18:33:52 -0700 Subject: [PATCH 2/6] Update docs --- doc/help/commands.asciidoc | 21 ++++++++++++--------- doc/help/settings.asciidoc | 1 + 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index e8dbf91c4..65bdd13c0 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -111,6 +111,7 @@ It is possible to run or bind multiple commands by separating them with `;;`. |<>|Select the tab given as argument/[count]. |<>|Give the current tab to a new or existing window if win_id given. |<>|Move the current tab according to the argument and [count]. +|<>|Mute/Unmute the current/[count]th tab. |<>|Switch to the next tab, or switch [count] tabs forward. |<>|Close all tabs except for the current one. |<>|Pin/Unpin the current/[count]th tab. @@ -277,8 +278,7 @@ Set all settings back to their default. [[config-cycle]] === config-cycle -Syntax: +:config-cycle [*--pattern* 'pattern'] [*--temp*] [*--print*] - 'option' ['values' ['values' ...]]+ +Syntax: +:config-cycle [*--pattern* 'pattern'] [*--temp*] [*--print*] 'option' ['values' ['values' ...]]+ Cycle an option between multiple values. @@ -530,8 +530,7 @@ Show help about a command or setting. [[hint]] === hint -Syntax: +:hint [*--mode* 'mode'] [*--add-history*] [*--rapid*] [*--first*] - ['group'] ['target'] ['args' ['args' ...]]+ +Syntax: +:hint [*--mode* 'mode'] [*--add-history*] [*--rapid*] [*--first*] ['group'] ['target'] ['args' ['args' ...]]+ Start hinting. @@ -782,8 +781,7 @@ Do nothing. [[open]] === open -Syntax: +:open [*--related*] [*--bg*] [*--tab*] [*--window*] [*--secure*] [*--private*] - ['url']+ +Syntax: +:open [*--related*] [*--bg*] [*--tab*] [*--window*] [*--secure*] [*--private*] ['url']+ Open a URL in the current/[count]th tab. @@ -1112,9 +1110,7 @@ Load a session. [[session-save]] === session-save -Syntax: +:session-save [*--current*] [*--quiet*] [*--force*] [*--only-active-window*] - [*--with-private*] - ['name']+ +Syntax: +:session-save [*--current*] [*--quiet*] [*--force*] [*--only-active-window*] [*--with-private*] ['name']+ Save a session. @@ -1284,6 +1280,13 @@ If moving relatively: Offset. If moving absolutely: New position (default: 0). T overrides the index argument, if given. +[[tab-mute]] +=== tab-mute +Mute/Unmute the current/[count]th tab. + +==== count +The tab index to pin or unpin + [[tab-next]] === tab-next Switch to the next tab, or switch [count] tabs forward. diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index a7ebede3d..95dd46cc1 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -3045,6 +3045,7 @@ The following placeholders are defined: * `{private}`: Indicates when private mode is enabled. * `{current_url}`: URL of the current web page. * `{protocol}`: Protocol (http/https/...) of the current web page. +* `{muted}`: Icon if the tab is muted Type: <> From ae04da7b78848370325737c008229ff6c76dc561 Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Wed, 9 May 2018 18:57:53 -0700 Subject: [PATCH 3/6] Upgrade indicator to show recentlyAudible status --- qutebrowser/browser/browsertab.py | 5 +++++ qutebrowser/browser/webengine/webenginetab.py | 5 +++++ qutebrowser/browser/webkit/webkittab.py | 4 ++++ qutebrowser/config/configdata.yml | 11 ++++++----- qutebrowser/mainwindow/tabbedbrowser.py | 12 +++++++----- qutebrowser/mainwindow/tabwidget.py | 3 ++- 6 files changed, 29 insertions(+), 11 deletions(-) diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py index 17376dc7f..ee5717550 100644 --- a/qutebrowser/browser/browsertab.py +++ b/qutebrowser/browser/browsertab.py @@ -650,6 +650,7 @@ class AbstractTab(QWidget): renderer_process_terminated = pyqtSignal(TerminationStatus, int) predicted_navigation = pyqtSignal(QUrl) audio_muted_changed = pyqtSignal(bool) + recently_audible_changed = pyqtSignal(bool) def __init__(self, *, win_id, mode_manager, private, parent=None): self.private = private @@ -932,3 +933,7 @@ class AbstractTab(QWidget): def is_muted(self): """Whether this tab is muted.""" raise NotImplementedError + + def is_recently_audible(self): + """Whether this tab has had audio playing recently.""" + raise NotImplementedError diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index a0339180b..0fccd6b73 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -1093,6 +1093,7 @@ class WebEngineTab(browsertab.AbstractTab): page.contentsSizeChanged.connect(self.contents_size_changed) page.navigation_request.connect(self._on_navigation_request) page.audioMutedChanged.connect(self.audio_muted_changed) + page.recentlyAudibleChanged.connect(self.recently_audible_changed) view.titleChanged.connect(self.title_changed) view.urlChanged.connect(self._on_url_changed) @@ -1125,3 +1126,7 @@ class WebEngineTab(browsertab.AbstractTab): def is_muted(self): page = self._widget.page() return page.isAudioMuted() + + def is_recently_audible(self): + page = self._widget.page() + return page.recentlyAudible() diff --git a/qutebrowser/browser/webkit/webkittab.py b/qutebrowser/browser/webkit/webkittab.py index ae3a09463..d243c7e18 100644 --- a/qutebrowser/browser/webkit/webkittab.py +++ b/qutebrowser/browser/webkit/webkittab.py @@ -835,3 +835,7 @@ class WebKitTab(browsertab.AbstractTab): def is_muted(self): # Dummy value for things that read muted status return False + + def is_recently_audible(self): + # Dummy value for things that read audible status + return False diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index cdbaa328b..cfeeee07e 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -1344,7 +1344,7 @@ tabs.title.alignment: desc: Alignment of the text inside of tabs. tabs.title.format: - default: '{index}: {title}' + default: '{audio}{index}: {title}' type: name: FormatString fields: @@ -1359,7 +1359,7 @@ tabs.title.format: - private - current_url - protocol - - muted + - audio none_ok: true desc: | Format to use for the tab title. @@ -1377,7 +1377,7 @@ tabs.title.format: * `{private}`: Indicates when private mode is enabled. * `{current_url}`: URL of the current web page. * `{protocol}`: Protocol (http/https/...) of the current web page. - * `{muted}`: Icon if the tab is muted + * `{audio}`: Cookie for audio/mute status tabs.title.format_pinned: default: '{index}' @@ -1395,7 +1395,7 @@ tabs.title.format_pinned: - private - current_url - protocol - - muted + - audio none_ok: true desc: Format to use for the tab title for pinned tabs. The same placeholders like for `tabs.title.format` are defined. @@ -1563,7 +1563,7 @@ window.title_format: - private - current_url - protocol - - muted + - audio default: '{perc}{title}{title_sep}qutebrowser' desc: | Format to use for the window title. The same placeholders like for @@ -2366,6 +2366,7 @@ bindings.default: : follow-selected -t .: repeat-command : tab-pin + : tab-mute q: record-macro "@": run-macro tsh: config-cycle -p -t -u *://{url:host}/* content.javascript.enabled ;; reload diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index cc290ba1e..c2ca7acd4 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -239,7 +239,9 @@ class TabbedBrowser(QWidget): tab.renderer_process_terminated.connect( functools.partial(self._on_renderer_process_terminated, tab)) tab.audio_muted_changed.connect( - functools.partial(self.on_mute_changed, tab)) + functools.partial(self.on_audio_changed, tab)) + tab.recently_audible_changed.connect( + functools.partial(self.on_audio_changed, tab)) tab.new_tab_requested.connect(self.tabopen) if not self.private: web_history = objreg.get('web-history') @@ -736,16 +738,16 @@ class TabbedBrowser(QWidget): self.widget.update_tab_title(idx, 'scroll_pos') @pyqtSlot() - def on_mute_changed(self, tab, muted): - """Update tab and window title when scroll position changed.""" + def on_audio_changed(self, tab, muted): + """Update audio cookie in tab when mute or recentlyAudible changed.""" try: idx = self._tab_index(tab) except TabDeletedError: # We can get signals for tabs we already deleted... return - self.widget.update_tab_title(idx, 'muted') + self.widget.update_tab_title(idx, 'audio') if idx == self.widget.currentIndex(): - self._update_window_title('muted') + self._update_window_title('audio') def _on_renderer_process_terminated(self, tab, status, code): """Show an error when a renderer process terminated.""" diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index ace938592..c9f65c5a6 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -172,7 +172,8 @@ class TabWidget(QTabWidget): fields['perc_raw'] = tab.progress() fields['backend'] = objects.backend.name fields['private'] = ' [Private Mode] ' if tab.private else '' - fields['muted'] = '[M] ' if tab.is_muted() else '' + fields['audio'] = '[M] ' if tab.is_muted() else ( + '[A] ' if tab.is_recently_audible() else '') if tab.load_status() == usertypes.LoadStatus.loading: fields['perc'] = '[{}%] '.format(tab.progress()) From 4bb048cb6a845ce8c396171db0098942f4e2fa23 Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Wed, 9 May 2018 21:41:59 -0700 Subject: [PATCH 4/6] Fix mocked tests --- qutebrowser/mainwindow/tabwidget.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index c9f65c5a6..7135d587c 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -33,6 +33,7 @@ from PyQt5.QtGui import QIcon, QPalette, QColor from qutebrowser.utils import qtutils, objreg, utils, usertypes, log from qutebrowser.config import config from qutebrowser.misc import objects +from qutebrowser.browser import browsertab PixelMetrics = enum.IntEnum('PixelMetrics', ['icon_padding'], @@ -172,8 +173,12 @@ class TabWidget(QTabWidget): fields['perc_raw'] = tab.progress() fields['backend'] = objects.backend.name fields['private'] = ' [Private Mode] ' if tab.private else '' - fields['audio'] = '[M] ' if tab.is_muted() else ( - '[A] ' if tab.is_recently_audible() else '') + try: + fields['audio'] = '[M] ' if tab.is_muted() else ( + '[A] ' if tab.is_recently_audible() else '') + except (NotImplementedError, browsertab.WebTabError): + # one of the functions was not implemented or had an error, abort + fields['audio'] = '' if tab.load_status() == usertypes.LoadStatus.loading: fields['perc'] = '[{}%] '.format(tab.progress()) From 563afb277de0246ca3a2c4b66ea10fb5e495547f Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Thu, 10 May 2018 08:04:48 -0700 Subject: [PATCH 5/6] Fix style issues --- qutebrowser/mainwindow/tabbedbrowser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index c2ca7acd4..9cb160959 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -738,8 +738,8 @@ class TabbedBrowser(QWidget): self.widget.update_tab_title(idx, 'scroll_pos') @pyqtSlot() - def on_audio_changed(self, tab, muted): - """Update audio cookie in tab when mute or recentlyAudible changed.""" + def on_audio_changed(self, tab, _muted): + """Update audio field in tab when mute or recentlyAudible changed.""" try: idx = self._tab_index(tab) except TabDeletedError: From 11d8df0e3ed5817b6ee6768f8cb9ddf95e73bdc5 Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Sat, 9 Jun 2018 16:45:42 -0700 Subject: [PATCH 6/6] Simplify logic and resolve style issues --- doc/help/commands.asciidoc | 13 +++++++++---- qutebrowser/browser/commands.py | 2 +- qutebrowser/config/configdata.yml | 2 +- qutebrowser/mainwindow/tabbedbrowser.py | 7 +++---- qutebrowser/mainwindow/tabwidget.py | 12 ++++++++---- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index 65bdd13c0..7f59c6c2e 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -278,7 +278,8 @@ Set all settings back to their default. [[config-cycle]] === config-cycle -Syntax: +:config-cycle [*--pattern* 'pattern'] [*--temp*] [*--print*] 'option' ['values' ['values' ...]]+ +Syntax: +:config-cycle [*--pattern* 'pattern'] [*--temp*] [*--print*] + 'option' ['values' ['values' ...]]+ Cycle an option between multiple values. @@ -530,7 +531,8 @@ Show help about a command or setting. [[hint]] === hint -Syntax: +:hint [*--mode* 'mode'] [*--add-history*] [*--rapid*] [*--first*] ['group'] ['target'] ['args' ['args' ...]]+ +Syntax: +:hint [*--mode* 'mode'] [*--add-history*] [*--rapid*] [*--first*] + ['group'] ['target'] ['args' ['args' ...]]+ Start hinting. @@ -781,7 +783,8 @@ Do nothing. [[open]] === open -Syntax: +:open [*--related*] [*--bg*] [*--tab*] [*--window*] [*--secure*] [*--private*] ['url']+ +Syntax: +:open [*--related*] [*--bg*] [*--tab*] [*--window*] [*--secure*] [*--private*] + ['url']+ Open a URL in the current/[count]th tab. @@ -1110,7 +1113,9 @@ Load a session. [[session-save]] === session-save -Syntax: +:session-save [*--current*] [*--quiet*] [*--force*] [*--only-active-window*] [*--with-private*] ['name']+ +Syntax: +:session-save [*--current*] [*--quiet*] [*--force*] [*--only-active-window*] + [*--with-private*] + ['name']+ Save a session. diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index e4d75777b..6299581f2 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -2238,7 +2238,7 @@ class CommandDispatcher: """Mute/Unmute the current/[count]th tab. Args: - count: The tab index to pin or unpin, or None + count: The tab index to mute or unmute, or None """ tab = self._cntwidget(count) if tab is None: diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index cfeeee07e..afdfb9453 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -1377,7 +1377,7 @@ tabs.title.format: * `{private}`: Indicates when private mode is enabled. * `{current_url}`: URL of the current web page. * `{protocol}`: Protocol (http/https/...) of the current web page. - * `{audio}`: Cookie for audio/mute status + * `{audio}`: Indicator for audio/mute status tabs.title.format_pinned: default: '{index}' diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index 9cb160959..e5955998f 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -239,9 +239,9 @@ class TabbedBrowser(QWidget): tab.renderer_process_terminated.connect( functools.partial(self._on_renderer_process_terminated, tab)) tab.audio_muted_changed.connect( - functools.partial(self.on_audio_changed, tab)) + functools.partial(self._on_audio_changed, tab)) tab.recently_audible_changed.connect( - functools.partial(self.on_audio_changed, tab)) + functools.partial(self._on_audio_changed, tab)) tab.new_tab_requested.connect(self.tabopen) if not self.private: web_history = objreg.get('web-history') @@ -737,8 +737,7 @@ class TabbedBrowser(QWidget): self._update_window_title('scroll_pos') self.widget.update_tab_title(idx, 'scroll_pos') - @pyqtSlot() - def on_audio_changed(self, tab, _muted): + def _on_audio_changed(self, tab, _muted): """Update audio field in tab when mute or recentlyAudible changed.""" try: idx = self._tab_index(tab) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 7135d587c..8540ef24a 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -174,10 +174,14 @@ class TabWidget(QTabWidget): fields['backend'] = objects.backend.name fields['private'] = ' [Private Mode] ' if tab.private else '' try: - fields['audio'] = '[M] ' if tab.is_muted() else ( - '[A] ' if tab.is_recently_audible() else '') - except (NotImplementedError, browsertab.WebTabError): - # one of the functions was not implemented or had an error, abort + if tab.is_muted(): + fields['audio'] = '[M] ' + elif tab.is_recently_audible(): + fields['audio'] = '[A] ' + else: + fields['audio'] = '' + except browsertab.WebTabError: + # Muting is only implemented with QtWebEngine fields['audio'] = '' if tab.load_status() == usertypes.LoadStatus.loading: