Merge PR #1083: Some layout fixes in the Sensor page
This commit is contained in:
commit
d8f2b65db2
@ -159,6 +159,7 @@ Item {
|
|||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
text: root.stateType.displayName
|
text: root.stateType.displayName
|
||||||
visible: root.titleVisible
|
visible: root.titleVisible
|
||||||
|
elide: Text.ElideMiddle
|
||||||
// MouseArea {
|
// MouseArea {
|
||||||
// anchors.fill: parent
|
// anchors.fill: parent
|
||||||
// onClicked: {
|
// onClicked: {
|
||||||
|
|||||||
@ -81,7 +81,7 @@ ThingPageBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Flickable {
|
Flickable {
|
||||||
id: listView
|
id: flickable
|
||||||
anchors { fill: parent }
|
anchors { fill: parent }
|
||||||
topMargin: app.margins / 2
|
topMargin: app.margins / 2
|
||||||
interactive: contentHeight > height
|
interactive: contentHeight > height
|
||||||
@ -97,15 +97,12 @@ ThingPageBase {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.leftMargin: sensorsModel.count == 1 ? Style.hugeMargins : Style.bigMargins
|
Layout.leftMargin: sensorsModel.count == 1 ? Style.hugeMargins : Style.bigMargins
|
||||||
Layout.rightMargin: sensorsModel.count == 1 ? Style.hugeMargins : Style.bigMargins
|
Layout.rightMargin: sensorsModel.count == 1 ? Style.hugeMargins : Style.bigMargins
|
||||||
Layout.preferredHeight: cellWidth * Math.min(400, Math.ceil(flowRepeater.count / columns))
|
Layout.preferredHeight: flow.cellWidth * flow.totalRows
|
||||||
|
|
||||||
property int columns: Math.min(flowRepeater.count, Math.floor(listView.width / 150))
|
property int columns: Math.min(flowRepeater.count, Math.floor(flickable.width / 150))
|
||||||
property int cellWidth: width / columns
|
property int cellWidth: Math.min(400, width / columns)
|
||||||
property int totalRows: flowRepeater.count / columns
|
property int filledRows: flowRepeater.count / columns
|
||||||
|
property int totalRows: Math.ceil(flowRepeater.count / columns)
|
||||||
// columns: 2// Math.ceil(width / 600)
|
|
||||||
// columnSpacing: Style.margins
|
|
||||||
// rowSpacing: Style.margins
|
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: flowRepeater
|
id: flowRepeater
|
||||||
@ -113,9 +110,9 @@ ThingPageBase {
|
|||||||
|
|
||||||
delegate: SensorView {
|
delegate: SensorView {
|
||||||
width: Math.floor(flow.width / itemsInRow)
|
width: Math.floor(flow.width / itemsInRow)
|
||||||
height: Math.min(400, flow.cellWidth)
|
height: flow.cellWidth
|
||||||
property int row: Math.floor(index / flow.columns)
|
property int row: Math.floor(index / flow.columns)
|
||||||
property int itemsInRow: row < flow.totalRows ? flow.columns : (flowRepeater.count % flow.columns)
|
property int itemsInRow: row < flow.filledRows ? flow.columns : (flowRepeater.count % flow.columns)
|
||||||
|
|
||||||
thing: root.thing
|
thing: root.thing
|
||||||
interfaceName: modelData
|
interfaceName: modelData
|
||||||
@ -124,7 +121,6 @@ ThingPageBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GridLayout {
|
GridLayout {
|
||||||
columns: Math.ceil(width / 600)
|
columns: Math.ceil(width / 600)
|
||||||
rowSpacing: 0
|
rowSpacing: 0
|
||||||
@ -152,10 +148,30 @@ ThingPageBase {
|
|||||||
Component {
|
Component {
|
||||||
id: stateChartComponent
|
id: stateChartComponent
|
||||||
StateChart {
|
StateChart {
|
||||||
|
id: stateChart
|
||||||
thing: root.thing
|
thing: root.thing
|
||||||
stateType: parent.stateType
|
stateType: parent.stateType
|
||||||
color: app.interfaceToColor(interfaceName)
|
color: app.interfaceToColor(interfaceName)
|
||||||
iconSource: app.interfaceToIcon(interfaceName)
|
iconSource: app.interfaceToIcon(interfaceName)
|
||||||
|
Binding {
|
||||||
|
target: stateChart
|
||||||
|
property: "title"
|
||||||
|
when: ["presencesensor", "daylightsensor", "closablesensor", "watersensor", "firesensor"].indexOf(interfaceName) >= 0
|
||||||
|
value: {
|
||||||
|
switch (interfaceName) {
|
||||||
|
case "presencesensor":
|
||||||
|
return stateChart.valueState.value === true ? qsTr("Presence") : qsTr("Vacant")
|
||||||
|
case "daylightsensor":
|
||||||
|
return stateChart.valueState.value === true ? qsTr("Daytime") : qsTr("Nighttime")
|
||||||
|
case "closablesensor":
|
||||||
|
return stateChart.valueState.value === true ? qsTr("Closed") : qsTr("Open")
|
||||||
|
case "watersensor":
|
||||||
|
return stateChart.valueState.value === true ? qsTr("Wet") : qsTr("Dry")
|
||||||
|
case "firesensor":
|
||||||
|
return stateChart.valueState.value === true ? qsTr("Fire") : qsTr("No fire")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user