فهرست منبع

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 8 سال پیش
والد
کامیت
d88cb541df
1فایلهای تغییر یافته به همراه7 افزوده شده و 1 حذف شده
  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);