a mechanism for the toggle action

This commit is contained in:
Marco Martin 2015-04-11 17:03:37 +02:00
parent 7263c9ac15
commit 129adccee6
2 changed files with 16 additions and 4 deletions

View file

@ -42,7 +42,13 @@ RowLayout {
MouseArea {
id: iconMouseArea
anchors.fill: parent
onClicked: print("action of mouse area")
onClicked: {
if (model.toggleFunction) {
root[model.toggleFunction]();
} else if (model.settingsCommand) {
plasmoid.nativeInterface.executeCommand(model.settingsCommand);
}
}
}
}
}
@ -64,6 +70,8 @@ RowLayout {
onClicked: {
if (model.settingsCommand) {
plasmoid.nativeInterface.executeCommand(model.settingsCommand);
} else if (model.toggleFunction) {
root[model.toggleFunction]();
}
}
}

View file

@ -25,10 +25,12 @@ import org.kde.plasma.plasmoid 2.0
Item {
id: bigClock
id: root
function toggleAirplane() {
print("toggle airplane mode")
}
/*Layout.minimumWidth: implicitWidth
Layout.minimumHeight: implicitHeight*/
Plasmoid.preferredRepresentation: plasmoid.fullRepresentation
ListModel {
@ -39,6 +41,7 @@ Item {
icon: "configure"
enabled: false
settingsCommand: "active-settings"
toggleFunction: ""
}
ListElement {
text: "Mobile network"
@ -51,6 +54,7 @@ Item {
icon: "flightmode-on"
enabled: false
settingsCommand: ""
toggleFunction: "toggleAirplane"
}
ListElement {
text: "Bluetooth"