diff --git a/src/scriptable/scriptable.cpp b/src/scriptable/scriptable.cpp index ba632ba46e..5b4b992080 100644 --- a/src/scriptable/scriptable.cpp +++ b/src/scriptable/scriptable.cpp @@ -1046,9 +1046,23 @@ QScriptValue Scriptable::dialog() QScriptValue Scriptable::settings() { - QSettings settings; + const QString settingsGroup = "script"; + + if (argumentCount() == 2) { + Settings settings2; + settings2.beginGroup(settingsGroup); + + const QString key = arg(0); + const QScriptValue value = argument(1); + const QByteArray *bytes = getByteArray(value); + const QVariant saveValue = bytes ? QVariant(*bytes) : value.toVariant(); + settings2.setValue(key, saveValue); + + return QScriptValue(); + } - settings.beginGroup("script"); + QSettings settings; + settings.beginGroup(settingsGroup); if (argumentCount() == 1) { QVariant value = settings.value(arg(0)); @@ -1059,11 +1073,6 @@ QScriptValue Scriptable::settings() return engine()->newVariant(value); } - if (argumentCount() == 2) { - Settings().setValue(arg(0), argument(1).toVariant()); - return QScriptValue(); - } - return toScriptValue(settings.allKeys(), this); }