diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index d67eebb..88c86a7 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -12,6 +12,7 @@ Page { allowedOrientations: Orientation.All property string selectedFile: "" + property string selectedFileType IppDiscovery { id: discovery @@ -88,7 +89,7 @@ Page { visible: false property string name: printer.attrs["printer-name"].value != "" ? printer.attrs["printer-name"].value : qsTr("Unknown") - property bool canPrint: Utils.can_print(printer, selectedFile) + property bool canPrint: printer.attrs["document-format-supported"].value.indexOf(selectedFileType) != -1 Connections { target: printer @@ -226,6 +227,7 @@ Page { onSelectedContentPropertiesChanged: { page.selectedFile = selectedContentProperties.filePath + page.selectedFileType = selectedContentProperties.mimeType } } } diff --git a/qml/pages/utils.js b/qml/pages/utils.js index 5730825..8ab43b8 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -1,28 +1,14 @@ function supported_formats(printer) -{ - return _formats(printer).supported; -} - -function format_filters(printer) -{ - return _formats(printer).filters; -} - -function _formats(printer) { var formats = printer.attrs["document-format-supported"].value; var supported = []; - var filters = []; if(has(formats, "application/pdf")) { supported.push("PDF"); - filters.push("*.pdf"); } if(has(formats, "image/jpeg")) { supported.push("JPEG"); - filters.push("*.jpg"); - filters.push("*.jpeg"); } if(supported.length == 0) @@ -30,7 +16,7 @@ function _formats(printer) supported.push("No relevant formats supported") } - return {supported: supported.join(" "), filters: filters}; + return supported.join(" "); } function has(arrayish, what) @@ -42,9 +28,3 @@ function has(arrayish, what) } return false } - -function can_print(printer, fileName) -{ - // Move to ippprinter? - return format_filters(printer).indexOf("*."+fileName.split('.').pop()) != -1; -}