temp commit
This commit is contained in:
parent
ef1493f0d7
commit
d54ec121dd
@ -157,6 +157,12 @@ Interfaces::Interfaces(QObject *parent) : QAbstractListModel(parent)
|
|||||||
addActionType("mediacontroller", "pause", tr("Pause playback"), new ParamTypes());
|
addActionType("mediacontroller", "pause", tr("Pause playback"), new ParamTypes());
|
||||||
addActionType("mediacontroller", "skipBack", tr("Skip back"), new ParamTypes());
|
addActionType("mediacontroller", "skipBack", tr("Skip back"), new ParamTypes());
|
||||||
addActionType("mediacontroller", "skipNext", tr("Skip next"), new ParamTypes());
|
addActionType("mediacontroller", "skipNext", tr("Skip next"), new ParamTypes());
|
||||||
|
|
||||||
|
addInterface("powersocket", tr("Power sockets"));
|
||||||
|
addStateType("powersocket", "power", QVariant::Bool, true,
|
||||||
|
tr("Powered"),
|
||||||
|
tr("Turned on/off"),
|
||||||
|
tr("Turn on/off"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int Interfaces::rowCount(const QModelIndex &parent) const
|
int Interfaces::rowCount(const QModelIndex &parent) const
|
||||||
|
|||||||
@ -58,29 +58,82 @@ Page {
|
|||||||
showStates: true
|
showStates: true
|
||||||
}
|
}
|
||||||
|
|
||||||
GridView {
|
DevicesProxy {
|
||||||
id: gridView
|
id: lightsInGroup
|
||||||
|
engine: _engine
|
||||||
|
sourceModel: devicesInGroup
|
||||||
|
filterTagId: root.groupTag
|
||||||
|
shownInterfaces: "light"
|
||||||
|
}
|
||||||
|
DevicesProxy {
|
||||||
|
id: dimmableLightsInGroup
|
||||||
|
engine: _engine
|
||||||
|
sourceModel: devicesInGroup
|
||||||
|
filterTagId: root.groupTag
|
||||||
|
shownInterfaces: "dimmablelight"
|
||||||
|
}
|
||||||
|
DevicesProxy {
|
||||||
|
id: colorLightsInGroup
|
||||||
|
engine: _engine
|
||||||
|
sourceModel: devicesInGroup
|
||||||
|
filterTagId: root.groupTag
|
||||||
|
shownInterfaces: "colorlight"
|
||||||
|
}
|
||||||
|
DevicesProxy {
|
||||||
|
id: socketsInGroup
|
||||||
|
engine: _engine
|
||||||
|
sourceModel: devicesInGroup
|
||||||
|
filterTagId: root.groupTag
|
||||||
|
shownInterfaces: "powersocket"
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: app.margins / 2
|
|
||||||
|
|
||||||
model: devicesInGroup
|
Pane {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Material.elevation: 1
|
||||||
|
RowLayout {
|
||||||
|
HeaderButton {
|
||||||
|
imageSource: "../images/powersocket.svg"
|
||||||
|
visible: socketsInGroup.count > 0
|
||||||
|
}
|
||||||
|
HeaderButton {
|
||||||
|
imageSource: "../images/light-on.svg"
|
||||||
|
visible: lightsInGroup.count > 0
|
||||||
|
}
|
||||||
|
HeaderButton {
|
||||||
|
imageSource: "../images/radiator.svg"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
readonly property int minTileWidth: 180
|
GridView {
|
||||||
readonly property int minTileHeight: 240
|
id: gridView
|
||||||
readonly property int tilesPerRow: root.width / minTileWidth
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
clip: true
|
||||||
|
|
||||||
cellWidth: gridView.width / tilesPerRow
|
model: devicesInGroup
|
||||||
cellHeight: cellWidth
|
|
||||||
|
|
||||||
delegate: ThingTile {
|
readonly property int minTileWidth: 180
|
||||||
width: gridView.cellWidth
|
readonly property int minTileHeight: 240
|
||||||
height: gridView.cellHeight
|
readonly property int tilesPerRow: root.width / minTileWidth
|
||||||
|
|
||||||
device: devicesInGroup.get(index)
|
cellWidth: gridView.width / tilesPerRow
|
||||||
|
cellHeight: cellWidth
|
||||||
|
|
||||||
onClicked: pageStack.push(Qt.resolvedUrl("../devicepages/" + app.interfaceListToDevicePage(deviceClass.interfaces)), {device: device})
|
delegate: ThingTile {
|
||||||
|
width: gridView.cellWidth
|
||||||
|
height: gridView.cellHeight
|
||||||
|
|
||||||
|
device: devicesInGroup.get(index)
|
||||||
|
|
||||||
|
onClicked: pageStack.push(Qt.resolvedUrl("../devicepages/" + app.interfaceListToDevicePage(deviceClass.interfaces)), {device: device})
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,7 +80,7 @@ MouseArea {
|
|||||||
|
|
||||||
InterfacesProxy {
|
InterfacesProxy {
|
||||||
id: controlsInGroup
|
id: controlsInGroup
|
||||||
shownInterfaces: ["light", "simpleclosable", "mediacontroller"]
|
shownInterfaces: ["light", "simpleclosable", "mediacontroller", "powersocket"]
|
||||||
devicesProxyFilter: devicesInGroup
|
devicesProxyFilter: devicesInGroup
|
||||||
showStates: true
|
showStates: true
|
||||||
showActions: true
|
showActions: true
|
||||||
@ -132,7 +132,8 @@ MouseArea {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: Math.min(controlsInGroup.count, parent.height / 50)
|
// model: Math.min(controlsInGroup.count, parent.height / 50)
|
||||||
|
model: controlsInGroup.count
|
||||||
delegate: Loader {
|
delegate: Loader {
|
||||||
id: controlLoader
|
id: controlLoader
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
@ -147,6 +148,8 @@ MouseArea {
|
|||||||
return lightDelegate
|
return lightDelegate
|
||||||
case "mediacontroller":
|
case "mediacontroller":
|
||||||
return mediaControllerDelegate
|
return mediaControllerDelegate
|
||||||
|
case "powersocket":
|
||||||
|
return powerSocketDelegate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Binding {
|
Binding {
|
||||||
@ -243,6 +246,51 @@ MouseArea {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: powerSocketDelegate
|
||||||
|
RowLayout {
|
||||||
|
property var devices
|
||||||
|
|
||||||
|
Layout.alignment: Layout.Right
|
||||||
|
|
||||||
|
DevicesProxy {
|
||||||
|
id: sockets
|
||||||
|
engine: _engine
|
||||||
|
parentProxy: devices
|
||||||
|
shownInterfaces: ["powersocket"]
|
||||||
|
}
|
||||||
|
|
||||||
|
ColorIcon {
|
||||||
|
Layout.preferredHeight: app.iconSize
|
||||||
|
Layout.preferredWidth: app.iconSize
|
||||||
|
name: "../images/powersocket.svg"
|
||||||
|
color: isOn ? app.accentColor : keyColor
|
||||||
|
|
||||||
|
property bool isOn: {
|
||||||
|
for (var i = 0; i < sockets.count; i++) {
|
||||||
|
var device = sockets.get(i)
|
||||||
|
var powerId = device.deviceClass.stateTypes.findByName("power").id
|
||||||
|
if (device.states.getState(powerId).value === true) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
for (var i = 0; i < sockets.count; i++) {
|
||||||
|
var device = sockets.get(i)
|
||||||
|
var powerId = device.deviceClass.stateTypes.findByName("power").id
|
||||||
|
engine.deviceManager.executeAction(device.id, powerId, [{paramTypeId: powerId, value: !parent.isOn}])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: lightDelegate
|
id: lightDelegate
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
|||||||
Reference in New Issue
Block a user