This repository has been archived on 2026-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
powersync-app/guh-control/ui/magic/SelectThingPage.qml
2018-02-25 16:03:04 +01:00

57 lines
1.5 KiB
QML

import QtQuick 2.6
import QtQuick.Layouts 1.2
import QtQuick.Controls 2.1
import "../components"
import Guh 1.0
Page {
id: root
signal backPressed();
signal thingSelected(var device);
signal interfaceSelected(string interfaceName);
header: GuhHeader {
text: "Select a thing"
onBackPressed: root.backPressed()
}
ColumnLayout {
anchors.fill: parent
RowLayout {
Layout.fillWidth: true
RadioButton {
id: thingButton
text: "A specific thing"
checked: true
}
RadioButton {
id: interfacesButton
text: "A group of things"
}
}
Interfaces {
id: interfacesModel
}
ListView {
Layout.fillWidth: true
Layout.fillHeight: true
model: thingButton.checked ? Engine.deviceManager.devices : interfacesModel
clip: true
delegate: ItemDelegate {
text: thingButton.checked ? model.name : model.displayName
width: parent.width
onClicked: {
if (thingButton.checked) {
root.thingSelected(Engine.deviceManager.devices.get(index))
} else {
root.interfaceSelected(interfacesModel.get(index).name)
}
}
}
}
}
}