Browse Source

Migrate old users to webMode == TV and default to desktop / no-fullscreen for new ones

Fixes plexinc/plex-media-player-private#502
Tobias Hieta 8 năm trước cách đây
mục cha
commit
83013d072f

+ 3 - 3
resources/settings/settings_description.json

@@ -1,7 +1,7 @@
 [
   {
     "section": "__meta__",
-    "version": 3
+    "version": 4
   },
   {
     "section": "state",
@@ -20,7 +20,7 @@
     "values": [
       {
         "value": "webMode",
-        "default": "tv",
+        "default": "desktop",
         "platforms": [ "windows", "macosx" ],
         "possible_values": [
           [ "desktop", "desktop" ],
@@ -34,7 +34,7 @@
       },
       {
         "value": "fullscreen",
-        "default": true,
+        "default": false,
         "platforms_excluded": "oe"
       },
       {

+ 14 - 1
src/settings/SettingsComponent.cpp

@@ -174,10 +174,20 @@ void SettingsComponent::load()
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 void SettingsComponent::loadConf(const QString& path, bool storage)
 {
+  bool migrateTvMode = false;
   QJsonObject json = loadJson(path);
 
   int version = json["version"].toInt(0);
-  if (version != m_settingsVersion)
+
+  // Migrate to settings version 4
+  if (version == 3 && m_settingsVersion == 4)
+  {
+    // We only need to make sure that old users have the
+    // webmode set to "tv" so that we don't flip their
+    // interface unnecessarly
+    migrateTvMode = true;
+  }
+  else if (version != m_settingsVersion)
   {
     QString backup = path + ".broken";
     QFile::remove(backup);
@@ -217,6 +227,9 @@ void SettingsComponent::loadConf(const QString& path, bool storage)
     for(const QString& setting : jsonSection.keys())
       sec->setValue(setting, jsonSection.value(setting).toVariant());
   }
+
+  if (migrateTvMode)
+    getSection(SETTINGS_SECTION_MAIN)->setValue("webMode", "tv");
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////