Skip to content

Commit

Permalink
Fix saving values with settings()
Browse files Browse the repository at this point in the history
  • Loading branch information
hluk committed Aug 31, 2014
1 parent 1799800 commit af5fd44
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/scriptable/scriptable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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);
}

Expand Down

0 comments on commit af5fd44

Please sign in to comment.