Add zero margin setting

This commit is contained in:
Anton Thomasson 2020-06-16 19:51:29 +02:00
parent c58ed1e67d
commit d3ff426946
8 changed files with 134 additions and 5 deletions

View file

@ -24,7 +24,7 @@ Setting {
maximumValue: high < 100 ? high : 100 maximumValue: high < 100 ? high : 100
width: parent.width width: parent.width
stepSize: 1 stepSize: 1
value: choice value: choice ? choice : default_choice
onValueChanged: onValueChanged:
{ {
choice = value; choice = value;

View file

@ -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
}
}
}
}

View file

@ -7,7 +7,7 @@ Item {
property string name property string name
property string prettyName property string prettyName
property int tag property int tag
property bool valid: true property bool valid: false
property var choice property var choice
property var default_choice property var default_choice

View file

@ -45,6 +45,7 @@ Page {
ListElement {name: "printer-resolution"; prettyName: qsTr("Resolution"); tag: IppMsg.Resolution} ListElement {name: "printer-resolution"; prettyName: qsTr("Resolution"); tag: IppMsg.Resolution}
ListElement {name: "document-format"; prettyName: qsTr("Transfer format"); tag: IppMsg.MimeMediaType} 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-source"; prettyName: qsTr("Media source"); tag: IppMsg.Keyword}
ListElement {name: "media-col"; prettyName: qsTr("Zero margins"); tag: IppMsg.BeginCollection}
} }
SilicaListView { SilicaListView {
@ -74,6 +75,7 @@ Page {
anchors.fill: parent anchors.fill: parent
onLoaded: { onLoaded: {
delegate.visible = true
if(loaderItem.menu.enabled) if(loaderItem.menu.enabled)
{ {
menu = loaderItem.menu menu = loaderItem.menu
@ -81,7 +83,14 @@ Page {
} }
loaderItem.choiceMade.connect(function(tag, choice) { loaderItem.choiceMade.connect(function(tag, choice) {
console.log("choice changed", tag, JSON.stringify(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)); console.log(JSON.stringify(jobParams));
}) })
} }
@ -97,7 +106,7 @@ Page {
valid: printer.attrs.hasOwnProperty(name+"-supported"), valid: printer.attrs.hasOwnProperty(name+"-supported"),
low: printer.attrs[name+"-supported"].value.low, low: printer.attrs[name+"-supported"].value.low,
high: printer.attrs[name+"-supported"].value.high, 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 break
case IppMsg.IntegerRange: case IppMsg.IntegerRange:
@ -118,10 +127,18 @@ Page {
tag: tag, tag: tag,
valid: printer.attrs.hasOwnProperty(name+"-supported"), valid: printer.attrs.hasOwnProperty(name+"-supported"),
choices: printer.attrs[name+"-supported"].value, 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) mime_type: Mimer.get_type(selectedFile)
}) })
break break
case IppMsg.BeginCollection:
loader.setSource("../components/MediaColSetting.qml",
{name: name,
prettyName: prettyName,
tag: tag,
valid: false,
printer: printer
})
} }
} }

View file

@ -257,6 +257,17 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
<context>
<name>MediaColSetting</name>
<message>
<source>true</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>false</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>NagScreen</name> <name>NagScreen</name>
<message> <message>
@ -326,6 +337,10 @@
<source>Media source</source> <source>Media source</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Zero margins</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>SettingsPage</name> <name>SettingsPage</name>

View file

@ -257,6 +257,17 @@
<translation>Cancelando trabajo fallido</translation> <translation>Cancelando trabajo fallido</translation>
</message> </message>
</context> </context>
<context>
<name>MediaColSetting</name>
<message>
<source>true</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>false</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>NagScreen</name> <name>NagScreen</name>
<message> <message>
@ -326,6 +337,10 @@
<source>Media source</source> <source>Media source</source>
<translation>Fuente de medios</translation> <translation>Fuente de medios</translation>
</message> </message>
<message>
<source>Zero margins</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>SettingsPage</name> <name>SettingsPage</name>

View file

@ -257,6 +257,17 @@
<translation>Échec de l&apos;annulation de la tâche d&apos;impression</translation> <translation>Échec de l&apos;annulation de la tâche d&apos;impression</translation>
</message> </message>
</context> </context>
<context>
<name>MediaColSetting</name>
<message>
<source>true</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>false</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>NagScreen</name> <name>NagScreen</name>
<message> <message>
@ -326,6 +337,10 @@
<source>Media source</source> <source>Media source</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Zero margins</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>SettingsPage</name> <name>SettingsPage</name>

View file

@ -257,6 +257,17 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
<context>
<name>MediaColSetting</name>
<message>
<source>true</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>false</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>NagScreen</name> <name>NagScreen</name>
<message> <message>
@ -326,6 +337,10 @@
<source>Media source</source> <source>Media source</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Zero margins</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>SettingsPage</name> <name>SettingsPage</name>