From cdc778f417c667e3aa12c0dc2685c383f5ab8dba Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 11 Sep 2013 17:39:09 +0200 Subject: [PATCH] test applet for config uis --- examples/applets/CMakeLists.txt | 1 + .../contents/ui/configGeneral.qml | 5 +- .../applets/config/contents/config/config.qml | 34 +++++++++++ .../applets/config/contents/config/main.xml | 25 ++++++++ .../config/contents/ui/configGeneral.qml | 57 +++++++++++++++++++ examples/applets/config/contents/ui/main.qml | 56 ++++++++++++++++++ examples/applets/config/metadata.desktop | 17 ++++++ .../qml/private/DualStateButton.qml | 1 + 8 files changed, 194 insertions(+), 2 deletions(-) create mode 100644 examples/applets/config/contents/config/config.qml create mode 100644 examples/applets/config/contents/config/main.xml create mode 100644 examples/applets/config/contents/ui/configGeneral.qml create mode 100644 examples/applets/config/contents/ui/main.qml create mode 100644 examples/applets/config/metadata.desktop diff --git a/examples/applets/CMakeLists.txt b/examples/applets/CMakeLists.txt index ef2e1ef11..ef7e80689 100644 --- a/examples/applets/CMakeLists.txt +++ b/examples/applets/CMakeLists.txt @@ -1,4 +1,5 @@ +plasma_install_package(config org.kde.example.configuration) plasma_install_package(localegallery org.kde.example.locale) plasma_install_package(widgetgallery org.kde.example.widgetgallery) plasma_install_package(qmltasks org.kde.example.tasks) diff --git a/examples/applets/conditionalloader/contents/ui/configGeneral.qml b/examples/applets/conditionalloader/contents/ui/configGeneral.qml index e7a54e1d2..63e579473 100644 --- a/examples/applets/conditionalloader/contents/ui/configGeneral.qml +++ b/examples/applets/conditionalloader/contents/ui/configGeneral.qml @@ -17,6 +17,7 @@ */ import QtQuick 2.0 +import QtQuick.Controls 1.0 as QtControls import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents @@ -36,10 +37,10 @@ Item { anchors.fill: parent spacing: 4 Row { - PlasmaComponents.Label { + QtControls.Label { text: "Text Config value" } - PlasmaComponents.TextField { + QtControls.TextField { id: testConfigField } } diff --git a/examples/applets/config/contents/config/config.qml b/examples/applets/config/contents/config/config.qml new file mode 100644 index 000000000..1cace8db4 --- /dev/null +++ b/examples/applets/config/contents/config/config.qml @@ -0,0 +1,34 @@ +/* + * Copyright 2013 Marco Martin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. + */ + +import QtQuick 2.0 + +import org.kde.plasma.configuration 2.0 + +ConfigModel { + ConfigCategory { + name: "General" + icon: "plasma" + source: "configGeneral.qml" + } + ConfigCategory { + name: "Other page" + icon: "konqueror" + source: "configSecondPage.qml" + } +} diff --git a/examples/applets/config/contents/config/main.xml b/examples/applets/config/contents/config/main.xml new file mode 100644 index 000000000..9f6f0b9ce --- /dev/null +++ b/examples/applets/config/contents/config/main.xml @@ -0,0 +1,25 @@ + + + + + + + + test + + + true + + + + + + + test2 + + + + diff --git a/examples/applets/config/contents/ui/configGeneral.qml b/examples/applets/config/contents/ui/configGeneral.qml new file mode 100644 index 000000000..15fb4e41b --- /dev/null +++ b/examples/applets/config/contents/ui/configGeneral.qml @@ -0,0 +1,57 @@ +/* + * Copyright 2013 Marco Martin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. + */ + +import QtQuick 2.0 +import QtQuick.Controls 1.0 as QtControls + +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents + + +Item { + id: iconsPage + width: childrenRect.width + height: childrenRect.height + implicitWidth: mainColumn.implicitWidth + implicitHeight: pageColumn.implicitHeight + + property alias cfg_Test: testConfigField.text + property alias cfg_TestBool: testBoolConfigField.checked + + Column { + id: pageColumn + anchors.fill: parent + spacing: 4 + Row { + QtControls.Label { + text: "Text Config value" + } + QtControls.TextField { + id: testConfigField + } + } + Row { + QtControls.Label { + text: "Bool Config value" + } + QtControls.CheckBox { + id: testBoolConfigField + } + } + } +} diff --git a/examples/applets/config/contents/ui/main.qml b/examples/applets/config/contents/ui/main.qml new file mode 100644 index 000000000..f30f42265 --- /dev/null +++ b/examples/applets/config/contents/ui/main.qml @@ -0,0 +1,56 @@ +/* + * Copyright 2013 Marco Martin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. + */ + +import QtQuick 2.1 +import QtQuick.Layouts 1.0 + +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents + +Item { + id: root + width: 100 + height: 100 + property int minimumWidth: units.gridUnit * 20 + property int minimumHeight: column.implicitHeight + + + ColumnLayout { + id: column + anchors.centerIn: parent + PlasmaComponents.Label { + anchors.horizontalCenter: parent.horizontalCenter + text: i18n("I'm an applet") + } + PlasmaComponents.TextField { + text: plasmoid.configuration.Test + onTextChanged: plasmoid.configuration.Test = text + } + PlasmaComponents.CheckBox { + enabled: true + checked: plasmoid.configuration.TestBool + text: i18n("Bool from config") + onCheckedChanged: plasmoid.configuration.TestBool = checked + } + PlasmaComponents.TextField { + text: plasmoid.configuration.OtherTest + onTextChanged: plasmoid.configuration.OtherTest = text + } + } + +} \ No newline at end of file diff --git a/examples/applets/config/metadata.desktop b/examples/applets/config/metadata.desktop new file mode 100644 index 000000000..a17ef60ad --- /dev/null +++ b/examples/applets/config/metadata.desktop @@ -0,0 +1,17 @@ +[Desktop Entry] +Encoding=UTF-8 +Keywords= +Name=Configuration test +Type=Service + +X-KDE-ServiceTypes=Plasma/Applet +X-Plasma-API=declarativeappletscript +X-KDE-ParentApp= +X-KDE-PluginInfo-Author=Marco Martin +X-KDE-PluginInfo-Category= +X-KDE-PluginInfo-Email=mart@kde.org +X-KDE-PluginInfo-License=GPLv2+ +X-KDE-PluginInfo-Name=org.kde.example.configuration +X-KDE-PluginInfo-Version= +X-KDE-PluginInfo-Website= +X-Plasma-MainScript=ui/main.qml diff --git a/src/declarativeimports/plasmacomponents/qml/private/DualStateButton.qml b/src/declarativeimports/plasmacomponents/qml/private/DualStateButton.qml index e4eb4ba43..a16fddb99 100644 --- a/src/declarativeimports/plasmacomponents/qml/private/DualStateButton.qml +++ b/src/declarativeimports/plasmacomponents/qml/private/DualStateButton.qml @@ -93,6 +93,7 @@ Item { id: label text: dualButton.text + renderType: Text.NativeRendering anchors { top: parent.top bottom: parent.bottom