aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2013-07-25 06:28:54 +0200
committerLars Uebernickel <lars.uebernickel@canonical.com>2013-07-25 06:28:54 +0200
commit192e9c85e6d7441a6115d1ead859b8449cfb07ec (patch)
treeb13342b9cf56b062a15cc5670109f3c607039404
parentca81974f1fe8454c725e80aa943705d40398a2ad (diff)
downloadqmenumodel-192e9c85e6d7441a6115d1ead859b8449cfb07ec.tar.gz
qmenumodel-192e9c85e6d7441a6115d1ead859b8449cfb07ec.tar.bz2
qmenumodel-192e9c85e6d7441a6115d1ead859b8449cfb07ec.zip
examples/unitymenumodel.qml: update to newest API
-rw-r--r--examples/unityqmlmenumodel.qml55
1 files changed, 46 insertions, 9 deletions
diff --git a/examples/unityqmlmenumodel.qml b/examples/unityqmlmenumodel.qml
index a66ba8e..5dcb1ff 100644
--- a/examples/unityqmlmenumodel.qml
+++ b/examples/unityqmlmenumodel.qml
@@ -8,9 +8,9 @@ Item {
UnityMenuModel {
id: menu
- busName: "com.canonical.testmenu"
- actionObjectPath: "/com/canonical/testmenu"
- menuObjectPath: "/com/canonical/testmenu"
+ busName: "com.canonical.indicator.sound"
+ actions: { "indicator": "/com/canonical/indicator/sound" }
+ menuObjectPath: "/com/canonical/indicator/sound/desktop"
}
ListView {
@@ -21,7 +21,19 @@ Item {
model: menu
delegate: Loader {
- sourceComponent: isSeparator ? separator : menuitem;
+ sourceComponent: {
+ if (isSeparator) {
+ return separator;
+ }
+ else if (type == "com.canonical.unity.slider") {
+ listview.model.loadExtendedAttributes(index, {'min-icon': 'icon',
+ 'max-icon': 'icon'});
+ return slider;
+ }
+ else {
+ return menuitem;
+ }
+ }
Component {
id: separator
@@ -33,21 +45,46 @@ Item {
}
Component {
+ id: slider
+ Row {
+ anchors.fill: parent
+ Image {
+ source: ext.minIcon
+ }
+ Image {
+ source: ext.maxIcon
+ }
+ }
+ }
+
+ Component {
id: menuitem
Rectangle {
width: listview.width
height: 40
color: "#ddd"
- Text {
+ Row {
anchors.fill: parent
anchors.margins: 5
- verticalAlignment: Text.AlignVCenter
- color: sensitive ? "black" : "#aaa";
- text: label
+ Image {
+ source: icon
+ }
+ Text {
+ height: parent.height
+ verticalAlignment: Text.AlignVCenter
+ color: sensitive ? "black" : "#aaa";
+ text: label
+ }
}
MouseArea {
anchors.fill: parent
- onClicked: listview.model.activate(index);
+ onClicked: {
+ var submenu = listview.model.submenu(index);
+ if (submenu)
+ listview.model = submenu;
+ else
+ listview.model.activate(index);
+ }
}
}
}