Use QCoreApplication.instance()
This commit is contained in:
parent
3c098060d1
commit
edc9d0810c
1
TODO
1
TODO
@ -124,7 +124,6 @@ Minor features
|
||||
==============
|
||||
|
||||
- Display metavars for commands in input bar.
|
||||
- Use QCoreApplication instead of QApplication for .instance()
|
||||
- count support for special keys
|
||||
- --set-as-default argument
|
||||
- Make inspector height resizable
|
||||
|
@ -18,7 +18,7 @@
|
||||
"""The main browser widgets."""
|
||||
|
||||
import sip
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from PyQt5.QtCore import QCoreApplication
|
||||
from PyQt5.QtNetwork import QNetworkReply
|
||||
from PyQt5.QtWebKitWidgets import QWebPage
|
||||
|
||||
@ -41,7 +41,8 @@ class BrowserPage(QWebPage):
|
||||
self._extension_handlers = {
|
||||
QWebPage.ErrorPageExtension: self._handle_errorpage,
|
||||
}
|
||||
self.setNetworkAccessManager(QApplication.instance().networkmanager)
|
||||
self.setNetworkAccessManager(
|
||||
QCoreApplication.instance().networkmanager)
|
||||
|
||||
def _handle_errorpage(self, opt, out):
|
||||
"""Display an error page if needed.
|
||||
|
@ -22,8 +22,7 @@ import logging
|
||||
from qutebrowser.commands._exceptions import (ArgumentCountError,
|
||||
PrerequisitesError)
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal, QObject
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from PyQt5.QtCore import pyqtSignal, QObject, QCoreApplication
|
||||
from PyQt5.QtWebKit import QWebSettings
|
||||
|
||||
|
||||
@ -85,7 +84,7 @@ class Command(QObject):
|
||||
"""
|
||||
# We don't use modeman.instance() here to avoid a circular import
|
||||
# of qutebrowser.keyinput.modeman.
|
||||
curmode = QApplication.instance().modeman.mode
|
||||
curmode = QCoreApplication.instance().modeman.mode
|
||||
if self.modes is not None and curmode not in self.modes:
|
||||
raise PrerequisitesError("{}: This command is only allowed in {} "
|
||||
"mode.".format(self.name,
|
||||
|
@ -30,8 +30,7 @@ import configparser
|
||||
from configparser import ExtendedInterpolation
|
||||
from collections.abc import MutableMapping
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal, QObject
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from PyQt5.QtCore import pyqtSignal, QObject, QCoreApplication
|
||||
|
||||
import qutebrowser.config.configdata as configdata
|
||||
import qutebrowser.commands.utils as cmdutils
|
||||
@ -42,7 +41,7 @@ from qutebrowser.config._conftypes import ValidationError
|
||||
|
||||
def instance():
|
||||
"""Get the global config instance."""
|
||||
return QApplication.instance().config
|
||||
return QCoreApplication.instance().config
|
||||
|
||||
|
||||
def get(*args, **kwargs):
|
||||
|
@ -24,8 +24,8 @@ Module attributes:
|
||||
import logging
|
||||
|
||||
from PyQt5.QtGui import QWindow
|
||||
from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject, QEvent
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from PyQt5.QtCore import (pyqtSignal, pyqtSlot, QObject, QEvent,
|
||||
QCoreApplication)
|
||||
|
||||
import qutebrowser.config.config as config
|
||||
import qutebrowser.commands.utils as cmdutils
|
||||
@ -34,7 +34,7 @@ import qutebrowser.utils.debug as debug
|
||||
|
||||
def instance():
|
||||
"""Get the global modeman instance."""
|
||||
return QApplication.instance().modeman
|
||||
return QCoreApplication.instance().modeman
|
||||
|
||||
|
||||
def enter(mode, reason=None):
|
||||
@ -259,7 +259,7 @@ class ModeManager(QObject):
|
||||
logging.debug("Ignoring event {} for {}".format(
|
||||
debug.EVENTS[typ], obj.__class__.__name__))
|
||||
return False
|
||||
if QApplication.instance().activeWindow() is not self.mainwindow:
|
||||
if QCoreApplication.instance().activeWindow() is not self.mainwindow:
|
||||
# Some other window (print dialog, etc.) is focused so we pass
|
||||
# the event through.
|
||||
return False
|
||||
|
@ -19,8 +19,7 @@
|
||||
|
||||
import logging
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from PyQt5.QtCore import pyqtSlot, QCoreApplication
|
||||
|
||||
from qutebrowser.utils.usertypes import NeighborList
|
||||
|
||||
@ -51,7 +50,7 @@ class History:
|
||||
|
||||
def __init__(self):
|
||||
self._tmphist = None
|
||||
history = QApplication.instance().cmd_history.data
|
||||
history = QCoreApplication.instance().cmd_history.data
|
||||
if history is None:
|
||||
self._history = []
|
||||
else:
|
||||
|
@ -19,13 +19,12 @@
|
||||
|
||||
import logging
|
||||
|
||||
from PyQt5.QtCore import QObject, pyqtSignal
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from PyQt5.QtCore import QObject, pyqtSignal, QCoreApplication
|
||||
|
||||
|
||||
def instance():
|
||||
"""Get the global messagebridge instance."""
|
||||
return QApplication.instance().messagebridge
|
||||
return QCoreApplication.instance().messagebridge
|
||||
|
||||
|
||||
def error(message):
|
||||
|
@ -20,8 +20,8 @@
|
||||
import binascii
|
||||
from base64 import b64decode
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot, QRect, QPoint
|
||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QApplication
|
||||
from PyQt5.QtCore import pyqtSlot, QRect, QPoint, QCoreApplication
|
||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout
|
||||
from PyQt5.QtWebKitWidgets import QWebInspector
|
||||
|
||||
from qutebrowser.widgets._statusbar import StatusBar
|
||||
@ -50,9 +50,9 @@ class MainWindow(QWidget):
|
||||
|
||||
self.setWindowTitle('qutebrowser')
|
||||
try:
|
||||
geom = b64decode(
|
||||
QApplication.instance().stateconfig['geometry']['mainwindow'],
|
||||
validate=True)
|
||||
stateconf = QCoreApplication.instance().stateconfig
|
||||
geom = b64decode(stateconf['geometry']['mainwindow'],
|
||||
validate=True)
|
||||
except (KeyError, binascii.Error):
|
||||
self._set_default_geometry()
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user