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.
2018-07-10 14:20:10 +02:00

89 lines
3.0 KiB
QML

import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import Nymea 1.0
import QtQuick.Controls.Material 2.2
import "../components"
Item {
id: root
readonly property int count: interfacesGridView.count
GridView {
id: interfacesGridView
anchors.fill: parent
anchors.margins: app.margins / 2
readonly property int minTileWidth: 180
readonly property int minTileHeight: 180
readonly property int tilesPerRow: root.width / minTileWidth
model: RulesFilterModel {
rules: Engine.ruleManager.rules
filterExecutable: true
}
cellWidth: width / tilesPerRow
cellHeight: Math.max(cellWidth, minTileHeight)
delegate: Item {
id: scenesDelegate
width: interfacesGridView.cellWidth
height: interfacesGridView.cellHeight
property var colorTag: Engine.tagsManager.tags.findRuleTag(model.id, "color")
property var iconTag: Engine.tagsManager.tags.findRuleTag(model.id, "icon")
Connections {
target: Engine.tagsManager.tags
onCountChanged: {
colorTag = Engine.tagsManager.tags.findRuleTag(model.id, "color")
iconTag = Engine.tagsManager.tags.findRuleTag(model.id, "icon")
}
}
Pane {
anchors.fill: parent
anchors.margins: app.margins / 2
Material.elevation: 1
MouseArea {
anchors.fill: parent
onClicked: {
Engine.ruleManager.executeActions(model.id)
}
}
ColumnLayout {
width: parent.width
anchors.centerIn: parent
spacing: app.margins
ColorIcon {
Layout.preferredHeight: app.iconSize * 2
Layout.preferredWidth: height
Layout.alignment: Qt.AlignHCenter
name: scenesDelegate.iconTag ? "../images/" + scenesDelegate.iconTag.value + ".svg" : "../images/slideshow.svg";
color: scenesDelegate.colorTag ? scenesDelegate.colorTag.value : app.guhAccent;
ColorIcon {
anchors.fill: parent
name: "../images/slideshow.svg"
color: app.guhAccent
visible: parent.status === Image.Error
}
}
Label {
Layout.fillWidth: true
text: model.name
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
maximumLineCount: 2
elide: Text.ElideRight
}
}
}
}
}
}