Allow tabs be muted by default
This commit is contained in:
parent
25c189d8d4
commit
9d91c22236
@ -666,9 +666,10 @@ class AbstractAudio(QObject):
|
|||||||
muted_changed = pyqtSignal(bool)
|
muted_changed = pyqtSignal(bool)
|
||||||
recently_audible_changed = pyqtSignal(bool)
|
recently_audible_changed = pyqtSignal(bool)
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, tab, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self._widget = None
|
self._widget = None
|
||||||
|
self._tab = tab
|
||||||
|
|
||||||
def set_muted(self, muted: bool):
|
def set_muted(self, muted: bool):
|
||||||
"""Set this tab as muted or not."""
|
"""Set this tab as muted or not."""
|
||||||
|
@ -638,6 +638,7 @@ class WebEngineAudio(browsertab.AbstractAudio):
|
|||||||
page = self._widget.page()
|
page = self._widget.page()
|
||||||
page.audioMutedChanged.connect(self.muted_changed)
|
page.audioMutedChanged.connect(self.muted_changed)
|
||||||
page.recentlyAudibleChanged.connect(self.recently_audible_changed)
|
page.recentlyAudibleChanged.connect(self.recently_audible_changed)
|
||||||
|
self._tab.url_changed.connect(self._on_url_changed)
|
||||||
|
|
||||||
def set_muted(self, muted: bool):
|
def set_muted(self, muted: bool):
|
||||||
page = self._widget.page()
|
page = self._widget.page()
|
||||||
@ -651,6 +652,11 @@ class WebEngineAudio(browsertab.AbstractAudio):
|
|||||||
page = self._widget.page()
|
page = self._widget.page()
|
||||||
return page.recentlyAudible()
|
return page.recentlyAudible()
|
||||||
|
|
||||||
|
def _on_url_changed(self):
|
||||||
|
urlstr = self._tab.url().toString(QUrl.RemoveUserInfo)
|
||||||
|
muted_url = config.instance.get('content.mute', url=urlstr)
|
||||||
|
self.set_muted(muted_url is not None)
|
||||||
|
|
||||||
|
|
||||||
class _WebEnginePermissions(QObject):
|
class _WebEnginePermissions(QObject):
|
||||||
|
|
||||||
@ -995,7 +1001,7 @@ class WebEngineTab(browsertab.AbstractTab):
|
|||||||
self.printing = WebEnginePrinting(tab=self)
|
self.printing = WebEnginePrinting(tab=self)
|
||||||
self.elements = WebEngineElements(tab=self)
|
self.elements = WebEngineElements(tab=self)
|
||||||
self.action = WebEngineAction(tab=self)
|
self.action = WebEngineAction(tab=self)
|
||||||
self.audio = WebEngineAudio(parent=self)
|
self.audio = WebEngineAudio(tab=self, parent=self)
|
||||||
self._permissions = _WebEnginePermissions(tab=self, parent=self)
|
self._permissions = _WebEnginePermissions(tab=self, parent=self)
|
||||||
self._scripts = _WebEngineScripts(tab=self, parent=self)
|
self._scripts = _WebEngineScripts(tab=self, parent=self)
|
||||||
# We're assigning settings in _set_widget
|
# We're assigning settings in _set_widget
|
||||||
|
@ -661,7 +661,7 @@ class WebKitTab(browsertab.AbstractTab):
|
|||||||
self.printing = WebKitPrinting(tab=self)
|
self.printing = WebKitPrinting(tab=self)
|
||||||
self.elements = WebKitElements(tab=self)
|
self.elements = WebKitElements(tab=self)
|
||||||
self.action = WebKitAction(tab=self)
|
self.action = WebKitAction(tab=self)
|
||||||
self.audio = WebKitAudio(parent=self)
|
self.audio = WebKitAudio(tab=self, parent=self)
|
||||||
# We're assigning settings in _set_widget
|
# We're assigning settings in _set_widget
|
||||||
self.settings = webkitsettings.WebKitSettings(settings=None)
|
self.settings = webkitsettings.WebKitSettings(settings=None)
|
||||||
self._set_widget(widget)
|
self._set_widget(widget)
|
||||||
|
@ -746,6 +746,14 @@ content.xss_auditing:
|
|||||||
Suspicious scripts will be blocked and reported in the inspector's
|
Suspicious scripts will be blocked and reported in the inspector's
|
||||||
JavaScript console.
|
JavaScript console.
|
||||||
|
|
||||||
|
content.mute:
|
||||||
|
default: null
|
||||||
|
type:
|
||||||
|
name: String
|
||||||
|
none_ok: true
|
||||||
|
supports_pattern: true
|
||||||
|
desc: List of URLs muted by default.
|
||||||
|
|
||||||
# emacs: '
|
# emacs: '
|
||||||
|
|
||||||
## completion
|
## completion
|
||||||
|
Loading…
Reference in New Issue
Block a user