diff options
author | Lars Uebernickel <lars.uebernickel@canonical.com> | 2013-06-04 15:42:16 -0400 |
---|---|---|
committer | Lars Uebernickel <lars.uebernickel@canonical.com> | 2013-06-04 15:42:16 -0400 |
commit | b1009a800f4e64b17e19e578deedaf0c9bd18902 (patch) | |
tree | 45d0713b90bfb89f76105af0cbf77ae2434c4d4b /examples | |
parent | 550306421fa0ece045d3e8930fdc7f135fe70c47 (diff) | |
download | qmenumodel-b1009a800f4e64b17e19e578deedaf0c9bd18902.tar.gz qmenumodel-b1009a800f4e64b17e19e578deedaf0c9bd18902.tar.bz2 qmenumodel-b1009a800f4e64b17e19e578deedaf0c9bd18902.zip |
Add qml example for UnityMenuModel
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/exportmenu.py | 6 | ||||
-rw-r--r-- | examples/unityqmlmenumodel.qml | 34 |
2 files changed, 39 insertions, 1 deletions
diff --git a/examples/exportmenu.py b/examples/exportmenu.py index 4be3deb..767d8b9 100755 --- a/examples/exportmenu.py +++ b/examples/exportmenu.py @@ -54,7 +54,7 @@ if __name__ == '__main__': GLib.Variant.new_string('lorem ipsum')) foo.set_attribute_value('x-enabled', GLib.Variant.new_boolean(True)) menu.append_item(foo) - bar = Gio.MenuItem.new('bar', 'app.bar') + bar = Gio.MenuItem.new('bar', 'bar') bar.set_attribute_value('x-defaultvalue', GLib.Variant.new_string('Hello World!')) bar.set_attribute_value('x-canonical-currentvalue', @@ -74,5 +74,9 @@ if __name__ == '__main__': menu.append('baz', 'app.baz') bus.export_menu_model(BUS_OBJECT_PATH, menu) + actions = Gio.SimpleActionGroup.new() + actions.add_action(Gio.SimpleAction.new("bar", None)) + bus.export_action_group(BUS_OBJECT_PATH, actions) + GLib.MainLoop().run() diff --git a/examples/unityqmlmenumodel.qml b/examples/unityqmlmenumodel.qml new file mode 100644 index 0000000..257866d --- /dev/null +++ b/examples/unityqmlmenumodel.qml @@ -0,0 +1,34 @@ + +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: Rectangle { + width: parent.width + height: 40 + color: "#ddd" + Text { + anchors.fill: parent + anchors.margins: 5 + verticalAlignment: Text.AlignVCenter + color: sensitive ? "black" : "#aaa"; + text: label + } + } + } +} |