Allow portable configuration via `QtUtilities::getSettings()`
See https://github.com/Martchus/tageditor/issues/88
This commit is contained in:
parent
217942e946
commit
eb1b73f4be
|
@ -122,7 +122,7 @@ include(BasicConfig)
|
||||||
set(CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES
|
set(CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES
|
||||||
"${CONFIGURATION_PACKAGE_SUFFIX}"
|
"${CONFIGURATION_PACKAGE_SUFFIX}"
|
||||||
CACHE STRING "sets the suffix for qtutilities")
|
CACHE STRING "sets the suffix for qtutilities")
|
||||||
find_package(qtutilities${CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES} 6.0.0 REQUIRED)
|
find_package(qtutilities${CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES} 6.8.0 REQUIRED)
|
||||||
use_qt_utilities()
|
use_qt_utilities()
|
||||||
|
|
||||||
# find passwordfile
|
# find passwordfile
|
||||||
|
|
|
@ -33,15 +33,9 @@ int runWidgetsGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs,
|
||||||
QApplication application(argc, argv);
|
QApplication application(argc, argv);
|
||||||
|
|
||||||
// restore Qt settings
|
// restore Qt settings
|
||||||
QtSettings qtSettings;
|
auto qtSettings = QtSettings();
|
||||||
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QStringLiteral(PROJECT_NAME));
|
auto settings = QtUtilities::getSettings(QStringLiteral(PROJECT_NAME));
|
||||||
|
qtSettings.restore(*settings);
|
||||||
// move old config to new location
|
|
||||||
const QString oldConfig
|
|
||||||
= QSettings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), QApplication::applicationName()).fileName();
|
|
||||||
QFile::rename(oldConfig, settings.fileName()) || QFile::remove(oldConfig);
|
|
||||||
settings.sync();
|
|
||||||
qtSettings.restore(settings);
|
|
||||||
qtSettings.apply();
|
qtSettings.apply();
|
||||||
|
|
||||||
// apply settings specified via command line args
|
// apply settings specified via command line args
|
||||||
|
@ -49,7 +43,7 @@ int runWidgetsGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs,
|
||||||
LOAD_QT_TRANSLATIONS;
|
LOAD_QT_TRANSLATIONS;
|
||||||
|
|
||||||
// init widgets GUI
|
// init widgets GUI
|
||||||
MainWindow w(settings, &qtSettings);
|
auto w = MainWindow(*settings, &qtSettings);
|
||||||
w.show();
|
w.show();
|
||||||
if (!file.isEmpty()) {
|
if (!file.isEmpty()) {
|
||||||
w.openFile(file);
|
w.openFile(file);
|
||||||
|
|
|
@ -79,14 +79,14 @@ int runQuickGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs, c
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// load settings from configuration file
|
// load settings from configuration file
|
||||||
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QStringLiteral(PROJECT_NAME));
|
auto settings = QtUtilities::getSettings(QStringLiteral(PROJECT_NAME));
|
||||||
|
|
||||||
// load translations
|
// load translations
|
||||||
LOAD_QT_TRANSLATIONS;
|
LOAD_QT_TRANSLATIONS;
|
||||||
|
|
||||||
// init Quick GUI
|
// init Quick GUI
|
||||||
QQmlApplicationEngine engine;
|
auto engine = QQmlApplicationEngine();
|
||||||
Controller controller(settings, file);
|
auto controller = Controller(*settings, file);
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
registerControllerForAndroid(&controller);
|
registerControllerForAndroid(&controller);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue