Display warning icon

...and account for that there can be multiple reasons
This commit is contained in:
Anton Thomasson 2020-10-10 17:32:44 +02:00
parent 0da94cc3b3
commit ded0d4a2cb
4 changed files with 29 additions and 3 deletions

View file

@ -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 {

View file

@ -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

View file

@ -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",

View file

@ -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)
{