add all up button for blinds on main page
This commit is contained in:
parent
e5f3ff4f3f
commit
2c29947c96
@ -91,6 +91,7 @@ MainPageTile {
|
|||||||
Label {
|
Label {
|
||||||
id: label
|
id: label
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
visible: text != ""
|
||||||
text: {
|
text: {
|
||||||
switch (model.name) {
|
switch (model.name) {
|
||||||
case "media":
|
case "media":
|
||||||
@ -123,121 +124,234 @@ MainPageTile {
|
|||||||
case "extendedawning":
|
case "extendedawning":
|
||||||
case "shutter":
|
case "shutter":
|
||||||
case "extendedshutter":
|
case "extendedshutter":
|
||||||
return qsTr("%1 installed").arg(devicesProxy.count)
|
return ""
|
||||||
|
// return qsTr("%1 installed").arg(devicesProxy.count)
|
||||||
}
|
}
|
||||||
console.warn("DevicesPageDelegate, inlineButtonControl: Unhandled interface", model.name)
|
console.warn("DevicesPageDelegate, inlineButtonControl: Unhandled interface", model.name)
|
||||||
}
|
}
|
||||||
font.pixelSize: app.smallFont
|
font.pixelSize: app.smallFont
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
}
|
}
|
||||||
ItemDelegate {
|
RowLayout {
|
||||||
Layout.preferredHeight: app.iconSize
|
// Layout.alignment: Qt.AlignRight
|
||||||
Layout.preferredWidth: height
|
Layout.fillWidth: true
|
||||||
Layout.alignment: Qt.AlignRight
|
spacing: (parent.width - app.iconSize * 3) / 2
|
||||||
|
|
||||||
ColorIcon {
|
ItemDelegate {
|
||||||
id: icon
|
Layout.preferredHeight: app.iconSize
|
||||||
width: app.iconSize
|
Layout.preferredWidth: height
|
||||||
height: width
|
|
||||||
color: app.accentColor
|
|
||||||
|
|
||||||
name: {
|
ColorIcon {
|
||||||
|
id: leftIcon
|
||||||
|
width: app.iconSize
|
||||||
|
height: width
|
||||||
|
color: app.accentColor
|
||||||
|
|
||||||
|
name: {
|
||||||
|
switch (model.name) {
|
||||||
|
case "media":
|
||||||
|
case "light":
|
||||||
|
return ""
|
||||||
|
case "garagegate":
|
||||||
|
case "blind":
|
||||||
|
case "extendedblind":
|
||||||
|
case "awning":
|
||||||
|
case "extendedawning":
|
||||||
|
case "shutter":
|
||||||
|
case "extendedshutter":
|
||||||
|
return "../images/up.svg"
|
||||||
|
default:
|
||||||
|
console.warn("DevicesPageDelegate, inlineButtonControl image: Unhandled interface", model.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
switch (model.name) {
|
switch (model.name) {
|
||||||
|
case "light":
|
||||||
|
case "media":
|
||||||
|
break;
|
||||||
|
case "garagegate":
|
||||||
|
case "shutter":
|
||||||
|
case "extendedshutter":
|
||||||
|
case "blind":
|
||||||
|
case "extendedblind":
|
||||||
|
case "awning":
|
||||||
|
case "extendedawning":
|
||||||
|
case "simpleclosable":
|
||||||
|
for (var i = 0; i < devicesProxy.count; i++) {
|
||||||
|
var device = devicesProxy.get(i);
|
||||||
|
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
|
||||||
|
var actionType = deviceClass.actionTypes.findByName("open");
|
||||||
|
engine.deviceManager.executeAction(device.id, actionType.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
console.warn("DevicesPageDelegate, inlineButtonControl clicked: Unhandled interface", model.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemDelegate {
|
||||||
|
Layout.preferredHeight: app.iconSize
|
||||||
|
Layout.preferredWidth: height
|
||||||
|
ColorIcon {
|
||||||
|
id: centerIcon
|
||||||
|
width: app.iconSize
|
||||||
|
height: width
|
||||||
|
color: app.accentColor
|
||||||
|
|
||||||
|
name: {
|
||||||
|
switch (model.name) {
|
||||||
|
case "media":
|
||||||
|
case "light":
|
||||||
|
return ""
|
||||||
|
case "garagegate":
|
||||||
|
case "blind":
|
||||||
|
case "extendedblind":
|
||||||
|
case "awning":
|
||||||
|
case "extendedawning":
|
||||||
|
case "shutter":
|
||||||
|
case "extendedshutter":
|
||||||
|
return "../images/media-playback-stop.svg"
|
||||||
|
default:
|
||||||
|
console.warn("DevicesPageDelegate, inlineButtonControl image: Unhandled interface", model.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
switch (model.name) {
|
||||||
|
case "light":
|
||||||
|
case "media":
|
||||||
|
break;
|
||||||
|
case "garagegate":
|
||||||
|
case "shutter":
|
||||||
|
case "extendedshutter":
|
||||||
|
case "blind":
|
||||||
|
case "extendedblind":
|
||||||
|
case "awning":
|
||||||
|
case "extendedawning":
|
||||||
|
case "simpleclosable":
|
||||||
|
for (var i = 0; i < devicesProxy.count; i++) {
|
||||||
|
var device = devicesProxy.get(i);
|
||||||
|
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
|
||||||
|
var actionType = deviceClass.actionTypes.findByName("stop");
|
||||||
|
engine.deviceManager.executeAction(device.id, actionType.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
console.warn("DevicesPageDelegate, inlineButtonControl clicked: Unhandled interface", model.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemDelegate {
|
||||||
|
Layout.preferredHeight: app.iconSize
|
||||||
|
Layout.preferredWidth: height
|
||||||
|
|
||||||
|
ColorIcon {
|
||||||
|
id: icon
|
||||||
|
width: app.iconSize
|
||||||
|
height: width
|
||||||
|
color: app.accentColor
|
||||||
|
|
||||||
|
name: {
|
||||||
|
switch (model.name) {
|
||||||
|
case "media":
|
||||||
|
var device = devicesProxy.get(0)
|
||||||
|
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
|
||||||
|
var stateType = deviceClass.stateTypes.findByName("playbackStatus");
|
||||||
|
var state = device.states.getState(stateType.id)
|
||||||
|
return state.value === "Playing" ? "../images/media-playback-pause.svg" :
|
||||||
|
state.value === "PAUSED" ? "../images/media-playback-start.svg" :
|
||||||
|
""
|
||||||
|
case "light":
|
||||||
|
return "../images/system-shutdown.svg"
|
||||||
|
case "garagegate":
|
||||||
|
case "blind":
|
||||||
|
case "extendedblind":
|
||||||
|
case "awning":
|
||||||
|
case "extendedawning":
|
||||||
|
case "shutter":
|
||||||
|
case "extendedshutter":
|
||||||
|
return "../images/down.svg"
|
||||||
|
default:
|
||||||
|
console.warn("DevicesPageDelegate, inlineButtonControl image: Unhandled interface", model.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
switch (model.name) {
|
||||||
|
case "light":
|
||||||
|
if (devicesProxy.count == 1) {
|
||||||
|
var device = devicesProxy.get(0);
|
||||||
|
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
|
||||||
|
var stateType = deviceClass.stateTypes.findByName("power")
|
||||||
|
var actionType = deviceClass.actionTypes.findByName("power")
|
||||||
|
var params = [];
|
||||||
|
var param1 = {};
|
||||||
|
param1["paramTypeId"] = actionType.paramTypes.get(0).id;
|
||||||
|
param1["value"] = !device.states.getState(stateType.id).value;
|
||||||
|
params.push(param1)
|
||||||
|
engine.deviceManager.executeAction(device.id, actionType.id, params)
|
||||||
|
} else {
|
||||||
|
for (var i = 0; i < devicesProxy.count; i++) {
|
||||||
|
var device = devicesProxy.get(i);
|
||||||
|
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
|
||||||
|
var actionType = deviceClass.actionTypes.findByName("power");
|
||||||
|
|
||||||
|
var params = [];
|
||||||
|
var param1 = {};
|
||||||
|
param1["paramTypeId"] = actionType.paramTypes.get(0).id;
|
||||||
|
param1["value"] = false;
|
||||||
|
params.push(param1)
|
||||||
|
engine.deviceManager.executeAction(device.id, actionType.id, params)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "media":
|
case "media":
|
||||||
var device = devicesProxy.get(0)
|
var device = devicesProxy.get(0)
|
||||||
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
|
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
|
||||||
var stateType = deviceClass.stateTypes.findByName("playbackStatus");
|
var stateType = deviceClass.stateTypes.findByName("playbackStatus");
|
||||||
var state = device.states.getState(stateType.id)
|
var state = device.states.getState(stateType.id)
|
||||||
return state.value === "Playing" ? "../images/media-playback-pause.svg" :
|
|
||||||
state.value === "PAUSED" ? "../images/media-playback-start.svg" :
|
var actionName
|
||||||
""
|
switch (state.value) {
|
||||||
case "light":
|
case "Playing":
|
||||||
return "../images/system-shutdown.svg"
|
actionName = "pause";
|
||||||
|
break;
|
||||||
|
case "Paused":
|
||||||
|
actionName = "play";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
var actionTypeId = deviceClass.actionTypes.findByName(actionName).id;
|
||||||
|
|
||||||
|
print("executing", device, device.id, actionTypeId, actionName, deviceClass.actionTypes)
|
||||||
|
|
||||||
|
engine.deviceManager.executeAction(device.id, actionTypeId)
|
||||||
case "garagegate":
|
case "garagegate":
|
||||||
|
case "shutter":
|
||||||
|
case "extendedshutter":
|
||||||
case "blind":
|
case "blind":
|
||||||
case "extendedblind":
|
case "extendedblind":
|
||||||
case "awning":
|
case "awning":
|
||||||
case "extendedawning":
|
case "extendedawning":
|
||||||
case "shutter":
|
case "simpleclosable":
|
||||||
case "extendedshutter":
|
|
||||||
return "../images/down.svg"
|
|
||||||
default:
|
|
||||||
console.warn("DevicesPageDelegate, inlineButtonControl image: Unhandled interface", model.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
switch (model.name) {
|
|
||||||
case "light":
|
|
||||||
if (devicesProxy.count == 1) {
|
|
||||||
var device = devicesProxy.get(0);
|
|
||||||
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
|
|
||||||
var stateType = deviceClass.stateTypes.findByName("power")
|
|
||||||
var actionType = deviceClass.actionTypes.findByName("power")
|
|
||||||
var params = [];
|
|
||||||
var param1 = {};
|
|
||||||
param1["paramTypeId"] = actionType.paramTypes.get(0).id;
|
|
||||||
param1["value"] = !device.states.getState(stateType.id).value;
|
|
||||||
params.push(param1)
|
|
||||||
engine.deviceManager.executeAction(device.id, actionType.id, params)
|
|
||||||
} else {
|
|
||||||
for (var i = 0; i < devicesProxy.count; i++) {
|
for (var i = 0; i < devicesProxy.count; i++) {
|
||||||
var device = devicesProxy.get(i);
|
var device = devicesProxy.get(i);
|
||||||
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
|
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
|
||||||
var actionType = deviceClass.actionTypes.findByName("power");
|
var actionType = deviceClass.actionTypes.findByName("close");
|
||||||
|
engine.deviceManager.executeAction(device.id, actionType.id)
|
||||||
var params = [];
|
|
||||||
var param1 = {};
|
|
||||||
param1["paramTypeId"] = actionType.paramTypes.get(0).id;
|
|
||||||
param1["value"] = false;
|
|
||||||
params.push(param1)
|
|
||||||
engine.deviceManager.executeAction(device.id, actionType.id, params)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
console.warn("DevicesPageDelegate, inlineButtonControl clicked: Unhandled interface", model.name)
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case "media":
|
|
||||||
var device = devicesProxy.get(0)
|
|
||||||
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
|
|
||||||
var stateType = deviceClass.stateTypes.findByName("playbackStatus");
|
|
||||||
var state = device.states.getState(stateType.id)
|
|
||||||
|
|
||||||
var actionName
|
|
||||||
switch (state.value) {
|
|
||||||
case "Playing":
|
|
||||||
actionName = "pause";
|
|
||||||
break;
|
|
||||||
case "Paused":
|
|
||||||
actionName = "play";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
var actionTypeId = deviceClass.actionTypes.findByName(actionName).id;
|
|
||||||
|
|
||||||
print("executing", device, device.id, actionTypeId, actionName, deviceClass.actionTypes)
|
|
||||||
|
|
||||||
engine.deviceManager.executeAction(device.id, actionTypeId)
|
|
||||||
case "garagegate":
|
|
||||||
case "shutter":
|
|
||||||
case "extendedshutter":
|
|
||||||
case "blind":
|
|
||||||
case "extendedblind":
|
|
||||||
case "awning":
|
|
||||||
case "extendedawning":
|
|
||||||
case "simpleclosable":
|
|
||||||
for (var i = 0; i < devicesProxy.count; i++) {
|
|
||||||
var device = devicesProxy.get(i);
|
|
||||||
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
|
|
||||||
var actionType = deviceClass.actionTypes.findByName("close");
|
|
||||||
engine.deviceManager.executeAction(device.id, actionType.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
console.warn("DevicesPageDelegate, inlineButtonControl clicked: Unhandled interface", model.name)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user