Use object registry for stateconfig.
This commit is contained in:
parent
21bdf517b7
commit
1d535ae300
@ -57,7 +57,6 @@ class Application(QApplication):
|
|||||||
meta_registry: The object registry of object registries.
|
meta_registry: The object registry of object registries.
|
||||||
mainwindow: The MainWindow QWidget.
|
mainwindow: The MainWindow QWidget.
|
||||||
config: The main ConfigManager
|
config: The main ConfigManager
|
||||||
stateconfig: The "state" ReadWriteConfigParser instance.
|
|
||||||
cmd_history: The "cmd_history" LineConfigParser instance.
|
cmd_history: The "cmd_history" LineConfigParser instance.
|
||||||
messagebridge: The global MessageBridge instance.
|
messagebridge: The global MessageBridge instance.
|
||||||
modeman: The global ModeManager instance.
|
modeman: The global ModeManager instance.
|
||||||
@ -100,7 +99,6 @@ class Application(QApplication):
|
|||||||
self._crashdlg = None
|
self._crashdlg = None
|
||||||
self._crashlogfile = None
|
self._crashlogfile = None
|
||||||
self.messagebridge = None
|
self.messagebridge = None
|
||||||
self.stateconfig = None
|
|
||||||
self.modeman = None
|
self.modeman = None
|
||||||
self.cmd_history = None
|
self.cmd_history = None
|
||||||
self.config = None
|
self.config = None
|
||||||
@ -211,7 +209,8 @@ class Application(QApplication):
|
|||||||
msgbox.exec_()
|
msgbox.exec_()
|
||||||
# We didn't really initialize much so far, so we just quit hard.
|
# We didn't really initialize much so far, so we just quit hard.
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
self.stateconfig = iniparsers.ReadWriteConfigParser(confdir, 'state')
|
stateconfig = iniparsers.ReadWriteConfigParser(confdir, 'state')
|
||||||
|
self.registry['stateconfig'] = stateconfig
|
||||||
self.cmd_history = lineparser.LineConfigParser(
|
self.cmd_history = lineparser.LineConfigParser(
|
||||||
confdir, 'cmd_history', ('completion', 'history-length'))
|
confdir, 'cmd_history', ('completion', 'history-length'))
|
||||||
|
|
||||||
@ -529,13 +528,14 @@ 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']
|
||||||
data = bytes(self.mainwindow.saveGeometry())
|
data = bytes(self.mainwindow.saveGeometry())
|
||||||
geom = base64.b64encode(data).decode('ASCII')
|
geom = base64.b64encode(data).decode('ASCII')
|
||||||
try:
|
try:
|
||||||
self.stateconfig.add_section('geometry')
|
stateconfig.add_section('geometry')
|
||||||
except configparser.DuplicateSectionError:
|
except configparser.DuplicateSectionError:
|
||||||
pass
|
pass
|
||||||
self.stateconfig['geometry']['mainwindow'] = geom
|
stateconfig['geometry']['mainwindow'] = geom
|
||||||
|
|
||||||
def _destroy_crashlogfile(self):
|
def _destroy_crashlogfile(self):
|
||||||
"""Clean up the crash log file and delete it."""
|
"""Clean up the crash log file and delete it."""
|
||||||
@ -770,8 +770,12 @@ class Application(QApplication):
|
|||||||
("quickmarks", quickmarks.save)]
|
("quickmarks", quickmarks.save)]
|
||||||
if hasattr(self, 'cmd_history'):
|
if hasattr(self, 'cmd_history'):
|
||||||
to_save.append(("command history", self.cmd_history.save))
|
to_save.append(("command history", self.cmd_history.save))
|
||||||
if hasattr(self, 'stateconfig'):
|
try:
|
||||||
to_save.append(("window geometry", self.stateconfig.save))
|
stateconfig = self.registry['stateconfig']
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
to_save.append(("window geometry", stateconfig.save))
|
||||||
try:
|
try:
|
||||||
cookiejar = self.registry['cookiejar']
|
cookiejar = self.registry['cookiejar']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
@ -22,12 +22,12 @@
|
|||||||
import binascii
|
import binascii
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtSlot, QRect, QPoint, QCoreApplication, QTimer
|
from PyQt5.QtCore import pyqtSlot, QRect, QPoint, QTimer
|
||||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout
|
from PyQt5.QtWidgets import QWidget, QVBoxLayout
|
||||||
|
|
||||||
from qutebrowser.commands import cmdutils
|
from qutebrowser.commands import cmdutils
|
||||||
from qutebrowser.config import config
|
from qutebrowser.config import config
|
||||||
from qutebrowser.utils import message, log, usertypes, qtutils
|
from qutebrowser.utils import message, log, usertypes, qtutils, utils
|
||||||
from qutebrowser.widgets import tabbedbrowser, completion, downloads
|
from qutebrowser.widgets import tabbedbrowser, completion, downloads
|
||||||
from qutebrowser.widgets.statusbar import bar
|
from qutebrowser.widgets.statusbar import bar
|
||||||
|
|
||||||
@ -50,8 +50,8 @@ class MainWindow(QWidget):
|
|||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
self.setWindowTitle('qutebrowser')
|
self.setWindowTitle('qutebrowser')
|
||||||
|
stateconf = utils.get_object('stateconfig')
|
||||||
try:
|
try:
|
||||||
stateconf = QCoreApplication.instance().stateconfig
|
|
||||||
data = stateconf['geometry']['mainwindow']
|
data = stateconf['geometry']['mainwindow']
|
||||||
log.init.debug("Restoring mainwindow from {}".format(data))
|
log.init.debug("Restoring mainwindow from {}".format(data))
|
||||||
geom = base64.b64decode(data, validate=True)
|
geom = base64.b64decode(data, validate=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user