s/qApp/q_app/g
This commit is contained in:
parent
62059c27f3
commit
7c87f4e3d0
@ -83,7 +83,7 @@ from qutebrowser.misc import utilcmds
|
|||||||
# pylint: enable=unused-import
|
# pylint: enable=unused-import
|
||||||
|
|
||||||
|
|
||||||
qApp = None
|
q_app = None
|
||||||
|
|
||||||
|
|
||||||
def run(args):
|
def run(args):
|
||||||
@ -101,25 +101,25 @@ def run(args):
|
|||||||
log.init.debug("Initializing config...")
|
log.init.debug("Initializing config...")
|
||||||
configinit.early_init(args)
|
configinit.early_init(args)
|
||||||
|
|
||||||
global qApp
|
global q_app
|
||||||
qApp = Application(args)
|
q_app = Application(args)
|
||||||
qApp.setOrganizationName("qutebrowser")
|
q_app.setOrganizationName("qutebrowser")
|
||||||
qApp.setApplicationName("qutebrowser")
|
q_app.setApplicationName("qutebrowser")
|
||||||
qApp.setDesktopFileName("qutebrowser")
|
q_app.setDesktopFileName("qutebrowser")
|
||||||
qApp.setApplicationVersion(qutebrowser.__version__)
|
q_app.setApplicationVersion(qutebrowser.__version__)
|
||||||
qApp.lastWindowClosed.connect(quitter.on_last_window_closed)
|
q_app.lastWindowClosed.connect(quitter.on_last_window_closed)
|
||||||
|
|
||||||
if args.version:
|
if args.version:
|
||||||
print(version.version())
|
print(version.version())
|
||||||
sys.exit(usertypes.Exit.ok)
|
sys.exit(usertypes.Exit.ok)
|
||||||
|
|
||||||
crash_handler = crashsignal.CrashHandler(
|
crash_handler = crashsignal.CrashHandler(
|
||||||
app=qApp, quitter=quitter, args=args, parent=qApp)
|
app=q_app, quitter=quitter, args=args, parent=q_app)
|
||||||
crash_handler.activate()
|
crash_handler.activate()
|
||||||
objreg.register('crash-handler', crash_handler)
|
objreg.register('crash-handler', crash_handler)
|
||||||
|
|
||||||
signal_handler = crashsignal.SignalHandler(app=qApp, quitter=quitter,
|
signal_handler = crashsignal.SignalHandler(app=q_app, quitter=quitter,
|
||||||
parent=qApp)
|
parent=q_app)
|
||||||
signal_handler.activate()
|
signal_handler.activate()
|
||||||
objreg.register('signal-handler', signal_handler)
|
objreg.register('signal-handler', signal_handler)
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ def qt_mainloop():
|
|||||||
WARNING: misc/crashdialog.py checks the stacktrace for this function
|
WARNING: misc/crashdialog.py checks the stacktrace for this function
|
||||||
name, so if this is changed, it should be changed there as well!
|
name, so if this is changed, it should be changed there as well!
|
||||||
"""
|
"""
|
||||||
return qApp.exec_()
|
return q_app.exec_()
|
||||||
|
|
||||||
|
|
||||||
def init(args, crash_handler):
|
def init(args, crash_handler):
|
||||||
@ -162,7 +162,7 @@ def init(args, crash_handler):
|
|||||||
crash_handler: The CrashHandler instance.
|
crash_handler: The CrashHandler instance.
|
||||||
"""
|
"""
|
||||||
log.init.debug("Starting init...")
|
log.init.debug("Starting init...")
|
||||||
qApp.setQuitOnLastWindowClosed(False)
|
q_app.setQuitOnLastWindowClosed(False)
|
||||||
_init_icon()
|
_init_icon()
|
||||||
|
|
||||||
loader.init()
|
loader.init()
|
||||||
@ -175,12 +175,12 @@ def init(args, crash_handler):
|
|||||||
sys.exit(usertypes.Exit.err_init)
|
sys.exit(usertypes.Exit.err_init)
|
||||||
|
|
||||||
log.init.debug("Initializing eventfilter...")
|
log.init.debug("Initializing eventfilter...")
|
||||||
event_filter = EventFilter(qApp)
|
event_filter = EventFilter(q_app)
|
||||||
qApp.installEventFilter(event_filter)
|
q_app.installEventFilter(event_filter)
|
||||||
objreg.register('event-filter', event_filter)
|
objreg.register('event-filter', event_filter)
|
||||||
|
|
||||||
log.init.debug("Connecting signals...")
|
log.init.debug("Connecting signals...")
|
||||||
qApp.focusChanged.connect(on_focus_changed)
|
q_app.focusChanged.connect(on_focus_changed)
|
||||||
|
|
||||||
_process_args(args)
|
_process_args(args)
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ def _init_icon():
|
|||||||
if icon.isNull():
|
if icon.isNull():
|
||||||
log.init.warning("Failed to load icon")
|
log.init.warning("Failed to load icon")
|
||||||
else:
|
else:
|
||||||
qApp.setWindowIcon(icon)
|
q_app.setWindowIcon(icon)
|
||||||
|
|
||||||
|
|
||||||
def _process_args(args):
|
def _process_args(args):
|
||||||
@ -220,7 +220,7 @@ def _process_args(args):
|
|||||||
window = mainwindow.MainWindow(private=None)
|
window = mainwindow.MainWindow(private=None)
|
||||||
if not args.nowindow:
|
if not args.nowindow:
|
||||||
window.show()
|
window.show()
|
||||||
qApp.setActiveWindow(window)
|
q_app.setActiveWindow(window)
|
||||||
|
|
||||||
process_pos_args(args.command)
|
process_pos_args(args.command)
|
||||||
_open_startpage()
|
_open_startpage()
|
||||||
@ -425,7 +425,7 @@ def _init_modules(args, crash_handler):
|
|||||||
crash_handler: The CrashHandler instance.
|
crash_handler: The CrashHandler instance.
|
||||||
"""
|
"""
|
||||||
log.init.debug("Initializing save manager...")
|
log.init.debug("Initializing save manager...")
|
||||||
save_manager = savemanager.SaveManager(qApp)
|
save_manager = savemanager.SaveManager(q_app)
|
||||||
objreg.register('save-manager', save_manager)
|
objreg.register('save-manager', save_manager)
|
||||||
configinit.late_init(save_manager)
|
configinit.late_init(save_manager)
|
||||||
|
|
||||||
@ -450,7 +450,7 @@ def _init_modules(args, crash_handler):
|
|||||||
sql.init(os.path.join(standarddir.data(), 'history.sqlite'))
|
sql.init(os.path.join(standarddir.data(), 'history.sqlite'))
|
||||||
|
|
||||||
log.init.debug("Initializing web history...")
|
log.init.debug("Initializing web history...")
|
||||||
history.init(qApp)
|
history.init(q_app)
|
||||||
except sql.SqlEnvironmentError as e:
|
except sql.SqlEnvironmentError as e:
|
||||||
error.handle_fatal_exc(e, args, 'Error initializing SQL',
|
error.handle_fatal_exc(e, args, 'Error initializing SQL',
|
||||||
pre_text='Error initializing SQL')
|
pre_text='Error initializing SQL')
|
||||||
@ -464,31 +464,31 @@ def _init_modules(args, crash_handler):
|
|||||||
crash_handler.handle_segfault()
|
crash_handler.handle_segfault()
|
||||||
|
|
||||||
log.init.debug("Initializing sessions...")
|
log.init.debug("Initializing sessions...")
|
||||||
sessions.init(qApp)
|
sessions.init(q_app)
|
||||||
|
|
||||||
log.init.debug("Initializing websettings...")
|
log.init.debug("Initializing websettings...")
|
||||||
websettings.init(args)
|
websettings.init(args)
|
||||||
|
|
||||||
log.init.debug("Initializing quickmarks...")
|
log.init.debug("Initializing quickmarks...")
|
||||||
quickmark_manager = urlmarks.QuickmarkManager(qApp)
|
quickmark_manager = urlmarks.QuickmarkManager(q_app)
|
||||||
objreg.register('quickmark-manager', quickmark_manager)
|
objreg.register('quickmark-manager', quickmark_manager)
|
||||||
|
|
||||||
log.init.debug("Initializing bookmarks...")
|
log.init.debug("Initializing bookmarks...")
|
||||||
bookmark_manager = urlmarks.BookmarkManager(qApp)
|
bookmark_manager = urlmarks.BookmarkManager(q_app)
|
||||||
objreg.register('bookmark-manager', bookmark_manager)
|
objreg.register('bookmark-manager', bookmark_manager)
|
||||||
|
|
||||||
log.init.debug("Initializing cookies...")
|
log.init.debug("Initializing cookies...")
|
||||||
cookie_jar = cookies.CookieJar(qApp)
|
cookie_jar = cookies.CookieJar(q_app)
|
||||||
ram_cookie_jar = cookies.RAMCookieJar(qApp)
|
ram_cookie_jar = cookies.RAMCookieJar(q_app)
|
||||||
objreg.register('cookie-jar', cookie_jar)
|
objreg.register('cookie-jar', cookie_jar)
|
||||||
objreg.register('ram-cookie-jar', ram_cookie_jar)
|
objreg.register('ram-cookie-jar', ram_cookie_jar)
|
||||||
|
|
||||||
log.init.debug("Initializing cache...")
|
log.init.debug("Initializing cache...")
|
||||||
diskcache = cache.DiskCache(standarddir.cache(), parent=qApp)
|
diskcache = cache.DiskCache(standarddir.cache(), parent=q_app)
|
||||||
objreg.register('cache', diskcache)
|
objreg.register('cache', diskcache)
|
||||||
|
|
||||||
log.init.debug("Initializing downloads...")
|
log.init.debug("Initializing downloads...")
|
||||||
download_manager = qtnetworkdownloads.DownloadManager(parent=qApp)
|
download_manager = qtnetworkdownloads.DownloadManager(parent=q_app)
|
||||||
objreg.register('qtnetwork-download-manager', download_manager)
|
objreg.register('qtnetwork-download-manager', download_manager)
|
||||||
|
|
||||||
log.init.debug("Initializing Greasemonkey...")
|
log.init.debug("Initializing Greasemonkey...")
|
||||||
@ -735,7 +735,7 @@ class Quitter:
|
|||||||
def _shutdown(self, status, restart): # noqa
|
def _shutdown(self, status, restart): # noqa
|
||||||
"""Second stage of shutdown."""
|
"""Second stage of shutdown."""
|
||||||
log.destroy.debug("Stage 2 of shutting down...")
|
log.destroy.debug("Stage 2 of shutting down...")
|
||||||
if qApp is None:
|
if q_app is None:
|
||||||
# No QApplication exists yet, so quit hard.
|
# No QApplication exists yet, so quit hard.
|
||||||
sys.exit(status)
|
sys.exit(status)
|
||||||
# Remove eventfilter
|
# Remove eventfilter
|
||||||
@ -743,7 +743,7 @@ class Quitter:
|
|||||||
log.destroy.debug("Removing eventfilter...")
|
log.destroy.debug("Removing eventfilter...")
|
||||||
event_filter = objreg.get('event-filter', None)
|
event_filter = objreg.get('event-filter', None)
|
||||||
if event_filter is not None:
|
if event_filter is not None:
|
||||||
qApp.removeEventFilter(event_filter)
|
q_app.removeEventFilter(event_filter)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
# Close all windows
|
# Close all windows
|
||||||
@ -792,7 +792,7 @@ class Quitter:
|
|||||||
session_manager.delete_autosave()
|
session_manager.delete_autosave()
|
||||||
# We use a singleshot timer to exit here to minimize the likelihood of
|
# We use a singleshot timer to exit here to minimize the likelihood of
|
||||||
# segfaults.
|
# segfaults.
|
||||||
QTimer.singleShot(0, functools.partial(qApp.exit, status))
|
QTimer.singleShot(0, functools.partial(q_app.exit, status))
|
||||||
|
|
||||||
|
|
||||||
class Application(QApplication):
|
class Application(QApplication):
|
||||||
@ -893,7 +893,7 @@ class EventFilter(QObject):
|
|||||||
Return:
|
Return:
|
||||||
True if the event should be filtered, False if it's passed through.
|
True if the event should be filtered, False if it's passed through.
|
||||||
"""
|
"""
|
||||||
if qApp.activeWindow() not in objreg.window_registry.values():
|
if q_app.activeWindow() not in objreg.window_registry.values():
|
||||||
# Some other window (print dialog, etc.) is focused so we pass the
|
# Some other window (print dialog, etc.) is focused so we pass the
|
||||||
# event through.
|
# event through.
|
||||||
return False
|
return False
|
||||||
|
@ -162,7 +162,7 @@ class ConsoleWidget(QWidget):
|
|||||||
namespace = {
|
namespace = {
|
||||||
'__name__': '__console__',
|
'__name__': '__console__',
|
||||||
'__doc__': None,
|
'__doc__': None,
|
||||||
'qApp': QApplication.instance(),
|
'q_app': QApplication.instance(),
|
||||||
# We use parent as self here because the user "feels" the whole
|
# We use parent as self here because the user "feels" the whole
|
||||||
# console, not just the line edit.
|
# console, not just the line edit.
|
||||||
'self': parent,
|
'self': parent,
|
||||||
|
@ -30,7 +30,7 @@ def test_on_focus_changed_issue1484(monkeypatch, qapp, caplog):
|
|||||||
For some reason, Qt sometimes calls on_focus_changed() with a QBuffer as
|
For some reason, Qt sometimes calls on_focus_changed() with a QBuffer as
|
||||||
argument. Let's make sure we handle that gracefully.
|
argument. Let's make sure we handle that gracefully.
|
||||||
"""
|
"""
|
||||||
monkeypatch.setattr(app, 'qApp', qapp)
|
monkeypatch.setattr(app, 'q_app', qapp)
|
||||||
|
|
||||||
buf = QBuffer()
|
buf = QBuffer()
|
||||||
app.on_focus_changed(buf, buf)
|
app.on_focus_changed(buf, buf)
|
||||||
|
Loading…
Reference in New Issue
Block a user