From bbf33f69a6486729a777c770b2df3cae91bf5a84 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Sun, 21 Aug 2016 17:55:13 +0200 Subject: [PATCH] Use actions rather than visual elements --- app/qml/main.qml | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/app/qml/main.qml b/app/qml/main.qml index 010c05b94..0919c6f5b 100644 --- a/app/qml/main.qml +++ b/app/qml/main.qml @@ -31,32 +31,34 @@ Kirigami.ApplicationWindow width: 400 height: 500 + Kirigami.Action { + id: findDevicesAction + text: i18n ("Find devices...") + iconName: "list-add" + onTriggered: { + root.pageStack.clear() + root.pageStack.push("qrc:/qml/FindDevicesPage.qml"); + } + } + globalDrawer: Kirigami.GlobalDrawer { + id: drawer title: i18n("KDE Connect") titleIcon: "kdeconnect" // bannerImageSource: "/home/apol/devel/kde5/share/wallpapers/Next/contents/images/1024x768.png" - content: ListView { - anchors.fill: parent + property var objects: [findDevicesAction] + Instantiator { model: DevicesSortProxyModel { sourceModel: DevicesModel { displayFilter: DevicesModel.Paired } } - header: Kirigami.BasicListItem { - label: i18n ("Find devices...") - icon: "list-add" - onClicked: { - root.pageStack.clear() - root.pageStack.push("qrc:/qml/FindDevicesPage.qml"); - } - } - - delegate: Kirigami.BasicListItem { - width: ListView.view.width - icon: iconName - label: display + "\n" + toolTip + delegate: Kirigami.Action { + iconName: model.iconName + text: display + "\n" + toolTip enabled: status & DevicesModel.Reachable checked: root.pageStack.currentDevice == device - onClicked: { + checkable: true + onTriggered: { root.pageStack.clear() root.pageStack.push( "qrc:/qml/DevicePage.qml", @@ -64,7 +66,20 @@ Kirigami.ApplicationWindow ); } } + + onObjectAdded: { + drawer.objects.push(object) + drawer.objects = drawer.objects + } + onObjectRemoved: { + var idx = drawer.objects.indexOf(object); + if (idx>=0) { + var removed = drawer.objects.splice(idx, 1) + drawer.objects = drawer.objects + } + } } + actions: objects } contextDrawer: Kirigami.ContextDrawer {