diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 8b7e6b927..372b0b4e7 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -57,9 +57,6 @@ from qutebrowser.utils.appdirs import AppDirs from qutebrowser.utils.misc import set_trace -components = {} - - class QuteBrowser(QApplication): """Main object for qutebrowser. @@ -133,8 +130,6 @@ class QuteBrowser(QApplication): self.keyparser.keystring_updated.connect( self.mainwindow.status.keystring.setText) - components['app'] = self - self.mainwindow.show() self._python_hacks() timer = QTimer.singleShot(0, self._process_init_args) diff --git a/qutebrowser/commands/utils.py b/qutebrowser/commands/utils.py index afde5bc1e..c6c94fad4 100644 --- a/qutebrowser/commands/utils.py +++ b/qutebrowser/commands/utils.py @@ -26,7 +26,6 @@ from PyQt5.QtWidgets import QApplication from PyQt5.QtWebKitWidgets import QWebPage import qutebrowser.config.config as config -from qutebrowser.app import components as qtb_components from qutebrowser.commands.template import Command from qutebrowser.commands.exceptions import (ArgumentCountError, NoSuchCommandError) @@ -64,7 +63,7 @@ class register: count, nargs = self._get_nargs_count(func) desc = func.__doc__.splitlines()[0].strip().rstrip('.') if self.instance is not None: - handler = functools.partial(func, qtb_components[self.instance]) + handler = functools.partial(func, instance]) else: handler = func cmd = Command(mainname, self.split_args, self.hide, nargs, count, desc, @@ -139,7 +138,6 @@ class SearchParser(QObject): self._text = None self._flags = 0 super().__init__(parent) - qtb_components['searchparser'] = self def _search(self, text, rev=False): """Search for a text on the current page. diff --git a/qutebrowser/widgets/browser.py b/qutebrowser/widgets/browser.py index af14d2bae..fa14d9faf 100644 --- a/qutebrowser/widgets/browser.py +++ b/qutebrowser/widgets/browser.py @@ -37,7 +37,6 @@ from PyQt5.QtWebKitWidgets import QWebView, QWebPage import qutebrowser.utils.url as urlutils import qutebrowser.config.config as config import qutebrowser.commands.utils as cmdutils -from qutebrowser.app import components as qtb_components from qutebrowser.widgets.tabbar import TabWidget from qutebrowser.network.networkmanager import NetworkManager from qutebrowser.utils.signals import SignalCache, dbg_signal @@ -115,7 +114,6 @@ class TabbedBrowser(TabWidget): self._space.activated.connect(lambda: self.cur.scroll_page(0, 1)) self.cur = CurCommandDispatcher(self) self.cur.temp_message.connect(self.cur_temp_message) - qtb_components['browser'] = self def _cb_tab_shutdown(self, tab): """Called after a tab has been shut down completely. @@ -249,7 +247,7 @@ class TabbedBrowser(TabWidget): tab.shutdown(callback=functools.partial(self._cb_tab_shutdown, tab)) - @cmdutils.register(instance='browser') + @cmdutils.register(instance='mainwindow.tabs') def tabclose(self, count=None): """Close the current/[count]th tab. @@ -279,7 +277,7 @@ class TabbedBrowser(TabWidget): elif last_close == 'blank': tab.openurl('about:blank') - @cmdutils.register(instance='browser', split_args=False) + @cmdutils.register(instance='mainwindow.tabs', split_args=False) def tabopen(self, url): """Open a new tab with a given url. @@ -313,7 +311,7 @@ class TabbedBrowser(TabWidget): tab.open_tab.connect(self.tabopen) tab.openurl(url) - @cmdutils.register(instance='browser', hide=True) + @cmdutils.register(instance='mainwindow.tabs', hide=True) def tabopencur(self): """Set the statusbar to :tabopen and the current URL. @@ -324,7 +322,7 @@ class TabbedBrowser(TabWidget): url = urlutils.urlstring(self.currentWidget().url()) self.set_cmd_text.emit(':tabopen ' + url) - @cmdutils.register(instance='browser', hide=True) + @cmdutils.register(instance='mainwindow.tabs', hide=True) def opencur(self): """Set the statusbar to :open and the current URL. @@ -335,7 +333,7 @@ class TabbedBrowser(TabWidget): url = urlutils.urlstring(self.currentWidget().url()) self.set_cmd_text.emit(':open ' + url) - @cmdutils.register(instance='browser', name='undo') + @cmdutils.register(instance='mainwindow.tabs', name='undo') def undo_close(self): """Switch to the previous tab, or skip [count] tabs. @@ -345,7 +343,7 @@ class TabbedBrowser(TabWidget): if self._url_stack: self.tabopen(self._url_stack.pop()) - @cmdutils.register(instance='browser', name='tabprev') + @cmdutils.register(instance='mainwindow.tabs', name='tabprev') def switch_prev(self, count=1): """Switch to the ([count]th) previous tab. @@ -362,7 +360,7 @@ class TabbedBrowser(TabWidget): # FIXME pass - @cmdutils.register(instance='browser', name='tabnext') + @cmdutils.register(instance='mainwindow.tabs', name='tabnext') def switch_next(self, count=1): """Switch to the next tab, or skip [count] tabs. @@ -379,7 +377,7 @@ class TabbedBrowser(TabWidget): # FIXME pass - @cmdutils.register(instance='browser') + @cmdutils.register(instance='mainwindow.tabs') def paste(self, sel=False): """Open a page from the clipboard. @@ -396,7 +394,7 @@ class TabbedBrowser(TabWidget): logging.debug("Clipboard contained: '{}'".format(url)) self.openurl(url) - @cmdutils.register(instance='browser') + @cmdutils.register(instance='mainwindow.tabs') def tabpaste(self, sel=False): """Open a page from the clipboard in a new tab. @@ -491,7 +489,8 @@ class CurCommandDispatcher(QObject): return frame.setScrollBarValue(orientation, int(m * perc / 100)) - @cmdutils.register(instance='browser', name='open', split_args=False) + @cmdutils.register(instance='mainwindow.tabs.cur', name='open', + split_args=False) def openurl(self, url, count=None): """Open an url in the current/[count]th tab. @@ -514,7 +513,7 @@ class CurCommandDispatcher(QObject): else: tab.openurl(url) - @cmdutils.register(instance='browser', name='reload') + @cmdutils.register(instance='mainwindow.tabs.cur', name='reload') def reloadpage(self, count=None): """Reload the current/[count]th tab. @@ -528,7 +527,7 @@ class CurCommandDispatcher(QObject): if tab is not None: tab.reload() - @cmdutils.register(instance='browser') + @cmdutils.register(instance='mainwindow.tabs.cur') def stop(self, count=None): """Stop loading in the current/[count]th tab. @@ -542,7 +541,7 @@ class CurCommandDispatcher(QObject): if tab is not None: tab.stop() - @cmdutils.register(instance='browser', name='print') + @cmdutils.register(instance='mainwindow.tabs.cur', name='print') def printpage(self, count=None): """Print the current/[count]th tab. @@ -559,7 +558,7 @@ class CurCommandDispatcher(QObject): preview.paintRequested.connect(tab.print) preview.exec_() - @cmdutils.register(instance='browser') + @cmdutils.register(instance='mainwindow.tabs.cur') def back(self, count=1): """Go back in the history of the current tab. @@ -573,7 +572,7 @@ class CurCommandDispatcher(QObject): for i in range(count): # pylint: disable=unused-variable self.tabs.currentWidget().back() - @cmdutils.register(instance='browser') + @cmdutils.register(instance='mainwindow.tabs.cur') def forward(self, count=1): """Go forward in the history of the current tab. @@ -598,7 +597,7 @@ class CurCommandDispatcher(QObject): """ self.tabs.currentWidget().findText(text, flags) - @cmdutils.register(instance='browser', hide=True) + @cmdutils.register(instance='mainwindow.tabs.cur', hide=True) def scroll(self, dx, dy, count=1): """Scroll the current tab by count * dx/dy. @@ -614,7 +613,8 @@ class CurCommandDispatcher(QObject): dy = int(count) * float(dy) self.tabs.currentWidget().page_.mainFrame().scroll(dx, dy) - @cmdutils.register(instance='browser', name='scroll_perc_x', hide=True) + @cmdutils.register(instance='mainwindow.tabs.cur', name='scroll_perc_x', + hide=True) def scroll_percent_x(self, perc=None, count=None): """Scroll the current tab to a specific percent of the page (horiz). @@ -627,7 +627,8 @@ class CurCommandDispatcher(QObject): """ self._scroll_percent(perc, count, Qt.Horizontal) - @cmdutils.register(instance='browser', name='scroll_perc_y', hide=True) + @cmdutils.register(instance='mainwindow.tabs.cur', name='scroll_perc_y', + hide=True) def scroll_percent_y(self, perc=None, count=None): """Scroll the current tab to a specific percent of the page (vert). @@ -640,7 +641,7 @@ class CurCommandDispatcher(QObject): """ self._scroll_percent(perc, count, Qt.Vertical) - @cmdutils.register(instance='browser', hide=True) + @cmdutils.register(instance='mainwindow.tabs.cur', hide=True) def scroll_page(self, mx, my, count=1): """Scroll the frame page-wise. @@ -656,7 +657,7 @@ class CurCommandDispatcher(QObject): page.mainFrame().scroll(int(count) * float(mx) * size.width(), int(count) * float(my) * size.height()) - @cmdutils.register(instance='browser') + @cmdutils.register(instance='mainwindow.tabs.cur') def yank(self, sel=False): """Yank the current url to the clipboard or primary selection. @@ -676,7 +677,7 @@ class CurCommandDispatcher(QObject): self.temp_message.emit('URL yanked to {}'.format( 'primary selection' if sel else 'clipboard')) - @cmdutils.register(instance='browser', name='yanktitle') + @cmdutils.register(instance='mainwindow.tabs.cur', name='yanktitle') def yank_title(self, sel=False): """Yank the current title to the clipboard or primary selection. @@ -696,7 +697,7 @@ class CurCommandDispatcher(QObject): self.temp_message.emit('Title yanked to {}'.format( 'primary selection' if sel else 'clipboard')) - @cmdutils.register(instance='browser', name='zoomin') + @cmdutils.register(instance='mainwindow.tabs.cur', name='zoomin') def zoom_in(self, count=1): """Zoom in in the current tab. @@ -707,7 +708,7 @@ class CurCommandDispatcher(QObject): tab = self.tabs.currentWidget() tab.zoom(count) - @cmdutils.register(instance='browser', name='zoomout') + @cmdutils.register(instance='mainwindow.tabs.cur', name='zoomout') def zoom_out(self, count=1): """Zoom out in the current tab.