aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/SettingsHandler.qml43
-rw-r--r--src/command/commands.js2
2 files changed, 9 insertions, 36 deletions
diff --git a/src/SettingsHandler.qml b/src/SettingsHandler.qml
index f281da1..fd13473 100644
--- a/src/SettingsHandler.qml
+++ b/src/SettingsHandler.qml
@@ -2,46 +2,19 @@ import QtQuick 2.0
import Qt.labs.settings 1.0
QtObject {
- function getSetter(category, name) {
- try {
- var type = typeof eval(category + '.' + name);
-
- switch ( type ) {
- case 'undefined': {
- throw new ReferenceError();
- break;
- }
- case 'string': {
- return function(value) {
- return eval(category + '.' + name + ' = "' + value + '"');
- }
- break;
- }
- default: {
- return function(value) {
- return eval(category + '.' + name + ' = ' + value);
- }
- break;
- }
- }
- }
- catch (exception) {
+ function read(category, name) {
+ if ( typeof this[category][name] === 'undefined' ) {
throw category + '.' + name + ' doesnt exist.';
+ } else {
+ return this[category][name];
}
}
- function read(category, name) {
- try {
- var value = eval(category + '.' + name);
-
- if ( typeof value === 'undefined' ) {
- throw new ReferenceError();
- } else {
- return value;
- }
- }
- catch (exception) {
+ function set(category, name, value) {
+ if ( typeof this[category][name] === 'undefined' ) {
throw category + '.' + name + ' doesnt exist.';
+ } else {
+ this[category][name] = value;
}
}
diff --git a/src/command/commands.js b/src/command/commands.js
index d2a53af..333eb98 100644
--- a/src/command/commands.js
+++ b/src/command/commands.js
@@ -79,7 +79,7 @@ function set(output, args) {
break;
}
case 3: {
- settings.getSetter(args[0], args[1])(args[2]);
+ settings.set(args[0], args[1], args[2]);
break;
}
default: {