Pass modeman as argument to AbstractTab

This commit is contained in:
Florian Bruhin 2016-07-05 16:47:35 +02:00
parent e0cd878606
commit 7b37d85150
4 changed files with 17 additions and 12 deletions

View File

@ -228,16 +228,14 @@ class AbstractCaret(QObject):
"""Attribute of AbstractTab for caret browsing."""
def __init__(self, win_id, tab, parent=None):
def __init__(self, win_id, tab, modeman, parent=None):
super().__init__(parent)
self._tab = tab
self._win_id = win_id
self._widget = None
self.selection_enabled = False
mode_manager = objreg.get('mode-manager', scope='window',
window=win_id)
mode_manager.entered.connect(self.on_mode_entered)
mode_manager.left.connect(self.on_mode_left)
modeman.entered.connect(self.on_mode_entered)
modeman.left.connect(self.on_mode_left)
def on_mode_entered(self):
raise NotImplementedError
@ -444,7 +442,8 @@ class AbstractTab(QWidget):
super().__init__(parent)
# self.history = AbstractHistory(self)
# self.scroll = AbstractScroller(parent=self)
# self.caret = AbstractCaret(win_id=win_id, tab=self, parent=self)
# self.caret = AbstractCaret(win_id=win_id, tab=self, modeman=...,
# parent=self)
# self.zoom = AbstractZoom(win_id=win_id)
# self.search = AbstractSearch(parent=self)
self.data = TabData()

View File

@ -157,12 +157,13 @@ class WebEngineZoom(tab.AbstractZoom):
class WebEngineViewTab(tab.AbstractTab):
def __init__(self, win_id, parent=None):
def __init__(self, win_id, modeman, parent=None):
super().__init__(win_id)
widget = webview.WebEngineView()
self.history = WebEngineHistory(self)
self.scroll = WebEngineScroller()
self.caret = WebEngineCaret(win_id=win_id, tab=self, parent=self)
self.caret = WebEngineCaret(win_id=win_id, modeman=modeman, tab=self,
parent=self)
self.zoom = WebEngineZoom(win_id=win_id, parent=self)
self.search = WebEngineSearch(parent=self)
self._set_widget(widget)

View File

@ -436,12 +436,13 @@ class WebViewHistory(tab.AbstractHistory):
class WebViewTab(tab.AbstractTab):
def __init__(self, win_id, parent=None):
def __init__(self, win_id, modeman, parent=None):
super().__init__(win_id)
widget = webview.WebView(win_id, self.tab_id, tab=self)
self.history = WebViewHistory(self)
self.scroll = WebViewScroller(parent=self)
self.caret = WebViewCaret(win_id=win_id, tab=self, parent=self)
self.caret = WebViewCaret(win_id=win_id, modeman=modeman, tab=self,
parent=self)
self.zoom = WebViewZoom(win_id=win_id, parent=self)
self.search = WebViewSearch(parent=self)
self._set_widget(widget)

View File

@ -381,10 +381,14 @@ class TabbedBrowser(tabwidget.TabWidget):
window=window.win_id)
return tabbed_browser.tabopen(url, background, explicit)
if objreg.get('args').backend == 'webengine':
tab = webenginetab.WebEngineViewTab(self._win_id, self)
tab_class = webenginetab.WebEngineViewTab
else:
tab = webkittab.WebViewTab(self._win_id, self)
tab_class = webkittab.WebViewTab
tab = tab_class(self._win_id, modeman.instance(self._win_id),
parent=self)
self._connect_tab_signals(tab)
idx = self._get_new_tab_idx(explicit)