Simplify initializing of AbstractTab subclasses
If we already pass the tab object, no need to pass the window ID separately.
This commit is contained in:
parent
4b9bba7505
commit
24cc54a574
@ -119,10 +119,9 @@ class AbstractAction:
|
|||||||
action_class = None
|
action_class = None
|
||||||
action_base = None
|
action_base = None
|
||||||
|
|
||||||
def __init__(self, tab, win_id):
|
def __init__(self, tab):
|
||||||
self._widget = None
|
self._widget = None
|
||||||
self._tab = tab
|
self._tab = tab
|
||||||
self._win_id = win_id
|
|
||||||
|
|
||||||
def exit_fullscreen(self):
|
def exit_fullscreen(self):
|
||||||
"""Exit the fullscreen mode."""
|
"""Exit the fullscreen mode."""
|
||||||
@ -249,10 +248,10 @@ class AbstractZoom(QObject):
|
|||||||
_default_zoom_changed: Whether the zoom was changed from the default.
|
_default_zoom_changed: Whether the zoom was changed from the default.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, win_id, parent=None):
|
def __init__(self, tab, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
self._tab = tab
|
||||||
self._widget = None
|
self._widget = None
|
||||||
self._win_id = win_id
|
|
||||||
self._default_zoom_changed = False
|
self._default_zoom_changed = False
|
||||||
self._init_neighborlist()
|
self._init_neighborlist()
|
||||||
config.instance.changed.connect(self._on_config_changed)
|
config.instance.changed.connect(self._on_config_changed)
|
||||||
@ -328,10 +327,9 @@ class AbstractCaret(QObject):
|
|||||||
|
|
||||||
"""Attribute of AbstractTab for caret browsing."""
|
"""Attribute of AbstractTab for caret browsing."""
|
||||||
|
|
||||||
def __init__(self, win_id, tab, mode_manager, parent=None):
|
def __init__(self, tab, mode_manager, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self._tab = tab
|
self._tab = tab
|
||||||
self._win_id = win_id
|
|
||||||
self._widget = None
|
self._widget = None
|
||||||
self.selection_enabled = False
|
self.selection_enabled = False
|
||||||
mode_manager.entered.connect(self._on_mode_entered)
|
mode_manager.entered.connect(self._on_mode_entered)
|
||||||
@ -643,16 +641,6 @@ class AbstractTab(QWidget):
|
|||||||
tab_registry[self.tab_id] = self
|
tab_registry[self.tab_id] = self
|
||||||
objreg.register('tab', self, registry=self.registry)
|
objreg.register('tab', self, registry=self.registry)
|
||||||
|
|
||||||
# self.history = AbstractHistory(self)
|
|
||||||
# self.scroller = AbstractScroller(self, parent=self)
|
|
||||||
# self.caret = AbstractCaret(win_id=win_id, tab=self,
|
|
||||||
# mode_manager=mode_manager, parent=self)
|
|
||||||
# self.zoom = AbstractZoom(win_id=win_id)
|
|
||||||
# self.search = AbstractSearch(parent=self)
|
|
||||||
# self.printing = AbstractPrinting()
|
|
||||||
# self.elements = AbstractElements(self)
|
|
||||||
# self.action = AbstractAction()
|
|
||||||
|
|
||||||
self.data = TabData()
|
self.data = TabData()
|
||||||
self._layout = miscwidgets.WrapperLayout(self)
|
self._layout = miscwidgets.WrapperLayout(self)
|
||||||
self._widget = None
|
self._widget = None
|
||||||
|
@ -105,7 +105,7 @@ class WebEngineAction(browsertab.AbstractAction):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
# Qt < 5.8
|
# Qt < 5.8
|
||||||
tb = objreg.get('tabbed-browser', scope='window',
|
tb = objreg.get('tabbed-browser', scope='window',
|
||||||
window=self._win_id)
|
window=self._tab.win_id)
|
||||||
urlstr = self._tab.url().toString(QUrl.RemoveUserInfo)
|
urlstr = self._tab.url().toString(QUrl.RemoveUserInfo)
|
||||||
# The original URL becomes the path of a view-source: URL
|
# The original URL becomes the path of a view-source: URL
|
||||||
# (without a host), but query/fragment should stay.
|
# (without a host), but query/fragment should stay.
|
||||||
@ -603,13 +603,13 @@ class WebEngineTab(browsertab.AbstractTab):
|
|||||||
private=private)
|
private=private)
|
||||||
self.history = WebEngineHistory(self)
|
self.history = WebEngineHistory(self)
|
||||||
self.scroller = WebEngineScroller(self, parent=self)
|
self.scroller = WebEngineScroller(self, parent=self)
|
||||||
self.caret = WebEngineCaret(win_id=win_id, mode_manager=mode_manager,
|
self.caret = WebEngineCaret(mode_manager=mode_manager,
|
||||||
tab=self, parent=self)
|
tab=self, parent=self)
|
||||||
self.zoom = WebEngineZoom(win_id=win_id, parent=self)
|
self.zoom = WebEngineZoom(tab=self, parent=self)
|
||||||
self.search = WebEngineSearch(parent=self)
|
self.search = WebEngineSearch(parent=self)
|
||||||
self.printing = WebEnginePrinting()
|
self.printing = WebEnginePrinting()
|
||||||
self.elements = WebEngineElements(self)
|
self.elements = WebEngineElements(tab=self)
|
||||||
self.action = WebEngineAction(self, win_id)
|
self.action = WebEngineAction(tab=self)
|
||||||
self._set_widget(widget)
|
self._set_widget(widget)
|
||||||
self._connect_signals()
|
self._connect_signals()
|
||||||
self.backend = usertypes.Backend.QtWebEngine
|
self.backend = usertypes.Backend.QtWebEngine
|
||||||
|
@ -67,7 +67,7 @@ class WebKitAction(browsertab.AbstractAction):
|
|||||||
highlighted = pygments.highlight(source, lexer, formatter)
|
highlighted = pygments.highlight(source, lexer, formatter)
|
||||||
|
|
||||||
tb = objreg.get('tabbed-browser', scope='window',
|
tb = objreg.get('tabbed-browser', scope='window',
|
||||||
window=self._win_id)
|
window=self._tab.win_id)
|
||||||
new_tab = tb.tabopen(background=False, related=True)
|
new_tab = tb.tabopen(background=False, related=True)
|
||||||
# The original URL becomes the path of a view-source: URL
|
# The original URL becomes the path of a view-source: URL
|
||||||
# (without a host), but query/fragment should stay.
|
# (without a host), but query/fragment should stay.
|
||||||
@ -354,7 +354,7 @@ class WebKitCaret(browsertab.AbstractCaret):
|
|||||||
def toggle_selection(self):
|
def toggle_selection(self):
|
||||||
self.selection_enabled = not self.selection_enabled
|
self.selection_enabled = not self.selection_enabled
|
||||||
mainwindow = objreg.get('main-window', scope='window',
|
mainwindow = objreg.get('main-window', scope='window',
|
||||||
window=self._win_id)
|
window=self._tab.win_id)
|
||||||
mainwindow.status.set_mode_active(usertypes.KeyMode.caret, True)
|
mainwindow.status.set_mode_active(usertypes.KeyMode.caret, True)
|
||||||
|
|
||||||
def drop_selection(self):
|
def drop_selection(self):
|
||||||
@ -646,13 +646,13 @@ class WebKitTab(browsertab.AbstractTab):
|
|||||||
self._make_private(widget)
|
self._make_private(widget)
|
||||||
self.history = WebKitHistory(self)
|
self.history = WebKitHistory(self)
|
||||||
self.scroller = WebKitScroller(self, parent=self)
|
self.scroller = WebKitScroller(self, parent=self)
|
||||||
self.caret = WebKitCaret(win_id=win_id, mode_manager=mode_manager,
|
self.caret = WebKitCaret(mode_manager=mode_manager,
|
||||||
tab=self, parent=self)
|
tab=self, parent=self)
|
||||||
self.zoom = WebKitZoom(win_id=win_id, parent=self)
|
self.zoom = WebKitZoom(tab=self, parent=self)
|
||||||
self.search = WebKitSearch(parent=self)
|
self.search = WebKitSearch(parent=self)
|
||||||
self.printing = WebKitPrinting()
|
self.printing = WebKitPrinting()
|
||||||
self.elements = WebKitElements(self)
|
self.elements = WebKitElements(tab=self)
|
||||||
self.action = WebKitAction(self, win_id)
|
self.action = WebKitAction(tab=self)
|
||||||
self._set_widget(widget)
|
self._set_widget(widget)
|
||||||
self._connect_signals()
|
self._connect_signals()
|
||||||
self.backend = usertypes.Backend.QtWebKit
|
self.backend = usertypes.Backend.QtWebKit
|
||||||
|
@ -80,10 +80,9 @@ class Tab(browsertab.AbstractTab):
|
|||||||
parent=parent)
|
parent=parent)
|
||||||
self.history = browsertab.AbstractHistory(self)
|
self.history = browsertab.AbstractHistory(self)
|
||||||
self.scroller = browsertab.AbstractScroller(self, parent=self)
|
self.scroller = browsertab.AbstractScroller(self, parent=self)
|
||||||
self.caret = browsertab.AbstractCaret(win_id=self.win_id,
|
self.caret = browsertab.AbstractCaret(mode_manager=mode_manager,
|
||||||
mode_manager=mode_manager,
|
|
||||||
tab=self, parent=self)
|
tab=self, parent=self)
|
||||||
self.zoom = Zoom(win_id=self.win_id)
|
self.zoom = Zoom(tab=self)
|
||||||
self.search = browsertab.AbstractSearch(parent=self)
|
self.search = browsertab.AbstractSearch(parent=self)
|
||||||
self.printing = browsertab.AbstractPrinting()
|
self.printing = browsertab.AbstractPrinting()
|
||||||
self.elements = browsertab.AbstractElements(self)
|
self.elements = browsertab.AbstractElements(self)
|
||||||
|
Loading…
Reference in New Issue
Block a user