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/DevicesPage.qml
2018-02-26 00:51:23 +01:00

63 lines
1.8 KiB
QML

import QtQuick 2.8
import QtQuick.Controls 2.1
import QtQuick.Controls.Material 2.1
import Guh 1.0
import "components"
GridView {
id: interfacesGridView
property alias shownInterfaces: interfacesModel.shownInterfaces
model: InterfacesModel {
id: interfacesModel
devices: Engine.deviceManager.devices
}
property int tilesPerRow: Math.ceil(Math.sqrt(interfacesGridView.count))
cellWidth: width / tilesPerRow
cellHeight: height / tilesPerRow
delegate: Item {
width: interfacesGridView.cellWidth
height: interfacesGridView.cellHeight
Pane {
anchors.fill: parent
anchors.margins: app.margins
Material.elevation: 1
Column {
anchors.centerIn: parent
spacing: app.margins
ColorIcon {
height: app.iconSize * 2
width: height
color: app.guhAccent
anchors.horizontalCenter: parent.horizontalCenter
name: interfaceToIcon(model.name)
}
Label {
text: interfaceToString(model.name).toUpperCase()
anchors.horizontalCenter: parent.horizontalCenter
}
}
MouseArea {
anchors.fill: parent
onClicked: {
var page;
switch (model.name) {
case "light":
page = "LightsDeviceListPage.qml"
break;
default:
page = "GenericDeviceListPage.qml"
}
pageStack.push(Qt.resolvedUrl("devicelistpages/" + page), {filterInterface: model.name})
}
}
}
}
}