Browse Source

Created universal Settings entity

Ivan Arkhipov 5 years ago
parent
commit
977de7a885
3 changed files with 95 additions and 1 deletions
  1. 2 1
      src/Legacy/Legacy.pro
  2. 5 0
      src/Legacy/main.cpp
  3. 88 0
      src/Legacy/models/settings.h

+ 2 - 1
src/Legacy/Legacy.pro

@@ -57,7 +57,8 @@ HEADERS += \
     widgets/dialogwindow.h \
     widgets/qsmoothscrollarea.h \
     constants.h \
-    fonts.h
+    fonts.h \
+    models/settings.h
 
 FORMS += \
     widgets/helpwidget.ui \

+ 5 - 0
src/Legacy/main.cpp

@@ -19,6 +19,11 @@ int main(int argc, char *argv[])
     setlocale(LC_ALL,"Russian");
     QApplication a(argc, argv);
 
+    QCoreApplication::setOrganizationName("LotroLegacy");
+    QCoreApplication::setOrganizationDomain("translate.lotros.ru");
+    QCoreApplication::setApplicationName("Legacy v2");
+    QSettings::setDefaultFormat(QSettings::IniFormat);
+
     qDebug() << "Checking if there's another instance of Legacy";
 
     QLockFile lockFile(QDir::temp().absoluteFilePath("rulotro.lock"));

+ 88 - 0
src/Legacy/models/settings.h

@@ -0,0 +1,88 @@
+#ifndef SETTINGS_H
+#define SETTINGS_H
+
+#include <QSettings>
+
+namespace Settings
+{
+
+static inline QMap<QString, QVariant> defaults = {
+    // General info
+    {"General/UI_scale", "100"},
+    {"General/CurrentInitStage", "0"},
+    {"General/MicroUpdates", "Disabled"},
+
+    // Lotro Manager
+    {"Lotro/game_path", "none"},
+    {"Lotro/original_locale", "English"},
+    {"Lotro/skip_raw_downloads", "True"},
+    {"Lotro/no_splash_screen", "True"},
+
+    // Databases download settings
+    {"DatabaseDownload/sound", "Disabled"},
+    {"DatabaseDownload/text", "Disabled"},
+    {"DatabaseDownload/image", "Disabled"},
+    {"DatabaseDownload/loadscreen", "Disabled"},
+    {"DatabaseDownload/texture", "Disabled"},
+    {"DatabaseDownload/font", "Disabled"},
+    {"DatabaseDownload/video", "Disabled"},
+
+    // Databases applied status
+    {"DatabaseApplied/sound", "False"},
+    {"DatabaseApplied/text", "False"},
+    {"DatabaseApplied/image", "False"},
+    {"DatabaseApplied/loadscreen", "False"},
+    {"DatabaseApplied/texture", "False"},
+    {"DatabaseApplied/font", "False"},
+    {"DatabaseApplied/video", "False"},
+
+    // Databases downloaded paths
+    {"DatabasePath/sound", "False"},
+    {"DatabasePath/text", "False"},
+    {"DatabasePath/image", "False"},
+    {"DatabasePath/loadscreen", "False"},
+    {"DatabasePath/texture", "False"},
+    {"DatabasePath/font", "False"},
+    {"DatabasePath/video", "False"},
+
+    // Databases download date
+    {"DatabaseDownloadDate/sound", "none"},
+    {"DatabaseDownloadDate/text", "none"},
+    {"DatabaseDownloadDate/image", "none"},
+    {"DatabaseDownloadDate/loadscreen", "none"},
+    {"DatabaseDownloadDate/texture", "none"},
+    {"DatabaseDownloadDate/font", "none"},
+    {"DatabaseDownloadDate/video", "none"},
+
+    // Localisation components
+    {"Components/fonts", "Disabled"},
+    {"Components/texts_main", "Disabled"},
+    {"Components/texts_items", "Disabled"},
+    {"Components/texts_emotes", "Disabled"},
+    {"Components/maps", "Disabled"},
+    {"Components/loadscreens", "Disabled"},
+    {"Components/sounds", "Disabled"},
+    {"Components/videos", "Disabled"}
+};
+
+static void setDefaultSettings()
+{
+    QSettings settings;
+    foreach (QString key, defaults.keys()) {
+        settings.setValue(key, defaults[key]);
+    }
+}
+
+static QVariant getSettingsValue(QString key) {
+    QSettings settings;
+    return settings.value(key);
+}
+
+static void setSettingsValue(QString key, QVariant value) {
+    QSettings settings;
+    settings.setValue(key, value);
+}
+
+}
+
+#endif // SETTINGS_H