Procházet zdrojové kódy

Allow for any boolean settings to be cycleable.

- Remove the necessity for defining possible values

Plex-CLA-1.0-signed-off-by: Lukas Pitschl lukas@leftandleaving.com
Lukas Pitschl před 8 roky
rodič
revize
d88cb541df
1 změnil soubory, kde provedl 7 přidání a 1 odebrání
  1. 7 1
      src/settings/SettingsComponent.cpp

+ 7 - 1
src/settings/SettingsComponent.cpp

@@ -48,9 +48,15 @@ void SettingsComponent::cycleSetting(const QString& args)
     return;
   }
   QVariantList values = section->possibleValues(valueName);
+  // If no possible values are set, assume that the setting is a simple
+  // checkbox and cycle through the boolean value.
   if (values.size() == 0)
   {
-    QLOG_ERROR() << "Setting" << settingName << "is unknown or is not cycleable.";
+    QVariant currentValue = section->value(valueName);
+    auto nextValue = currentValue.toBool() ? false : true;
+    setValue(sectionID, valueName, nextValue);
+    QLOG_DEBUG() << "Setting" << settingName << "to " << (nextValue ? "Enabled" : "Disabled");
+    emit SystemComponent::Get().settingsMessage(valueName, nextValue ? "Enabled" : "Disabled");
     return;
   }
   QVariant currentValue = section->value(valueName);