diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index f7433fc..fd5f09d 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -145,7 +145,8 @@ Page { visible: Object.keys(printer.attrs).length !== 0 property string name: printer.attrs["printer-name"].value != "" ? printer.attrs["printer-name"].value : qsTr("Unknown") - property bool canPrint: Utils.supported_formats(printer, ConvertChecker, considerAdditionalFormatsSetting.value).mimetypes.indexOf(selectedFileType) != -1 + property var supported_formats: Utils.supported_formats(printer, ConvertChecker, considerAdditionalFormatsSetting.value) + property bool canPrint: supported_formats.mimetypes.indexOf(selectedFileType) != -1 Connections { target: printer @@ -254,16 +255,44 @@ Page { spacing: Theme.paddingMedium Label { id: format_unsupported_label - visible: format_label.text == "" + visible: !supported_formats.pdf && !supported_formats.postscript && !supported_formats.office && !supported_formats.images color: "red" font.pixelSize: Theme.fontSizeExtraSmall text: qsTr("No compatible formats supported") } - Label { - id: format_label - color: selectedFile == "" ? Theme.secondaryColor : canPrint ? Theme.primaryColor : "red" - font.pixelSize: Theme.fontSizeExtraSmall - text: Utils.supported_formats(printer, ConvertChecker, considerAdditionalFormatsSetting.value).supported + + HighlightImage { + height: Theme.itemSizeExtraSmall/2 + width: Theme.itemSizeExtraSmall/2 + visible: supported_formats.pdf + highlightColor: "red" + highlighted: !(selectedFile == "" || canPrint) + source: "image://theme/icon-m-file-pdf" + } + HighlightImage { + height: Theme.itemSizeExtraSmall/2 + width: Theme.itemSizeExtraSmall/2 + visible: supported_formats.postscript + highlightColor: "red" + highlighted: !(selectedFile == "" || canPrint) + source: "image://theme/icon-m-file-other" + + } + HighlightImage { + height: Theme.itemSizeExtraSmall/2 + width: Theme.itemSizeExtraSmall/2 + visible: supported_formats.office + highlightColor: "red" + highlighted: !(selectedFile == "" || canPrint) + source: "image://theme/icon-m-file-formatted" + } + HighlightImage { + height: Theme.itemSizeExtraSmall/2 + width: Theme.itemSizeExtraSmall/2 + visible: supported_formats.images + highlightColor: "red" + highlighted: !(selectedFile == "" || canPrint) + source: "image://theme/icon-m-file-image" } } diff --git a/qml/pages/utils.js b/qml/pages/utils.js index 57ac6a2..b97e0bf 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -1,3 +1,5 @@ + +// TODO move to IppPrinter and/or Mimer when i figure out how to handle considerAdditionalFormats there function supported_formats(printer, ConvertChecker, considerAdditionalFormats) { var formats = printer.attrs["document-format-supported"].value; @@ -9,37 +11,40 @@ function supported_formats(printer, ConvertChecker, considerAdditionalFormats) var raster = (has(formats, Mimer.PWG) || has(formats, Mimer.URF)); var mimetypes = []; - var supported = []; + var pdf = false; + var postscript = false; + var office = false; + var images = false; + if(has(formats, Mimer.PDF) || (ConvertChecker.pdf && ( has(formats, Mimer.Postscript) || raster ))) - { - mimetypes.push(Mimer.PDF); - supported.push("PDF"); - } - if(has(formats, Mimer.Postscript)) - { - mimetypes.push(Mimer.Postscript); - supported.push("Postscript"); - } + { + pdf = true; + mimetypes.push(Mimer.PDF); + } + if(has(formats, Mimer.Postscript)) + { + postscript = true; + mimetypes.push(Mimer.Postscript); + } - if((ConvertChecker.pdf && ConvertChecker.calligra) && - ( has(formats, Mimer.PDF) || has(formats, Mimer.Postscript) || raster )) - { - mimetypes = mimetypes.concat(Mimer.OfficeFormats); - } + if((ConvertChecker.pdf && ConvertChecker.calligra) && + ( has(formats, Mimer.PDF) || has(formats, Mimer.Postscript) || raster )) + { + office = true; + mimetypes = mimetypes.concat(Mimer.OfficeFormats); + } - if (raster || has(formats, Mimer.JPEG) || has(formats, Mimer.PNG)) - { - mimetypes.push(Mimer.JPEG); - supported.push("JPEG"); - mimetypes.push(Mimer.PNG); - supported.push("PNG"); - mimetypes.push(Mimer.TIFF); - mimetypes.push(Mimer.GIF); + if (raster || has(formats, Mimer.JPEG) || has(formats, Mimer.PNG)) + { + images = true; + mimetypes.push(Mimer.JPEG); + mimetypes.push(Mimer.PNG); + mimetypes.push(Mimer.TIFF); + mimetypes.push(Mimer.GIF); + } - } - - return {supported: supported.join(" "), mimetypes: mimetypes}; + return {pdf: pdf, postscript: postscript, office: office, images: images, mimetypes: mimetypes}; } function has(arrayish, what)