From 1ed6e1b3e7475d28c95305bd4f53ff4a74655192 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 16 Jan 2014 16:00:51 +0100 Subject: Make config commands understand booleans. The user frontends for our settings assume everything is a string, so do the necessary conversions. Note that this means there is no way to set the string values "true" and "false". For a correct implementation, users would need to supply types when adding new values. Change-Id: If3638525eeebe73857834389bae46484eee92cc3 Reviewed-by: Joerg Bornemann --- src/app/shared/qbssettings.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/app/shared/qbssettings.h b/src/app/shared/qbssettings.h index a32f03e46..356399cde 100644 --- a/src/app/shared/qbssettings.h +++ b/src/app/shared/qbssettings.h @@ -44,11 +44,17 @@ inline SettingsPtr qbsSettings() inline QString settingsValueToRepresentation(const QVariant &value) { + if (value.type() == QVariant::Bool) + return QLatin1String(value.toBool() ? "true" : "false"); return value.toStringList().join(QLatin1String(",")); } inline QVariant representationToSettingsValue(const QString &representation) { + if (representation == QLatin1String("true")) + return QVariant(true); + if (representation == QLatin1String("false")) + return QVariant(false); const QStringList list = representation.split(QLatin1Char(','), QString::SkipEmptyParts); if (list.count() > 1) return list; -- cgit v1.2.3