Consider PDF support listed in printer-info
This commit is contained in:
parent
8257eed03a
commit
86bfedf01a
2 changed files with 38 additions and 7 deletions
|
@ -108,7 +108,7 @@ Page {
|
||||||
visible: false
|
visible: false
|
||||||
|
|
||||||
property string name: printer.attrs["printer-name"].value != "" ? printer.attrs["printer-name"].value : qsTr("Unknown")
|
property string name: printer.attrs["printer-name"].value != "" ? printer.attrs["printer-name"].value : qsTr("Unknown")
|
||||||
property bool canPrint: printer.attrs["document-format-supported"].value.indexOf(selectedFileType) != -1
|
property bool canPrint: Utils.supported_formats(printer).mimetypes.indexOf(selectedFileType) != -1
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: printer
|
target: printer
|
||||||
|
@ -208,12 +208,23 @@ Page {
|
||||||
text: printer.url
|
text: printer.url
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Row {
|
||||||
id: format_label
|
spacing: Theme.paddingMedium
|
||||||
color: canPrint ? Theme.primaryColor : "red"
|
Label {
|
||||||
font.pixelSize: Theme.fontSizeExtraSmall
|
id: format_label
|
||||||
text: Utils.supported_formats(printer)
|
color: canPrint ? Theme.primaryColor : "red"
|
||||||
|
font.pixelSize: Theme.fontSizeExtraSmall
|
||||||
|
text: Utils.supported_formats(printer).supported
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
id: maybe_format_label
|
||||||
|
color: canPrint ? Theme.secondaryColor : "red"
|
||||||
|
font.pixelSize: Theme.fontSizeExtraSmall
|
||||||
|
font.italic: true
|
||||||
|
text: Utils.supported_formats(printer).maybe
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RemorseItem {
|
RemorseItem {
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
function supported_formats(printer)
|
function supported_formats(printer)
|
||||||
{
|
{
|
||||||
var formats = printer.attrs["document-format-supported"].value;
|
var formats = printer.attrs["document-format-supported"].value;
|
||||||
|
var mimetypes = [];
|
||||||
var supported = [];
|
var supported = [];
|
||||||
if(has(formats, "application/pdf"))
|
if(has(formats, "application/pdf"))
|
||||||
{
|
{
|
||||||
|
mimetypes.push("application/pdf");
|
||||||
supported.push("PDF");
|
supported.push("PDF");
|
||||||
}
|
}
|
||||||
if(has(formats, "image/jpeg"))
|
if(has(formats, "image/jpeg"))
|
||||||
{
|
{
|
||||||
|
mimetypes.push("image/jpeg");
|
||||||
supported.push("JPEG");
|
supported.push("JPEG");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +19,24 @@ function supported_formats(printer)
|
||||||
supported.push(qsTr("No compatible formats supported"))
|
supported.push(qsTr("No compatible formats supported"))
|
||||||
}
|
}
|
||||||
|
|
||||||
return supported.join(" ");
|
|
||||||
|
//var info = "MFG:Hewlett-Packard;CMD:PJL,BIDI-ECP,PJL,POSTSCRIPT,PDF,PCLXL,PCL;MDL:HP LaserJet P3010 Series;CLS:PRINTER;DES:Hewlett-Packard ".split(";");
|
||||||
|
var maybe = []
|
||||||
|
var info = printer.attrs["printer-info"].value.split(";");
|
||||||
|
for(var i in info)
|
||||||
|
{
|
||||||
|
if(info[i].split(":")[0] == "CMD")
|
||||||
|
{
|
||||||
|
if(has(info[i].split(":")[1].split(","), "PDF"))
|
||||||
|
{
|
||||||
|
mimetypes.push("application/pdf");
|
||||||
|
maybe.push("PDF");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {supported: supported.join(" "), maybe: maybe.join(" "), mimetypes: mimetypes};
|
||||||
}
|
}
|
||||||
|
|
||||||
function has(arrayish, what)
|
function has(arrayish, what)
|
||||||
|
|
Loading…
Reference in a new issue