Use actions rather than visual elements
This commit is contained in:
parent
aef02c0cce
commit
bbf33f69a6
1 changed files with 31 additions and 16 deletions
|
@ -31,32 +31,34 @@ Kirigami.ApplicationWindow
|
||||||
width: 400
|
width: 400
|
||||||
height: 500
|
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 {
|
globalDrawer: Kirigami.GlobalDrawer {
|
||||||
|
id: drawer
|
||||||
title: i18n("KDE Connect")
|
title: i18n("KDE Connect")
|
||||||
titleIcon: "kdeconnect"
|
titleIcon: "kdeconnect"
|
||||||
// bannerImageSource: "/home/apol/devel/kde5/share/wallpapers/Next/contents/images/1024x768.png"
|
// bannerImageSource: "/home/apol/devel/kde5/share/wallpapers/Next/contents/images/1024x768.png"
|
||||||
|
|
||||||
content: ListView {
|
property var objects: [findDevicesAction]
|
||||||
anchors.fill: parent
|
Instantiator {
|
||||||
model: DevicesSortProxyModel {
|
model: DevicesSortProxyModel {
|
||||||
sourceModel: DevicesModel { displayFilter: DevicesModel.Paired }
|
sourceModel: DevicesModel { displayFilter: DevicesModel.Paired }
|
||||||
}
|
}
|
||||||
header: Kirigami.BasicListItem {
|
delegate: Kirigami.Action {
|
||||||
label: i18n ("Find devices...")
|
iconName: model.iconName
|
||||||
icon: "list-add"
|
text: display + "\n" + toolTip
|
||||||
onClicked: {
|
|
||||||
root.pageStack.clear()
|
|
||||||
root.pageStack.push("qrc:/qml/FindDevicesPage.qml");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: Kirigami.BasicListItem {
|
|
||||||
width: ListView.view.width
|
|
||||||
icon: iconName
|
|
||||||
label: display + "\n" + toolTip
|
|
||||||
enabled: status & DevicesModel.Reachable
|
enabled: status & DevicesModel.Reachable
|
||||||
checked: root.pageStack.currentDevice == device
|
checked: root.pageStack.currentDevice == device
|
||||||
onClicked: {
|
checkable: true
|
||||||
|
onTriggered: {
|
||||||
root.pageStack.clear()
|
root.pageStack.clear()
|
||||||
root.pageStack.push(
|
root.pageStack.push(
|
||||||
"qrc:/qml/DevicePage.qml",
|
"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 {
|
contextDrawer: Kirigami.ContextDrawer {
|
||||||
|
|
Loading…
Reference in a new issue