From e6c42068606f2ace62519d1ed56d352c1b938f28 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Thu, 20 Apr 2023 14:16:09 +0200 Subject: [PATCH] Fix dashboard chart item for legacy charts --- .../dashboard/DashboardGraphDelegate.qml | 68 ++++++++++++------- 1 file changed, 43 insertions(+), 25 deletions(-) diff --git a/nymea-app/ui/mainviews/dashboard/DashboardGraphDelegate.qml b/nymea-app/ui/mainviews/dashboard/DashboardGraphDelegate.qml index 868c16ce..26cf1f63 100644 --- a/nymea-app/ui/mainviews/dashboard/DashboardGraphDelegate.qml +++ b/nymea-app/ui/mainviews/dashboard/DashboardGraphDelegate.qml @@ -45,35 +45,53 @@ DashboardDelegateBase { readonly property StateType stateType: thing ? thing.thingClass.stateTypes.getStateType(item.stateTypeId) : null readonly property State state: thing ? thing.states.getState(item.stateTypeId) : null - contentItem: StateChart { - id: graph + contentItem: Loader { width: root.width height: root.height - title: root.state && root.stateType ? root.thing.name + ", " + root.stateType.displayName + ": " + Types.toUiValue(root.state.value, root.stateType.unit).toFixed(0) + Types.toUiUnit(root.stateType.unit) : "" - - thing: root.thing - color: root.thing ? app.interfaceToColor(root.thing.thingClass.interfaces[0]) : Style.accentColor -// iconSource: ""// app.interfaceToIcon(interfaceName) - implicitHeight: width * .6 -// property string interfaceName: parent.interfaceName - stateType: root.stateType -// property State state: root.state - + sourceComponent: { + if (engine.jsonRpcClient.ensureServerVersion("8.0")) { + return stateChartComponent + } else { + return graphComponent + } + } } -// contentItem: GenericTypeGraph { -// id: graph -// width: root.width -// height: root.height -// title: root.state && root.stateType ? root.thing.name + " " + Types.toUiValue(root.state.value, root.stateType.unit) + Types.toUiUnit(root.stateType.unit) : "" + Component { + id: stateChartComponent + + StateChart { + id: graph + title: root.state && root.stateType ? root.thing.name + ", " + root.stateType.displayName + ": " + Types.toUiValue(root.state.value, root.stateType.unit).toFixed(0) + Types.toUiUnit(root.stateType.unit) : "" + + thing: root.thing + color: root.thing ? app.interfaceToColor(root.thing.thingClass.interfaces[0]) : Style.accentColor + // iconSource: ""// app.interfaceToIcon(interfaceName) + implicitHeight: width * .6 + // property string interfaceName: parent.interfaceName + stateType: root.stateType + // property State state: root.state + + } + } + + + Component { + id: graphComponent + + GenericTypeGraph { + id: graph + title: root.state && root.stateType ? root.thing.name + " " + Types.toUiValue(root.state.value, root.stateType.unit) + Types.toUiUnit(root.stateType.unit) : "" + + thing: root.thing + color: "blue"//app.interfaceToColor(interfaceName) + iconSource: ""// app.interfaceToIcon(interfaceName) + implicitHeight: width * .6 + // property string interfaceName: parent.interfaceName + stateType: root.stateType + property State state: root.state + } + } -// thing: root.thing -// color: "blue"//app.interfaceToColor(interfaceName) -// iconSource: ""// app.interfaceToIcon(interfaceName) -// implicitHeight: width * .6 -//// property string interfaceName: parent.interfaceName -// stateType: root.stateType -// property State state: root.state -// } }