Icon selection heuristics

This commit is contained in:
Anton Thomasson 2020-06-13 12:51:21 +02:00
parent 16f1edd818
commit 35d3e44ffd
2 changed files with 14 additions and 1 deletions

View file

@ -189,7 +189,8 @@ Page {
height: Theme.itemSizeLarge height: Theme.itemSizeLarge
width: Theme.itemSizeLarge width: Theme.itemSizeLarge
source: printer.attrs["printer-icons"] ? "image://ippdiscovery/"+printer.attrs["printer-icons"].value[0] : "icon-seaprint-nobg.svg" source: printer.attrs["printer-icons"] ? "image://ippdiscovery/"+Utils.selectIcon(printer.attrs["printer-icons"].value)
: "icon-seaprint-nobg.svg"
// Some printers serve their icons over https with invalid certs... // Some printers serve their icons over https with invalid certs...
onStatusChanged: if (status == Image.Error) source = "icon-seaprint-nobg.svg" onStatusChanged: if (status == Image.Error) source = "icon-seaprint-nobg.svg"

View file

@ -254,6 +254,18 @@ function limitChoices(name, choices, mimeType, ConvertChecker)
} }
} }
function selectIcon(icons)
{
for(var i=0; i < icons.length; i++)
{
if(endsWith("M.png", icons[i]) || endsWith("128x128.png", icons[i]))
{
return icons[i];
}
}
return icons[0];
}
var media = var media =
{"asme_f_28x40in": "28 x 40″", {"asme_f_28x40in": "28 x 40″",
"choice_iso_a4_210x297mm_na_letter_8.5x11in": "A4 or US Letter", "choice_iso_a4_210x297mm_na_letter_8.5x11in": "A4 or US Letter",