Browse Source

SettingsComponent: fix forcing display mode on command line

Reproduction:
- start PMP, set it to fullscreened TV mode, exit
- now start with "--desktop --fullscreen"
- it will start in TV mode

The problem is that the "webMode" setting is never set to "desktop".
Indeed, the "webMode" setting is set from "layout" in this code path,
which includes only "tv" and "auto" anyway. A forced "desktop" layout
mode makes strangely no sense, because there'd be no way for the user
to change it (since desktop mode still lacks PMP settings).

Fix by changing the "webMode" setting to "desktop" explicitly in this
case.
Vincent Lang 8 years ago
parent
commit
f41176d1b9
1 changed files with 20 additions and 6 deletions
  1. 20 6
      src/settings/SettingsComponent.cpp

+ 20 - 6
src/settings/SettingsComponent.cpp

@@ -746,6 +746,9 @@ QString SettingsComponent::getWebClientUrl(bool desktop)
 void SettingsComponent::setCommandLineValues(const QStringList& values)
 {
   QLOG_DEBUG() << values;
+
+  QString mode = ""; // unset, different from "auto"
+
   for (const QString& value : values)
   {
     if (value == "fullscreen")
@@ -753,15 +756,26 @@ void SettingsComponent::setCommandLineValues(const QStringList& values)
     else if (value == "windowed")
       setValue(SETTINGS_SECTION_MAIN, "fullscreen", false);
     else if (value == "desktop")
-      setValue(SETTINGS_SECTION_MAIN, "layout", "auto");
+      mode = "desktop";
     else if (value == "tv")
-      setValue(SETTINGS_SECTION_MAIN, "layout", "tv");
+      mode = "tv";
     else if (value == "auto-layout")
-      setValue(SETTINGS_SECTION_MAIN, "layout", "auto");
+      mode = "auto";
   }
 
-  auto layout = value(SETTINGS_SECTION_MAIN, "layout").toString();
-  if (layout != "auto")
-    setValue(SETTINGS_SECTION_MAIN, "webMode", layout);
+  if (mode == "desktop")
+  {
+    setValue(SETTINGS_SECTION_MAIN, "layout", "auto");
+    setValue(SETTINGS_SECTION_MAIN, "webMode", "desktop");
+  }
+  else if (mode == "tv")
+  {
+    setValue(SETTINGS_SECTION_MAIN, "layout", "tv");
+    setValue(SETTINGS_SECTION_MAIN, "webMode", "tv");
+  }
+  else if (mode == "auto")
+  {
+    setValue(SETTINGS_SECTION_MAIN, "layout", "auto");
+  }
 }