Simplify showing of main windows.

This commit is contained in:
Florian Bruhin 2014-09-28 22:46:37 +02:00
parent 2dea47b162
commit 16c067e32d
3 changed files with 9 additions and 8 deletions

View File

@ -114,10 +114,6 @@ class Application(QApplication):
log.init.debug("Connecting signals...")
self._connect_signals()
log.init.debug("Showing mainwindow...")
if not args.nowindow:
objreg.get('main-window', scope='window', window=0).show()
log.init.debug("Applying python hacks...")
self._python_hacks()
@ -155,7 +151,7 @@ class Application(QApplication):
download_manager = downloads.DownloadManager(self)
objreg.register('download-manager', download_manager)
log.init.debug("Initializing main window...")
mainwindow.create_window()
mainwindow.create_window(False if self._args.nowindow else True)
log.init.debug("Initializing debug console...")
debug_console = console.ConsoleWidget()
objreg.register('debug-console', debug_console)

View File

@ -108,7 +108,7 @@ class CommandDispatcher:
elif window:
# We have to import this here to avoid a circular import.
from qutebrowser.widgets import mainwindow
win_id = mainwindow.create_window()
win_id = mainwindow.create_window(True)
tabbed_browser = objreg.get('tabbed-browser', scope='window',
window=win_id)
tabbed_browser.tabopen(url)

View File

@ -39,14 +39,19 @@ from qutebrowser.browser import hints
win_id_gen = itertools.count(0)
def create_window():
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)
MainWindow(win_id)
win = MainWindow(win_id)
if show:
win.show()
return win_id