Set orgname to make inspector settings persistent

This commit is contained in:
Florian Bruhin 2014-05-26 11:47:02 +02:00
parent 24543edcbe
commit d00a946497
2 changed files with 23 additions and 12 deletions

View File

@ -236,6 +236,7 @@ class QuteBrowser(QApplication):
def _init_misc(self):
"""Initialize misc things."""
self.setOrganizationName("qutebrowser")
self.setApplicationName("qutebrowser")
self.setApplicationVersion(qutebrowser.__version__)
self.messagebridge = MessageBridge()

View File

@ -210,18 +210,28 @@ def get_standard_dir(typ):
typ: A member of the QStandardPaths::StandardLocation enum,
see http://qt-project.org/doc/qt-5/qstandardpaths.html#StandardLocation-enum
"""
qapp = QCoreApplication.instance()
orgname = qapp.organizationName()
# We need to temporarely unset the organisationname here since the
# webinspector wants it to be set to store its persistent data correctly,
# but we don't want that to happen.
qapp.setOrganizationName(None)
try:
# FIXME RuntimeLocation "can be empty on some systems", wat.
path = QStandardPaths.writableLocation(typ)
# Qt seems to use '/' as path separator even on Windows...
path = path.replace('/', os.sep)
appname = QCoreApplication.instance().applicationName()
appname = qapp.applicationName()
if (typ == QStandardPaths.ConfigLocation and
path.split(os.sep)[-1] != appname):
# Workaround for https://bugreports.qt-project.org/browse/QTBUG-38872
# Workaround for
# https://bugreports.qt-project.org/browse/QTBUG-38872
path = os.path.join(path, appname)
if not os.path.exists(path):
os.makedirs(path)
return path
finally:
qapp.setOrganizationName(orgname)
def actute_warning():