From fed3644592b52e83f09f3777fb388399601e4b29 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 25 Feb 2013 20:58:01 +0100 Subject: [PATCH] partly working configuration still writes in the wrong config file --- .../testapplet/contents/ui/ConfigGeneral.qml | 2 ++ applets/testapplet/contents/ui/main.qml | 4 ++-- .../desktop/contents/ui/Configuration.qml | 23 ++++++++++++++++--- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/applets/testapplet/contents/ui/ConfigGeneral.qml b/applets/testapplet/contents/ui/ConfigGeneral.qml index f73963ccf..033d72525 100644 --- a/applets/testapplet/contents/ui/ConfigGeneral.qml +++ b/applets/testapplet/contents/ui/ConfigGeneral.qml @@ -25,6 +25,8 @@ Item { id: iconsPage height: childrenRect.height + property alias cfg_Test: testConfigField.text + Column { anchors.fill: parent spacing: 4 diff --git a/applets/testapplet/contents/ui/main.qml b/applets/testapplet/contents/ui/main.qml index 9828d955d..1648c3e9d 100644 --- a/applets/testapplet/contents/ui/main.qml +++ b/applets/testapplet/contents/ui/main.qml @@ -64,12 +64,12 @@ Rectangle { plasmoid.busy = !plasmoid.busy } } - TextInput { + /*TextInput { width: 100 height: 22 text: plasmoid.configuration.Test onTextChanged: plasmoid.configuration.Test = text - } + }*/ } Component.onCompleted: { print("Test Applet loaded") diff --git a/qmlpackages/desktop/contents/ui/Configuration.qml b/qmlpackages/desktop/contents/ui/Configuration.qml index 5cd92caa7..82deaccc5 100644 --- a/qmlpackages/desktop/contents/ui/Configuration.qml +++ b/qmlpackages/desktop/contents/ui/Configuration.qml @@ -28,11 +28,21 @@ Rectangle { width: 640 height: 480 - function addConfigPage(url) { - print("Loading config page: " + url) - main.source = url + function saveConfig() { + for (var key in plasmoid.configuration) { + if (main.item["cfg_"+key] !== undefined) { + plasmoid.configuration[key] = main.item["cfg_"+key] + } + } } + function restoreConfig() { + for (var key in plasmoid.configuration) { + if (main.item["cfg_"+key] !== undefined) { + main.item["cfg_"+key] = plasmoid.configuration[key] + } + } + } Column { anchors.fill: parent @@ -87,6 +97,7 @@ Rectangle { } onClicked: { main.sourceComponent = configDialog.configPages[modelData].component + root.restoreConfig() } } } @@ -120,10 +131,16 @@ Rectangle { PlasmaComponents.Button { iconSource: "dialog-ok" text: "Ok" + onClicked: { + root.saveConfig() + } } PlasmaComponents.Button { iconSource: "dialog-ok-apply" text: "Apply" + onClicked: { + root.saveConfig() + } } PlasmaComponents.Button { iconSource: "dialog-cancel"