Simplify logic and resolve style issues

This commit is contained in:
Jay Kamat 2018-06-09 16:45:42 -07:00
parent 563afb277d
commit 11d8df0e3e
No known key found for this signature in database
GPG Key ID: 5D2E399600F4F7B5
5 changed files with 22 additions and 14 deletions

View File

@ -278,7 +278,8 @@ Set all settings back to their default.
[[config-cycle]] [[config-cycle]]
=== 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. Cycle an option between multiple values.
@ -530,7 +531,8 @@ Show help about a command or setting.
[[hint]] [[hint]]
=== 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. Start hinting.
@ -781,7 +783,8 @@ Do nothing.
[[open]] [[open]]
=== 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. Open a URL in the current/[count]th tab.
@ -1110,7 +1113,9 @@ Load a session.
[[session-save]] [[session-save]]
=== 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. Save a session.

View File

@ -2238,7 +2238,7 @@ class CommandDispatcher:
"""Mute/Unmute the current/[count]th tab. """Mute/Unmute the current/[count]th tab.
Args: 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) tab = self._cntwidget(count)
if tab is None: if tab is None:

View File

@ -1377,7 +1377,7 @@ tabs.title.format:
* `{private}`: Indicates when private mode is enabled. * `{private}`: Indicates when private mode is enabled.
* `{current_url}`: URL of the current web page. * `{current_url}`: URL of the current web page.
* `{protocol}`: Protocol (http/https/...) 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: tabs.title.format_pinned:
default: '{index}' default: '{index}'

View File

@ -239,9 +239,9 @@ class TabbedBrowser(QWidget):
tab.renderer_process_terminated.connect( tab.renderer_process_terminated.connect(
functools.partial(self._on_renderer_process_terminated, tab)) functools.partial(self._on_renderer_process_terminated, tab))
tab.audio_muted_changed.connect( tab.audio_muted_changed.connect(
functools.partial(self.on_audio_changed, tab)) functools.partial(self._on_audio_changed, tab))
tab.recently_audible_changed.connect( 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) tab.new_tab_requested.connect(self.tabopen)
if not self.private: if not self.private:
web_history = objreg.get('web-history') web_history = objreg.get('web-history')
@ -737,8 +737,7 @@ class TabbedBrowser(QWidget):
self._update_window_title('scroll_pos') self._update_window_title('scroll_pos')
self.widget.update_tab_title(idx, '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.""" """Update audio field in tab when mute or recentlyAudible changed."""
try: try:
idx = self._tab_index(tab) idx = self._tab_index(tab)

View File

@ -174,10 +174,14 @@ class TabWidget(QTabWidget):
fields['backend'] = objects.backend.name fields['backend'] = objects.backend.name
fields['private'] = ' [Private Mode] ' if tab.private else '' fields['private'] = ' [Private Mode] ' if tab.private else ''
try: try:
fields['audio'] = '[M] ' if tab.is_muted() else ( if tab.is_muted():
'[A] ' if tab.is_recently_audible() else '') fields['audio'] = '[M] '
except (NotImplementedError, browsertab.WebTabError): elif tab.is_recently_audible():
# one of the functions was not implemented or had an error, abort fields['audio'] = '[A] '
else:
fields['audio'] = ''
except browsertab.WebTabError:
# Muting is only implemented with QtWebEngine
fields['audio'] = '' fields['audio'] = ''
if tab.load_status() == usertypes.LoadStatus.loading: if tab.load_status() == usertypes.LoadStatus.loading: