diff --git a/qml/components/IntegerSetting.qml b/qml/components/IntegerSetting.qml index 5b09a00..02d50cb 100644 --- a/qml/components/IntegerSetting.qml +++ b/qml/components/IntegerSetting.qml @@ -24,7 +24,7 @@ Setting { maximumValue: high < 100 ? high : 100 width: parent.width stepSize: 1 - value: choice + value: choice ? choice : default_choice onValueChanged: { choice = value; diff --git a/qml/components/MediaColSetting.qml b/qml/components/MediaColSetting.qml new file mode 100644 index 0000000..026da5f --- /dev/null +++ b/qml/components/MediaColSetting.qml @@ -0,0 +1,52 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import seaprint.convertchecker 1.0 +import seaprint.ippmsg 1.0 +import "../pages/utils.js" as Utils + +Setting { + property var printer + + Component.onCompleted: { + if((printer.attrs["media-left-margin-supported"].value.indexOf(0) != -1) && + (printer.attrs["media-right-margin-supported"].value.indexOf(0) != -1) && + (printer.attrs["media-top-margin-supported"].value.indexOf(0) != -1) && + (printer.attrs["media-bottom-margin-supported"].value.indexOf(0) != -1)) + { + valid = true + } + } + + ValueButton { + enabled: valid + anchors.verticalCenter: parent.verticalCenter + label: prettyName + value: choice ? qsTr("true") : qsTr("false") + onClicked: parent.clicked() + } + + property var menu: ContextMenu { + id: menu + enabled: true + MenuItem { + text: qsTr("true") + onClicked: + { + choice = {"media-left-margin": {"tag": IppMsg.Integer, "value": 0}, + "media-right-margin": {"tag": IppMsg.Integer, "value": 0}, + "media-top-margin": {"tag": IppMsg.Integer, "value": 0}, + "media-bottom-margin": {"tag": IppMsg.Integer, "value": 0}} + } + } + MenuItem { + text: qsTr("false") + onClicked: + { + choice = undefined + } + } + + } + + +} diff --git a/qml/components/Setting.qml b/qml/components/Setting.qml index 1c272b8..e8832a6 100644 --- a/qml/components/Setting.qml +++ b/qml/components/Setting.qml @@ -7,7 +7,7 @@ Item { property string name property string prettyName property int tag - property bool valid: true + property bool valid: false property var choice property var default_choice diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index 9740c53..c8c645c 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -45,6 +45,7 @@ Page { ListElement {name: "printer-resolution"; prettyName: qsTr("Resolution"); tag: IppMsg.Resolution} ListElement {name: "document-format"; prettyName: qsTr("Transfer format"); tag: IppMsg.MimeMediaType} ListElement {name: "media-source"; prettyName: qsTr("Media source"); tag: IppMsg.Keyword} + ListElement {name: "media-col"; prettyName: qsTr("Zero margins"); tag: IppMsg.BeginCollection} } SilicaListView { @@ -74,6 +75,7 @@ Page { anchors.fill: parent onLoaded: { + delegate.visible = true if(loaderItem.menu.enabled) { menu = loaderItem.menu @@ -81,7 +83,14 @@ Page { } loaderItem.choiceMade.connect(function(tag, choice) { console.log("choice changed", tag, JSON.stringify(choice)) - jobParams[name] = {tag: tag, value: choice}; + if(choice != undefined) + { + jobParams[name] = {tag: tag, value: choice}; + } + else + { + jobParams[name] = undefined + } console.log(JSON.stringify(jobParams)); }) } @@ -97,7 +106,7 @@ Page { valid: printer.attrs.hasOwnProperty(name+"-supported"), low: printer.attrs[name+"-supported"].value.low, high: printer.attrs[name+"-supported"].value.high, - default_choice: printer.attrs[name+"-default"].value + default_choice: printer.attrs.hasOwnProperty(name+"-default") ? printer.attrs[name+"-default"].value : undefined }) break case IppMsg.IntegerRange: @@ -118,10 +127,18 @@ Page { tag: tag, valid: printer.attrs.hasOwnProperty(name+"-supported"), choices: printer.attrs[name+"-supported"].value, - default_choice: printer.attrs[name+"-default"].value, + default_choice: printer.attrs.hasOwnProperty(name+"-default") ? printer.attrs[name+"-default"].value : "", mime_type: Mimer.get_type(selectedFile) }) break + case IppMsg.BeginCollection: + loader.setSource("../components/MediaColSetting.qml", + {name: name, + prettyName: prettyName, + tag: tag, + valid: false, + printer: printer + }) } } diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index e859f48..09b4947 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -257,6 +257,17 @@ + + MediaColSetting + + true + + + + false + + + NagScreen @@ -326,6 +337,10 @@ Media source + + Zero margins + + SettingsPage diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index 26b343f..f4f4dbe 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -257,6 +257,17 @@ Cancelando trabajo fallido + + MediaColSetting + + true + + + + false + + + NagScreen @@ -326,6 +337,10 @@ Media source Fuente de medios + + Zero margins + + SettingsPage diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index 9a8cddc..1bc9199 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -257,6 +257,17 @@ Échec de l'annulation de la tâche d'impression + + MediaColSetting + + true + + + + false + + + NagScreen @@ -326,6 +337,10 @@ Media source + + Zero margins + + SettingsPage diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index 606e38f..0efbbc8 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -257,6 +257,17 @@ + + MediaColSetting + + true + + + + false + + + NagScreen @@ -326,6 +337,10 @@ Media source + + Zero margins + + SettingsPage