Commit 9bae791a authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Display a message when sensors are missing from a page

When there are sensors missing, a page can end up not displaying
correctly. Inform the user of that state.
parent a457ce14
......@@ -100,6 +100,7 @@ Container {
onAddSeparator: control.addSeparator(index + 1)
onRemove: control.columnData.removeChild(index)
onMove: control.columnData.moveChild(from, to)
onMissingSensorsChanged: control.missingSensorsChanged(id, title, sensors)
}
}
}
......
......@@ -27,6 +27,8 @@ Item {
signal remove()
signal move(int from, int to)
signal missingSensorsChanged(string id, string title, var sensors)
property alias hovered: control.hovered
property alias contentItem: control.contentItem
property alias background: control.background
......
......@@ -59,10 +59,18 @@ Container {
function onFaceIdChanged() {
control.updateContentItem()
}
function onMissingSensorsChanged() {
control.missingSensorsChanged(dataObject.face, controller.title, loader.controller.missingSensors)
}
}
function updateContentItem() {
loader.controller.fullRepresentation.formFactor = Faces.SensorFace.Constrained;
control.contentItem = loader.controller.fullRepresentation;
if (loader.controller.missingSensors.length > 0) {
control.missingSensorsChanged(dataObject.face, loader.controller.title, loader.controller.missingSensors)
}
}
}
......@@ -19,6 +19,8 @@ ColumnLayout {
property PageDataObject pageData
property var actionsFace
property var missingSensors: []
spacing: rowSpacing // From parent Loader
......@@ -65,6 +67,17 @@ ColumnLayout {
return Math.max(balancedHeight, minimumSpace)
}
Kirigami.InlineMessage {
id: missingMessage
Layout.fillWidth: true
visible: root.missingSensors.length > 0
type: Kirigami.MessageType.Error
text: i18n("This page is missing some sensors and will not display correctly.");
}
Repeater {
model: PageDataModel { data: root.pageData }
......@@ -203,6 +216,25 @@ ColumnLayout {
FaceLoader {
id: loader
dataObject: modelData.data
Component.onCompleted: {
root.faceMapping[modelData.data.face] = loader
}
}
Connections {
target: loader.controller
function onMissingSensorsChanged() {
for (let i of missingSensors) {
root.missingSensors.push({
"face": modelData.data.face,
"title": loader.controller.title,
"sensor": i
})
}
root.missingSensorsChanged()
}
}
Component.onCompleted: {
......
......@@ -20,6 +20,7 @@ Column {
property Item activeItem
property var actionsFace
property var missingSensors: []
spacing: rowSpacing // From parent loader
move: Transition {
......@@ -27,7 +28,7 @@ Column {
}
function relayout() {
let reservedHeight = 0;
let reservedHeight = missingMessage.visible ? missingMessage.height : 0;
let minimumHeight = 0;
let balancedCount = 0;
let maximumCount = 0;
......@@ -92,9 +93,31 @@ Column {
Layout.minimumHeight = minimumTotalHeight
}
function updateMissingSensors(id, title, sensors) {
for (let sensor of sensors) {
missingSensors.push({
"face": id,
"title": title,
"sensor": sensor
})
}
missingSensorsChanged()
}
onWidthChanged: Qt.callLater(relayout)
onHeightChanged: Qt.callLater(relayout)
Kirigami.InlineMessage {
id: missingMessage
width: parent.width
visible: root.missingSensors.length > 0
type: Kirigami.MessageType.Error
text: i18n("This page is missing some sensors and will not display correctly.");
}
Repeater {
id: repeater
model: PageDataModel { data: root.pageData }
......@@ -123,6 +146,7 @@ Column {
onRemove: pageData.removeChild(index)
onMove: pageData.moveChild(from, to)
onMissingSensorsChanged: root.updateMissingSensors(id, title, sensors)
}
}
......
......@@ -111,6 +111,7 @@ Container {
onSelect: control.select(item)
onRemove: control.rowData.removeChild(index)
onMove: control.rowData.moveChild(from, to)
onMissingSensorsChanged: control.missingSensorsChanged(id, title, sensors)
}
}
}
......
......@@ -46,6 +46,8 @@ Container {
dataObject: control.sectionData
onSelect: control.select(item)
onMissingSensorsChanged: control.missingSensorsChanged(id, title, sensors)
}
toolbar.addVisible: false
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment