Move create_qsettings() out of preferences

- Load order was impacting translations
- Fix by moving create_qsettings() for now
This commit is contained in:
Andrew Senetar 2022-05-08 20:33:31 -05:00
parent 7a44c72a0a
commit 40ff40bea8
Signed by: arsenetar
GPG Key ID: C63300DCE48AB2F1
3 changed files with 27 additions and 29 deletions

View File

@ -5,17 +5,15 @@
# http://www.gnu.org/licenses/gpl-3.0.html
from PyQt5.QtWidgets import QApplication, QDockWidget
from PyQt5.QtCore import Qt, QSettings, QRect, QObject, pyqtSignal, QStandardPaths
from PyQt5.QtCore import Qt, QRect, QObject, pyqtSignal
from PyQt5.QtGui import QColor
from hscommon import trans
from hscommon.plat import ISLINUX, ISWINDOWS
from hscommon.plat import ISLINUX
from core.app import AppMode
from core.scanner import ScanType
from hscommon.util import tryint
from core.util import executable_folder
from os import path as op
from qt.util import create_qsettings
def get_langnames():
@ -70,27 +68,6 @@ def _adjust_after_deserialization(v):
return v
def create_qsettings():
# Create a QSettings instance with the correct arguments.
config_location = op.join(executable_folder(), "settings.ini")
if op.isfile(config_location):
settings = QSettings(config_location, QSettings.IniFormat)
settings.setValue("Portable", True)
elif ISWINDOWS:
# On windows use an ini file in the AppDataLocation instead of registry if possible as it
# makes it easier for a user to clear it out when there are issues.
locations = QStandardPaths.standardLocations(QStandardPaths.AppDataLocation)
if locations:
settings = QSettings(op.join(locations[0], "settings.ini"), QSettings.IniFormat)
else:
settings = QSettings()
settings.setValue("Portable", False)
else:
settings = QSettings()
settings.setValue("Portable", False)
return settings
class PreferencesBase(QObject):
prefsChanged = pyqtSignal()

View File

@ -14,8 +14,9 @@ import logging
from core.util import executable_folder
from hscommon.util import first
from hscommon.plat import ISWINDOWS
from PyQt5.QtCore import QStandardPaths
from PyQt5.QtCore import QStandardPaths, QSettings
from PyQt5.QtGui import QPixmap, QIcon, QGuiApplication
from PyQt5.QtWidgets import (
QSpacerItem,
@ -137,3 +138,24 @@ def escape_amp(s):
# Returns `s` with escaped ampersand (& --> &&). QAction text needs to have & escaped because
# that character is used to define "accel keys".
return s.replace("&", "&&")
def create_qsettings():
# Create a QSettings instance with the correct arguments.
config_location = op.join(executable_folder(), "settings.ini")
if op.isfile(config_location):
settings = QSettings(config_location, QSettings.IniFormat)
settings.setValue("Portable", True)
elif ISWINDOWS:
# On windows use an ini file in the AppDataLocation instead of registry if possible as it
# makes it easier for a user to clear it out when there are issues.
locations = QStandardPaths.standardLocations(QStandardPaths.AppDataLocation)
if locations:
settings = QSettings(op.join(locations[0], "settings.ini"), QSettings.IniFormat)
else:
settings = QSettings()
settings.setValue("Portable", False)
else:
settings = QSettings()
settings.setValue("Portable", False)
return settings

3
run.py
View File

@ -15,8 +15,7 @@ from PyQt5.QtWidgets import QApplication
from hscommon.trans import install_gettext_trans_under_qt
from qt.error_report_dialog import install_excepthook
from qt.util import setup_qt_logging
from qt.preferences import create_qsettings
from qt.util import setup_qt_logging, create_qsettings
from qt import dg_rc # noqa: F401
from qt.platform import BASE_PATH
from core import __version__, __appname__