From ded0d4a2cb48e18be73c4f8c700685a09b306752 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 10 Oct 2020 17:32:44 +0200 Subject: [PATCH] Display warning icon ...and account for that there can be multiple reasons --- qml/pages/DetailsPage.qml | 8 ++++++-- qml/pages/FirstPage.qml | 8 ++++++++ qml/pages/utils.js | 13 +++++++++++++ src/ippmsg.cpp | 3 ++- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/qml/pages/DetailsPage.qml b/qml/pages/DetailsPage.qml index ab247ab..b7a8d82 100644 --- a/qml/pages/DetailsPage.qml +++ b/qml/pages/DetailsPage.qml @@ -44,8 +44,12 @@ Page { text: Utils.ippName("printer-state", printer.attrs["printer-state"].value) } - Label { - text: Utils.ippName("printer-state-reasons", printer.attrs["printer-state-reasons"].value) + Repeater + { + model: printer.attrs["printer-state-reasons"].value + Label { + text: Utils.ippName("printer-state-reasons", printer.attrs["printer-state-reasons"].value[index]) + } } Label { diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index 54a41ac..1c5d281 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -202,6 +202,14 @@ Page { } + Image { + id: warningIcon + source: "image://theme/icon-lock-warning" + anchors.bottom: icon.bottom + anchors.right: icon.right + visible: Utils.isWaringState(printer) + } + Column { id: column anchors.left: icon.right diff --git a/qml/pages/utils.js b/qml/pages/utils.js index a43383c..037b1e4 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -318,6 +318,19 @@ function selectIcon(icons) return icons[0]; } +function isWaringState(printer) +{ + if(printer.attrs["printer-state"].value > 4) + { + return true; + } + else if(!has(printer.attrs["printer-state-reasons"].value, "none")) + { + return true; + } + return false; +} + var media = {"asme_f_28x40in": "28 x 40″", "choice_iso_a4_210x297mm_na_letter_8.5x11in": "A4 or US Letter", diff --git a/src/ippmsg.cpp b/src/ippmsg.cpp index 79c7c7c..c087c59 100644 --- a/src/ippmsg.cpp +++ b/src/ippmsg.cpp @@ -276,7 +276,8 @@ QString IppMsg::consume_attribute(QJsonObject& attrs, Bytestream& data) bool forceArray = (!noList && (name.startsWith("marker-") || name.startsWith("printer-firmware") || name.endsWith("-supported") - || name == "printer-icons")); + || name == "printer-icons" + || name.endsWith("-reasons"))); if(!unnamed.empty() || forceArray) {