Fix some objreg.get calls.
This commit is contained in:
parent
9533312e0d
commit
36f7ff6154
@ -493,7 +493,9 @@ class HintManager(QObject):
|
||||
for e, string in zip(elems, strings):
|
||||
label = self._draw_label(e, string)
|
||||
self._context.elems[string] = ElemTuple(e, label)
|
||||
keyparser = objreg.get('keyparsers')[usertypes.KeyMode.hint]
|
||||
keyparsers = objreg.get('keyparsers', scope='window',
|
||||
window=self._win_id)
|
||||
keyparser = keyparsers[usertypes.KeyMode.hint]
|
||||
keyparser.update_bindings(strings)
|
||||
|
||||
def follow_prevnext(self, frame, baseurl, prev=False, newtab=False):
|
||||
@ -515,7 +517,9 @@ class HintManager(QObject):
|
||||
"prev" if prev else "forward"))
|
||||
qtutils.ensure_valid(url)
|
||||
if newtab:
|
||||
objreg.get('tabbed-browser').tabopen(url, background=False)
|
||||
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||
window=self._win_id)
|
||||
tabbed_browser.tabopen(url, background=False)
|
||||
else:
|
||||
objreg.get('webview', scope='tab').openurl(url)
|
||||
|
||||
@ -556,7 +560,8 @@ class HintManager(QObject):
|
||||
`{hint-url}` will get replaced by the selected
|
||||
URL.
|
||||
"""
|
||||
tabbed_browser = objreg.get('tabbed-browser')
|
||||
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||
window=self._win_id)
|
||||
widget = tabbed_browser.currentWidget()
|
||||
if widget is None:
|
||||
raise cmdexc.CommandError("No WebView available yet!")
|
||||
@ -570,7 +575,9 @@ class HintManager(QObject):
|
||||
self._context.frames = webelem.get_child_frames(mainframe)
|
||||
self._context.args = args
|
||||
self._init_elements(mainframe, group)
|
||||
objreg.get('message-bridge').set_text(self.HINT_TEXTS[target])
|
||||
message_bridge = objreg.get('message-bridge', scope='window',
|
||||
window=self._win_id)
|
||||
message_bridge.set_text(self.HINT_TEXTS[target])
|
||||
self._connect_frame_signals()
|
||||
try:
|
||||
modeman.enter(self._win_id, usertypes.KeyMode.hint,
|
||||
|
@ -300,11 +300,13 @@ class BrowserPage(QWebPage):
|
||||
urlstr))
|
||||
log.webview.debug(url.errorString())
|
||||
return False
|
||||
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||
window=self._win_id)
|
||||
if self.view().open_target == usertypes.ClickTarget.tab:
|
||||
objreg.get('tabbed-browser').tabopen(url, False)
|
||||
tabbed_browser.tabopen(url, False)
|
||||
return False
|
||||
elif self.view().open_target == usertypes.ClickTarget.tab_bg:
|
||||
objreg.get('tabbed-browser').tabopen(url, True)
|
||||
tabbed_browser.tabopen(url, True)
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
@ -58,7 +58,9 @@ class HelpAction(argparse.Action):
|
||||
"""
|
||||
|
||||
def __call__(self, parser, _namespace, _values, _option_string=None):
|
||||
objreg.get('tabbed-browser').tabopen(
|
||||
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||
window='current')
|
||||
tabbed_browser.tabopen(
|
||||
QUrl('qute://help/commands.html#{}'.format(parser.name)))
|
||||
parser.exit()
|
||||
|
||||
|
@ -27,13 +27,15 @@ from qutebrowser.commands import cmdexc, cmdutils
|
||||
from qutebrowser.utils import message, log, utils, objreg
|
||||
|
||||
|
||||
def replace_variables(arglist):
|
||||
def replace_variables(win_id, arglist):
|
||||
"""Utility function to replace variables like {url} in a list of args."""
|
||||
args = []
|
||||
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||
window=win_id)
|
||||
url = tabbed_browser.current_url().toString(QUrl.FullyEncoded |
|
||||
QUrl.RemovePassword)
|
||||
for arg in arglist:
|
||||
if arg == '{url}':
|
||||
url = objreg.get('tabbed-browser').current_url().toString(
|
||||
QUrl.FullyEncoded | QUrl.RemovePassword)
|
||||
args.append(url)
|
||||
else:
|
||||
args.append(arg)
|
||||
@ -280,7 +282,7 @@ class CommandRunner:
|
||||
self.run(sub, count)
|
||||
return
|
||||
self.parse(text)
|
||||
args = replace_variables(self._args)
|
||||
args = replace_variables(self._win_id, self._args)
|
||||
if count is not None:
|
||||
self._cmd.run(self._win_id, args, count=count)
|
||||
else:
|
||||
|
@ -46,6 +46,7 @@ class CompletionView(QTreeView):
|
||||
|
||||
Attributes:
|
||||
enabled: Whether showing the CompletionView is enabled.
|
||||
_win_id: The ID of the window this CompletionView is associated with.
|
||||
_height: The height to use for the CompletionView.
|
||||
_height_perc: Either None or a percentage if height should be relative.
|
||||
_delegate: The item delegate used.
|
||||
@ -91,6 +92,7 @@ class CompletionView(QTreeView):
|
||||
|
||||
def __init__(self, win_id, parent=None):
|
||||
super().__init__(parent)
|
||||
self._win_id = win_id
|
||||
objreg.register('completion', self, scope='window', window=win_id)
|
||||
completer_obj = completer.Completer(win_id)
|
||||
objreg.register('completer', completer_obj, scope='window',
|
||||
@ -226,7 +228,9 @@ class CompletionView(QTreeView):
|
||||
def selectionChanged(self, selected, deselected):
|
||||
"""Extend selectionChanged to call completers selection_changed."""
|
||||
super().selectionChanged(selected, deselected)
|
||||
objreg.get('completer').selection_changed(selected, deselected)
|
||||
completer = objreg.get('completer', scope='window',
|
||||
window=self._win_id)
|
||||
completer.selection_changed(selected, deselected)
|
||||
|
||||
def resizeEvent(self, e):
|
||||
"""Extend resizeEvent to adjust column size."""
|
||||
|
@ -292,7 +292,8 @@ class Prompter:
|
||||
mode = self._display_question()
|
||||
question.aborted.connect(
|
||||
lambda: modeman.maybe_leave(self._win_id, mode, 'aborted'))
|
||||
mode_manager = objreg.get('mode-manager')
|
||||
mode_manager = objreg.get('mode-manager', scope='window',
|
||||
window=self._win_id)
|
||||
try:
|
||||
modeman.enter(self._win_id, mode, 'question asked')
|
||||
except modeman.ModeLockedError:
|
||||
|
@ -99,7 +99,7 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
title_changed = pyqtSignal(str)
|
||||
|
||||
def __init__(self, win_id, parent=None):
|
||||
super().__init__(parent)
|
||||
super().__init__(win_id, parent)
|
||||
self._win_id = win_id
|
||||
self._tab_insert_idx_left = 0
|
||||
self._tab_insert_idx_right = -1
|
||||
|
@ -42,9 +42,9 @@ class TabWidget(QTabWidget):
|
||||
|
||||
"""The tabwidget used for TabbedBrowser."""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, win_id, parent=None):
|
||||
super().__init__(parent)
|
||||
bar = TabBar()
|
||||
bar = TabBar(win_id)
|
||||
self.setTabBar(bar)
|
||||
bar.tabCloseRequested.connect(self.tabCloseRequested)
|
||||
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
|
||||
@ -90,10 +90,12 @@ class TabBar(QTabBar):
|
||||
|
||||
Attributes:
|
||||
vertical: When the tab bar is currently vertical.
|
||||
win_id: The window ID this TabBar belongs to.
|
||||
"""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, win_id, parent=None):
|
||||
super().__init__(parent)
|
||||
self._win_id = win_id
|
||||
self.setStyle(TabBarStyle(self.style()))
|
||||
self.set_font()
|
||||
config.on_change(self.set_font, 'fonts', 'tabbar')
|
||||
@ -200,8 +202,10 @@ class TabBar(QTabBar):
|
||||
if self.vertical:
|
||||
confwidth = str(config.get('tabs', 'width'))
|
||||
if confwidth.endswith('%'):
|
||||
main_window = objreg.get('main-window', scope='window',
|
||||
window=self._win_id)
|
||||
perc = int(confwidth.rstrip('%'))
|
||||
width = objreg.get('main-window').width() * perc / 100
|
||||
width = main_window.width() * perc / 100
|
||||
else:
|
||||
width = int(confwidth)
|
||||
size = QSize(max(minimum_size.width(), width), height)
|
||||
|
@ -366,7 +366,9 @@ class WebView(QWebView):
|
||||
self._set_load_status(LoadStatus.error)
|
||||
if not config.get('input', 'auto-insert-mode'):
|
||||
return
|
||||
cur_mode = objreg.get('mode-manager').mode()
|
||||
mode_manager = objreg.get('mode-manager', scope='window',
|
||||
window=self._win_id)
|
||||
cur_mode = mode_manager.mode()
|
||||
if cur_mode == usertypes.KeyMode.insert or not ok:
|
||||
return
|
||||
frame = self.page().currentFrame()
|
||||
@ -413,7 +415,9 @@ class WebView(QWebView):
|
||||
if wintype == QWebPage.WebModalDialog:
|
||||
log.webview.warning("WebModalDialog requested, but we don't "
|
||||
"support that!")
|
||||
return objreg.get('tabbed-browser').tabopen()
|
||||
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||
window=self._win_id)
|
||||
return tabbed_browser.tabopen()
|
||||
|
||||
def paintEvent(self, e):
|
||||
"""Extend paintEvent to emit a signal if the scroll position changed.
|
||||
|
Loading…
Reference in New Issue
Block a user