aboutsummaryrefslogtreecommitdiff
path: root/examples/unityqmlmenumodel.qml
blob: d38d6e5a9318f46b27642e20accfb5d31299ac9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

import QtQuick 2.0
import QMenuModel 0.1

Item {
    width: 400;
    height: 500;

    UnityMenuModel {
        id: menu
        busName: "com.canonical.testmenu"
        actionObjectPath: "/com/canonical/testmenu"
        menuObjectPath: "/com/canonical/testmenu"
    }

    ListView {
        anchors.fill: parent
        anchors.margins: 10
        spacing: 3
        model: menu

        delegate: Loader {
            sourceComponent: isSeparator ? separator : menuitem;

            Component {
                id: separator
                Rectangle {
                    width: parent.width
                    height: 4
                    color: "blue"
                }
            }

            Component {
                id: menuitem
                Rectangle {
                    width: parent.width
                    height: 40
                    color: "#ddd"
                    Text {
                        anchors.fill: parent
                        anchors.margins: 5
                        verticalAlignment: Text.AlignVCenter
                        color: sensitive ? "black" : "#aaa";
                        text: label
                    }
                }
            }
        }
    }
}