Use object registry for mainwindow.
This commit is contained in:
parent
a76c4c8ba5
commit
a32ed36ba6
@ -135,8 +135,8 @@ class Application(QApplication):
|
|||||||
log.init.debug("Initializing downloads...")
|
log.init.debug("Initializing downloads...")
|
||||||
self.downloadmanager = downloads.DownloadManager(self)
|
self.downloadmanager = downloads.DownloadManager(self)
|
||||||
log.init.debug("Initializing main window...")
|
log.init.debug("Initializing main window...")
|
||||||
self.mainwindow = mainwindow.MainWindow()
|
mainwin = mainwindow.MainWindow()
|
||||||
modeman_obj.mainwindow = self.mainwindow
|
self.registry['mainwindow'] = mainwin
|
||||||
log.init.debug("Initializing debug console...")
|
log.init.debug("Initializing debug console...")
|
||||||
self._debugconsole = console.ConsoleWidget()
|
self._debugconsole = console.ConsoleWidget()
|
||||||
log.init.debug("Initializing eventfilter...")
|
log.init.debug("Initializing eventfilter...")
|
||||||
@ -149,7 +149,7 @@ class Application(QApplication):
|
|||||||
|
|
||||||
log.init.debug("Showing mainwindow...")
|
log.init.debug("Showing mainwindow...")
|
||||||
if not args.nowindow:
|
if not args.nowindow:
|
||||||
self.mainwindow.show()
|
mainwin.show()
|
||||||
log.init.debug("Applying python hacks...")
|
log.init.debug("Applying python hacks...")
|
||||||
self._python_hacks()
|
self._python_hacks()
|
||||||
QTimer.singleShot(0, self._process_init_args)
|
QTimer.singleShot(0, self._process_init_args)
|
||||||
@ -371,7 +371,8 @@ class Application(QApplication):
|
|||||||
# pylint: disable=too-many-statements
|
# pylint: disable=too-many-statements
|
||||||
# syntactic sugar
|
# syntactic sugar
|
||||||
kp = self._keyparsers
|
kp = self._keyparsers
|
||||||
status = self.mainwindow.status
|
mainwin = self.registry['mainwindow']
|
||||||
|
status = mainwin.status
|
||||||
completion = self.registry['completion']
|
completion = self.registry['completion']
|
||||||
tabs = self.registry['tabbedbrowser']
|
tabs = self.registry['tabbedbrowser']
|
||||||
cmd = self.registry['status-cmd']
|
cmd = self.registry['status-cmd']
|
||||||
@ -419,7 +420,7 @@ class Application(QApplication):
|
|||||||
|
|
||||||
# config
|
# config
|
||||||
self.config.style_changed.connect(style.get_stylesheet.cache_clear)
|
self.config.style_changed.connect(style.get_stylesheet.cache_clear)
|
||||||
for obj in (tabs, completion, self.mainwindow, self.cmd_history,
|
for obj in (tabs, completion, mainwin, self.cmd_history,
|
||||||
websettings, modeman, status, status.txt):
|
websettings, modeman, status, status.txt):
|
||||||
self.config.changed.connect(obj.on_config_changed)
|
self.config.changed.connect(obj.on_config_changed)
|
||||||
for obj in kp.values():
|
for obj in kp.values():
|
||||||
@ -527,7 +528,7 @@ class Application(QApplication):
|
|||||||
def _save_geometry(self):
|
def _save_geometry(self):
|
||||||
"""Save the window geometry to the state config."""
|
"""Save the window geometry to the state config."""
|
||||||
stateconfig = self.registry['stateconfig']
|
stateconfig = self.registry['stateconfig']
|
||||||
data = bytes(self.mainwindow.saveGeometry())
|
data = bytes(self.registry['mainwindow'].saveGeometry())
|
||||||
geom = base64.b64encode(data).decode('ASCII')
|
geom = base64.b64encode(data).decode('ASCII')
|
||||||
try:
|
try:
|
||||||
stateconfig.add_section('geometry')
|
stateconfig.add_section('geometry')
|
||||||
|
@ -70,7 +70,6 @@ class ModeManager(QObject):
|
|||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
passthrough: A list of modes in which to pass through events.
|
passthrough: A list of modes in which to pass through events.
|
||||||
mainwindow: The mainwindow object
|
|
||||||
locked: Whether current mode is locked. This means the current mode can
|
locked: Whether current mode is locked. This means the current mode can
|
||||||
still be left (then locked will be reset), but no new mode can
|
still be left (then locked will be reset), but no new mode can
|
||||||
be entered while the current mode is active.
|
be entered while the current mode is active.
|
||||||
@ -94,7 +93,6 @@ class ModeManager(QObject):
|
|||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.mainwindow = None
|
|
||||||
self.locked = False
|
self.locked = False
|
||||||
self._handlers = {}
|
self._handlers = {}
|
||||||
self.passthrough = []
|
self.passthrough = []
|
||||||
@ -284,7 +282,8 @@ class ModeManager(QObject):
|
|||||||
# We already handled this same event at some point earlier, so
|
# We already handled this same event at some point earlier, so
|
||||||
# we're not interested in it anymore.
|
# we're not interested in it anymore.
|
||||||
return False
|
return False
|
||||||
if QApplication.instance().activeWindow() is not self.mainwindow:
|
if (QApplication.instance().activeWindow() is not
|
||||||
|
utils.get_object('mainwindow')):
|
||||||
# Some other window (print dialog, etc.) is focused so we pass
|
# Some other window (print dialog, etc.) is focused so we pass
|
||||||
# the event through.
|
# the event through.
|
||||||
return False
|
return False
|
||||||
|
@ -28,11 +28,10 @@ import functools
|
|||||||
|
|
||||||
from PyQt5.QtCore import pyqtSlot, Qt, QSize, QRect, QPoint, QTimer
|
from PyQt5.QtCore import pyqtSlot, Qt, QSize, QRect, QPoint, QTimer
|
||||||
from PyQt5.QtWidgets import (QTabWidget, QTabBar, QSizePolicy, QCommonStyle,
|
from PyQt5.QtWidgets import (QTabWidget, QTabBar, QSizePolicy, QCommonStyle,
|
||||||
QStyle, QStylePainter, QStyleOptionTab,
|
QStyle, QStylePainter, QStyleOptionTab)
|
||||||
QApplication)
|
|
||||||
from PyQt5.QtGui import QIcon, QPalette, QColor
|
from PyQt5.QtGui import QIcon, QPalette, QColor
|
||||||
|
|
||||||
from qutebrowser.utils import qtutils
|
from qutebrowser.utils import qtutils, utils
|
||||||
from qutebrowser.config import config
|
from qutebrowser.config import config
|
||||||
|
|
||||||
|
|
||||||
@ -210,7 +209,7 @@ class TabBar(QTabBar):
|
|||||||
confwidth = str(config.get('tabs', 'width'))
|
confwidth = str(config.get('tabs', 'width'))
|
||||||
if confwidth.endswith('%'):
|
if confwidth.endswith('%'):
|
||||||
perc = int(confwidth.rstrip('%'))
|
perc = int(confwidth.rstrip('%'))
|
||||||
width = QApplication.instance().mainwindow.width() * perc / 100
|
width = utils.get_object('mainwindow').width() * perc / 100
|
||||||
else:
|
else:
|
||||||
width = int(confwidth)
|
width = int(confwidth)
|
||||||
size = QSize(max(minimum_size.width(), width), height)
|
size = QSize(max(minimum_size.width(), width), height)
|
||||||
|
Loading…
Reference in New Issue
Block a user