Clean up mainwindow import mess.
This commit is contained in:
parent
bb530ed9e1
commit
fd9a3fc5e7
@ -153,7 +153,7 @@ class Application(QApplication):
|
||||
download_manager = downloads.DownloadManager(self)
|
||||
objreg.register('download-manager', download_manager)
|
||||
log.init.debug("Initializing main window...")
|
||||
mainwindow.create_window(False if self._args.nowindow else True)
|
||||
mainwindow.MainWindow.spawn(False if self._args.nowindow else True)
|
||||
log.init.debug("Initializing debug console...")
|
||||
debug_console = console.ConsoleWidget()
|
||||
objreg.register('debug-console', debug_console)
|
||||
@ -227,7 +227,7 @@ class Application(QApplication):
|
||||
commandrunner.run_safely_init(cmd.lstrip(':'))
|
||||
elif not cmd:
|
||||
log.init.debug("Empty argument")
|
||||
win_id = mainwindow.create_window(True)
|
||||
win_id = mainwindow.MainWindow.spawn()
|
||||
else:
|
||||
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||
window=win_id)
|
||||
|
@ -70,9 +70,9 @@ class CommandDispatcher:
|
||||
window: If True, open a new window.
|
||||
"""
|
||||
if window:
|
||||
# We have to import this here to avoid a circular import.
|
||||
from qutebrowser.widgets import mainwindow
|
||||
win_id = mainwindow.create_window(True)
|
||||
main_window = objreg.get('main-window', scope='window',
|
||||
window=self._win_id)
|
||||
win_id = main_window.spawn()
|
||||
else:
|
||||
win_id = self._win_id
|
||||
return objreg.get('tabbed-browser', scope='window', window=win_id)
|
||||
|
@ -527,9 +527,9 @@ class HintManager(QObject):
|
||||
"prev" if prev else "forward"))
|
||||
qtutils.ensure_valid(url)
|
||||
if window:
|
||||
# We have to import this here to avoid a circular import.
|
||||
from qutebrowser.widgets import mainwindow
|
||||
win_id = mainwindow.create_window(True)
|
||||
main_window = objreg.get('main-window', scope='window',
|
||||
window=self._win_id)
|
||||
win_id = main_window.spawn()
|
||||
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||
window=win_id)
|
||||
tabbed_browser.tabopen(url, background=False)
|
||||
|
@ -310,9 +310,9 @@ class BrowserPage(QWebPage):
|
||||
tabbed_browser.tabopen(url, True)
|
||||
return False
|
||||
elif open_target == usertypes.ClickTarget.window:
|
||||
# We have to import this here to avoid a circular import.
|
||||
from qutebrowser.widgets import mainwindow
|
||||
win_id = mainwindow.create_window(True)
|
||||
main_window = objreg.get('main-window', scope='window',
|
||||
window=self._win_id)
|
||||
win_id = main_window.spawn()
|
||||
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||
window=win_id)
|
||||
tabbed_browser.tabopen(url, False)
|
||||
|
@ -39,22 +39,6 @@ from qutebrowser.browser import hints
|
||||
win_id_gen = itertools.count(0)
|
||||
|
||||
|
||||
def create_window(show):
|
||||
"""Create a new main window.
|
||||
|
||||
Args:
|
||||
show: Show the window after creating.
|
||||
|
||||
Return:
|
||||
The new window id.
|
||||
"""
|
||||
win_id = next(win_id_gen)
|
||||
win = MainWindow(win_id)
|
||||
if show:
|
||||
win.show()
|
||||
return win_id
|
||||
|
||||
|
||||
class MainWindow(QWidget):
|
||||
|
||||
"""The main window of qutebrowser.
|
||||
@ -145,6 +129,22 @@ class MainWindow(QWidget):
|
||||
def __repr__(self):
|
||||
return utils.get_repr(self)
|
||||
|
||||
@classmethod
|
||||
def spawn(cls, show=True):
|
||||
"""Create a new main window.
|
||||
|
||||
Args:
|
||||
show: Show the window after creating.
|
||||
|
||||
Return:
|
||||
The new window id.
|
||||
"""
|
||||
win_id = next(win_id_gen)
|
||||
win = MainWindow(win_id)
|
||||
if show:
|
||||
win.show()
|
||||
return win_id
|
||||
|
||||
def _load_geometry(self):
|
||||
"""Load the geometry from the state file."""
|
||||
state_config = objreg.get('state-config')
|
||||
|
Loading…
Reference in New Issue
Block a user