test applet for config uis

This commit is contained in:
Marco Martin 2013-09-11 17:39:09 +02:00
parent 6e3b20a3e6
commit cdc778f417
8 changed files with 194 additions and 2 deletions

View File

@ -1,4 +1,5 @@
plasma_install_package(config org.kde.example.configuration)
plasma_install_package(localegallery org.kde.example.locale) plasma_install_package(localegallery org.kde.example.locale)
plasma_install_package(widgetgallery org.kde.example.widgetgallery) plasma_install_package(widgetgallery org.kde.example.widgetgallery)
plasma_install_package(qmltasks org.kde.example.tasks) plasma_install_package(qmltasks org.kde.example.tasks)

View File

@ -17,6 +17,7 @@
*/ */
import QtQuick 2.0 import QtQuick 2.0
import QtQuick.Controls 1.0 as QtControls
import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.components 2.0 as PlasmaComponents
@ -36,10 +37,10 @@ Item {
anchors.fill: parent anchors.fill: parent
spacing: 4 spacing: 4
Row { Row {
PlasmaComponents.Label { QtControls.Label {
text: "Text Config value" text: "Text Config value"
} }
PlasmaComponents.TextField { QtControls.TextField {
id: testConfigField id: testConfigField
} }
} }

View File

@ -0,0 +1,34 @@
/*
* Copyright 2013 Marco Martin <mart@kde.org>
*
* 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"
}
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name=""/>
<group name="General">
<entry name="Test" type="String">
<label>This is a test</label>
<default>test</default>
</entry>
<entry name="TestBool" type="Bool">
<default>true</default>
</entry>
</group>
<group name="Group2">
<entry name="OtherTest" type="String">
<label>This is another test</label>
<default>test2</default>
</entry>
</group>
</kcfg>

View File

@ -0,0 +1,57 @@
/*
* Copyright 2013 Marco Martin <mart@kde.org>
*
* 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
}
}
}
}

View File

@ -0,0 +1,56 @@
/*
* Copyright 2013 Marco Martin <mart@kde.org>
*
* 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
}
}
}

View File

@ -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

View File

@ -93,6 +93,7 @@ Item {
id: label id: label
text: dualButton.text text: dualButton.text
renderType: Text.NativeRendering
anchors { anchors {
top: parent.top top: parent.top
bottom: parent.bottom bottom: parent.bottom