some tunings in the heating experience

This commit is contained in:
Michael Zanetti 2019-03-08 17:44:04 +01:00
parent ae0a3279ec
commit 2b42b20a24
9 changed files with 178 additions and 134 deletions

View File

@ -137,7 +137,7 @@ Connection *NymeaConnection::currentConnection() const
void NymeaConnection::sendData(const QByteArray &data)
{
if (connected()) {
// qDebug() << "sending data:" << data;
qDebug() << "sending data:" << data;
m_currentTransport->sendData(data);
} else {
qWarning() << "Connection: Not connected. Cannot send.";

View File

@ -5,13 +5,27 @@ Item {
implicitHeight: app.iconSize * .8
implicitWidth: height
property bool on: false
// TODO: Convert to enum once we have Qt 5.10
// on, off, green, orange, red
property string state: "off"
Rectangle {
height: Math.min(parent.height, parent.height)
width: height
radius: width / 2
color: root.on ? "lightgreen" : "lightgray"
color: {
switch (root.state) {
case "on":
case "green":
return "#91dd77";
case "off":
return "lightgray";
case "orange":
return "#dddd77";
case "red":
return "#dd7777"
}
}
border.width: 1
border.color: app.foregroundColor
}

View File

@ -57,7 +57,7 @@ Item {
Led {
visible: root.stateType.type.toLowerCase() === "bool"
on: root.valueState.value === true
state: root.valueState.value === true ? "on" : "off"
}
Label {

View File

@ -7,5 +7,5 @@ import "../../components"
Led {
property bool value
on: value === true
state: value === true ? "on" : "off"
}

View File

@ -118,7 +118,7 @@ DeviceListPageBase {
Led {
id: led
visible: sensorValueDelegate.stateType && sensorValueDelegate.stateType.type.toLowerCase() == "bool"
on: visible && sensorValueDelegate.stateValue.value === true
state: visible && sensorValueDelegate.stateValue.value === true ? "on" : "off"
}
Item {
Layout.preferredWidth: led.width

View File

@ -268,7 +268,7 @@ Page {
property var value
Led {
implicitHeight: app.smallFont
on: boolLed.value === "true"
state: boolLed.value === "true" ? "on" : "off"
}
}
}

View File

@ -16,7 +16,9 @@ Item {
readonly property State temperatureState: duwWpDevice ? duwWpDevice.states.getState(duwWpDevice.deviceClass.stateTypes.findByName("temperature").id) : null
readonly property State targetTemperatureState: duwWpDevice ? duwWpDevice.states.getState(duwWpDevice.deviceClass.stateTypes.findByName("targetTemperature").id) : null
readonly property State co2LevelState: duwLuDevice ? duwLuDevice.states.getState(duwLuDevice.deviceClass.stateTypes.findByName("co2").id) : null
readonly property State ventilationModeState: duwLuDevice ? duwLuDevice.states.getState(duwLuDevice.deviceClass.stateTypes.findByName("ventilationMode").id) : null
readonly property State ventilationLevelState: duwLuDevice ? duwLuDevice.states.getState(duwLuDevice.deviceClass.stateTypes.findByName("activeVentilationLevel").id) : null
function ventilationModeToSliderValue(ventilationMode) {
switch (ventilationMode) {
@ -135,149 +137,177 @@ Item {
anchors.fill: parent
anchors.margins: app.margins
RowLayout {
spacing: app.margins
ColorIcon {
Layout.preferredHeight: app.iconSize
Layout.preferredWidth: app.iconSize
name: "qrc:/ui/images/weathericons/wind.svg"
color: app.accentColor
}
Led {
}
}
ColumnLayout {
Label {
text: qsTr("Current temperature")
font.pixelSize: app.smallFont
}
RowLayout {
ColorIcon {
Layout.preferredHeight: app.iconSize
Layout.preferredWidth: app.iconSize
name: "qrc:/ui/images/sensors/temperature.svg"
color: app.accentColor
RowLayout {
spacing: app.margins
ColorIcon {
Layout.preferredHeight: app.iconSize
Layout.preferredWidth: app.iconSize
name: "qrc:/ui/images/weathericons/wind.svg"
color: app.accentColor
}
Led {
state: {
if (!root.co2LevelState) {
return "off"
}
if (root.co2LevelState.value < 900) {
return "green"
}
if (root.co2LevelState.value < 2000) {
return "orange"
}
return "red"
}
}
}
Label {
text: root.temperatureState ? root.temperatureState.value.toFixed(1) + "°C" : "N/A"
Layout.fillWidth: true
font.pixelSize: app.largeFont * 2
}
}
Item {
Layout.preferredHeight: app.margins * 2
Layout.fillWidth: true
}
Label {
text: qsTr("Temperature, °C")
font.pixelSize: app.largeFont
}
Label {
text: (d.pendingCallId !== -1 || d.setTempPending) ? d.queuedTargetTemp.toFixed(1) :
root.targetTemperatureState ? root.targetTemperatureState.value.toFixed(1) : "N/A"
font.pixelSize: app.largeFont * 4
}
Item {
Layout.preferredHeight: app.margins * 2
Layout.fillWidth: true
}
ColorIcon {
Layout.preferredHeight: app.iconSize * 1.5
Layout.preferredWidth: height
Layout.leftMargin: width
color: app.accentColor
name: "qrc:/ui/images/share.svg"
}
Label {
text: qsTr("Automate this thing")
color: app.accentColor
font.pixelSize: app.smallFont
}
Item {
Layout.fillWidth: true
Layout.fillHeight: true
}
RowLayout {
Layout.leftMargin: parent.width * .05
Layout.rightMargin: parent.width * .2
spacing: app.margins
ColorIcon {
Layout.preferredHeight: app.iconSize
Layout.preferredWidth: app.iconSize
color: app.accentColor
name: "qrc:/ui/images/ventilation.svg"
text: qsTr("Current temperature")
font.pixelSize: app.smallFont
}
RowLayout {
Layout.fillWidth: true
Layout.maximumHeight: app.iconSize
spacing: 0
ColorIcon {
Layout.preferredHeight: app.iconSize
Layout.preferredWidth: app.iconSize
name: "qrc:/ui/images/sensors/temperature.svg"
color: app.accentColor
}
Label {
text: root.temperatureState ? root.temperatureState.value.toFixed(1) + "°C" : "N/A"
Layout.fillWidth: true
font.pixelSize: app.largeFont * 2
}
}
}
Repeater {
model: ListModel {
ListElement { text: qsTr("Auto") }
ListElement { text: qsTr("Party") }
ListElement { text: qsTr("Manual") }
}
ColumnLayout {
Rectangle {
Layout.fillWidth: true
Layout.fillHeight: true
border.width: 1
border.color: app.accentColor
color: root.ventilationModeState && root.ventilationModeToUiMode(root.ventilationModeState.value) === index ? app.accentColor : "transparent"
Label {
anchors.centerIn: parent
text: model.text
font.pixelSize: app.smallFont
Label {
text: qsTr("Temperature, °C")
font.pixelSize: app.largeFont
}
Label {
text: (d.pendingCallId !== -1 || d.setTempPending) ? d.queuedTargetTemp.toFixed(1) :
root.targetTemperatureState ? root.targetTemperatureState.value.toFixed(1) : "N/A"
font.pixelSize: app.largeFont * 4
}
}
ColumnLayout {
Layout.fillWidth: false
ColorIcon {
Layout.preferredHeight: app.iconSize * 1.5
Layout.preferredWidth: height
Layout.alignment: Qt.AlignHCenter
color: app.accentColor
name: "qrc:/ui/images/share.svg"
MouseArea {
anchors.fill: parent
onClicked: pageStack.push("qrc:/ui/magic/DeviceRulesPage.qml", {device: root.duwWpDevice})
}
}
Label {
text: qsTr("Automate this thing")
color: app.accentColor
font.pixelSize: app.smallFont
}
}
ColumnLayout {
RowLayout {
Layout.leftMargin: parent.width * .05
Layout.rightMargin: parent.width * .2
spacing: app.margins
ColorIcon {
Layout.preferredHeight: app.iconSize
Layout.preferredWidth: app.iconSize
color: app.accentColor
name: "qrc:/ui/images/ventilation.svg"
PropertyAnimation on rotation {
running: root.ventilationLevelState !== null
duration: root.ventilationLevelState !== null && root.ventilationLevelState.value > 0
? 2000 / root.ventilationLevelState.value
: 0
from: 360
to: 0
loops: Animation.Infinite
onDurationChanged: {
running = false;
running = true;
}
MouseArea {
anchors.fill: parent
onClicked: {
root.setVentilationMode(index, ventilationSlider.value)
}
}
RowLayout {
Layout.fillWidth: true
Layout.maximumHeight: app.iconSize
spacing: 0
Repeater {
model: ListModel {
ListElement { text: qsTr("Auto") }
ListElement { text: qsTr("Party") }
ListElement { text: qsTr("Manual") }
}
Rectangle {
Layout.fillWidth: true
Layout.fillHeight: true
border.width: 1
border.color: app.accentColor
color: root.ventilationModeState && root.ventilationModeToUiMode(root.ventilationModeState.value) === index ? app.accentColor : "transparent"
Label {
anchors.centerIn: parent
text: model.text
font.pixelSize: app.smallFont
}
MouseArea {
anchors.fill: parent
onClicked: {
root.setVentilationMode(index, ventilationSlider.value)
}
}
}
}
}
}
Slider {
id: ventilationSlider
Layout.fillWidth: true
Layout.leftMargin: parent.width * .05
Layout.rightMargin: parent.width * .05
from: 0
to: 3
stepSize: 1
live: false
snapMode: Slider.SnapAlways
enabled: root.ventilationModeState && root.ventilationModeToUiMode(root.ventilationModeState.value) === 2
opacity: enabled ? 1 : .2
value: root.ventilationModeState ? root.ventilationModeToSliderValue(root.ventilationModeState.value) : 0
onMoved: root.setVentilationMode(2, valueAt(visualPosition))
}
}
Slider {
id: ventilationSlider
Layout.fillWidth: true
Layout.leftMargin: parent.width * .05
Layout.rightMargin: parent.width * .05
from: 0
to: 4
stepSize: 1
live: false
snapMode: Slider.SnapAlways
enabled: root.ventilationModeState && root.ventilationModeToUiMode(root.ventilationModeState.value) === 2
opacity: enabled ? 1 : .2
value: root.ventilationModeState ? root.ventilationModeToSliderValue(root.ventilationModeState.value) : 0
onMoved: root.setVentilationMode(2, ventilationSlider.value)
}
// ProgressButton {
// imageSource: "qrc:/ui/images/system-shutdown.svg"
// Layout.preferredHeight: app.iconSize * 1.5
// Layout.preferredWidth: height
// Layout.alignment: Qt.AlignHCenter
// }
ProgressButton {
imageSource: "qrc:/ui/images/system-shutdown.svg"
Layout.preferredHeight: app.iconSize * 1.5
Layout.preferredWidth: height
Layout.alignment: Qt.AlignHCenter
}
Label {
text: qsTr("Hold to turn off")
font.pixelSize: app.smallFont
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
}
// Label {
// text: qsTr("Hold to turn off")
// font.pixelSize: app.smallFont
// Layout.fillWidth: true
// horizontalAlignment: Text.AlignHCenter
// }
}
Item {

View File

@ -511,7 +511,7 @@ MainPageTile {
Led {
Layout.preferredHeight: app.iconSize * .5
Layout.preferredWidth: height
on: sensorsRoot.shownStateType && sensorsRoot.device.stateValue(sensorsRoot.shownStateType.id) === true
state: sensorsRoot.shownStateType && sensorsRoot.device.stateValue(sensorsRoot.shownStateType.id) === true ? "on" : "off"
visible: sensorsRoot.shownStateType && sensorsRoot.shownStateType.type.toLowerCase() === "bool"
}
}

View File

@ -347,7 +347,7 @@ Item {
}
}
Led {
on: sensorsRoot.currentState.value === true
state: sensorsRoot.currentState.value === true ? "on" : "off"
visible: sensorsRoot.currentStateType.type.toLowerCase() === "bool"
}