Properly support (basic) media-col attributes

This commit is contained in:
Anton Thomasson 2021-07-09 19:17:45 +02:00
parent ec6224f777
commit b98cc0e47a
12 changed files with 185 additions and 87 deletions

View file

@ -6,11 +6,10 @@ import "../pages/utils.js" as Utils
Setting { Setting {
property var choices: parent.getChoices(name) property var choices: parent.getChoices(name)
property string mime_type
property var preferred_choices: [] property var preferred_choices: []
property string preferred_choice_suffix: "" property string preferred_choice_suffix: ""
property var limited_choices: Utils.limitChoices(name, choices, mime_type, ConvertChecker) property var limited_choices: Utils.limitChoices(name, choices, parent.selectedFileType, ConvertChecker)
property int num_large_choices: 8 property int num_large_choices: 8

View file

@ -1,36 +0,0 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
import seaprint.ippmsg 1.0
Setting {
valid: ((parent.printer.attrs["media-left-margin-supported"].value.indexOf(0) != -1) &&
(parent.printer.attrs["media-right-margin-supported"].value.indexOf(0) != -1) &&
(parent.printer.attrs["media-top-margin-supported"].value.indexOf(0) != -1) &&
(parent.printer.attrs["media-bottom-margin-supported"].value.indexOf(0) != -1))
displayValue: choice ? qsTr("true") : qsTr("false")
menu: ContextMenu {
id: menu
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

@ -8,6 +8,7 @@ Item {
property string name property string name
property string prettyName property string prettyName
property int tag property int tag
property string subkey: ""
property bool _valid: parent.isValid(name) property bool _valid: parent.isValid(name)
property bool valid: _valid property bool valid: _valid

View file

@ -2,6 +2,7 @@ import QtQuick 2.6
import Sailfish.Silica 1.0 import Sailfish.Silica 1.0
import seaprint.mimer 1.0 import seaprint.mimer 1.0
import seaprint.ippprinter 1.0 import seaprint.ippprinter 1.0
import seaprint.ippmsg 1.0
Column { Column {
id: settingsColumn id: settingsColumn
@ -15,17 +16,28 @@ Column {
return printer.attrs.hasOwnProperty(name+"-supported"); return printer.attrs.hasOwnProperty(name+"-supported");
} }
function setInitialChoice(setting) { function setInitialChoice(setting) {
if(jobParams.hasOwnProperty(setting.name)) if(setting.valid)
{ {
if(setting.valid) if(setting.subkey == "")
{ {
setting.choice = jobParams[setting.name].value; if(jobParams.hasOwnProperty(setting.name))
{
setting.choice = jobParams[setting.name].value;
}
} }
else else
{ // Clear jobParams of invalid settings {
jobParams[setting.name] = undefined; if(jobParams.hasOwnProperty(setting.subkey) &&jobParams[setting.subkey].value.hasOwnProperty(setting.name))
{
setting.choice = jobParams[setting.subkey].value[setting.name].value;
}
} }
} }
else
{ // Clear jobParams of invalid settings
delete jobParams[setting.name];
}
} }
function getChoices(name) { function getChoices(name) {
return isValid(name) ? printer.attrs[name+"-supported"].value : []; return isValid(name) ? printer.attrs[name+"-supported"].value : [];
@ -34,6 +46,8 @@ Column {
return printer.attrs.hasOwnProperty(name+"-default") ? printer.attrs[name+"-default"].value : undefined; return printer.attrs.hasOwnProperty(name+"-default") ? printer.attrs[name+"-default"].value : undefined;
} }
function choiceMade(setting) function choiceMade(setting)
{
if(setting.subkey == "")
{ {
if(setting.choice != undefined) if(setting.choice != undefined)
{ {
@ -41,10 +55,35 @@ Column {
} }
else else
{ {
jobParams[setting.name] = undefined; delete jobParams[setting.name];
} }
console.log(JSON.stringify(jobParams));
} }
else
{
var tmpObj = Object();
if(jobParams.hasOwnProperty(setting.subkey))
{
tmpObj = jobParams[setting.subkey].value;
}
if(setting.choice != undefined)
{
tmpObj[setting.name] = {tag: setting.tag, value: setting.choice};
}
else
{
delete tmpObj[setting.name];
}
if(Object.keys(tmpObj).length != 0)
{
jobParams[setting.subkey] = {tag: IppMsg.BeginCollection, value: tmpObj};
}
else
{
delete jobParams[setting.subkey];
}
}
console.log(JSON.stringify(jobParams));
}
} }

View file

@ -93,13 +93,11 @@ Page {
tag: IppMsg.Keyword tag: IppMsg.Keyword
name: "sides" name: "sides"
prettyName: qsTr("Sides") prettyName: qsTr("Sides")
mime_type: selectedFileType
} }
ChoiceSetting { ChoiceSetting {
tag: IppMsg.Keyword tag: IppMsg.Keyword
name: "media" name: "media"
prettyName: qsTr("Print media") prettyName: qsTr("Print media")
mime_type: selectedFileType
preferred_choices: printer.attrs.hasOwnProperty("media-ready") ? printer.attrs["media-ready"].value : [] preferred_choices: printer.attrs.hasOwnProperty("media-ready") ? printer.attrs["media-ready"].value : []
preferred_choice_suffix: qsTr("(loaded)") preferred_choice_suffix: qsTr("(loaded)")
} }
@ -112,7 +110,6 @@ Page {
tag: IppMsg.Keyword tag: IppMsg.Keyword
name: "multiple-document-handling" name: "multiple-document-handling"
prettyName: qsTr("Collated copies") prettyName: qsTr("Collated copies")
mime_type: selectedFileType
} }
RangeSetting { RangeSetting {
tag: IppMsg.IntegerRange tag: IppMsg.IntegerRange
@ -128,48 +125,62 @@ Page {
tag: IppMsg.Keyword tag: IppMsg.Keyword
name: "print-color-mode" name: "print-color-mode"
prettyName: qsTr("Color mode") prettyName: qsTr("Color mode")
mime_type: selectedFileType
} }
ChoiceSetting { ChoiceSetting {
tag: IppMsg.Enum tag: IppMsg.Enum
name: "print-quality" name: "print-quality"
prettyName: qsTr("Quality") prettyName: qsTr("Quality")
mime_type: selectedFileType
} }
ChoiceSetting { ChoiceSetting {
tag: IppMsg.Resolution tag: IppMsg.Resolution
name: "printer-resolution" name: "printer-resolution"
prettyName: qsTr("Resolution") prettyName: qsTr("Resolution")
mime_type: selectedFileType
} }
ChoiceSetting { ChoiceSetting {
tag: IppMsg.MimeMediaType tag: IppMsg.MimeMediaType
name: "document-format" name: "document-format"
prettyName: qsTr("Transfer format") prettyName: qsTr("Transfer format")
mime_type: selectedFileType
} }
ChoiceSetting { ChoiceSetting {
tag: IppMsg.Keyword tag: IppMsg.Keyword
name: "media-type" name: "media-type"
subkey: "media-col"
prettyName: qsTr("Media type") prettyName: qsTr("Media type")
mime_type: selectedFileType
} }
ChoiceSetting { ChoiceSetting {
tag: IppMsg.Keyword tag: IppMsg.Keyword
name: "media-source" name: "media-source"
subkey: "media-col"
prettyName: qsTr("Media source") prettyName: qsTr("Media source")
mime_type: selectedFileType
} }
ChoiceSetting { ChoiceSetting {
tag: IppMsg.Keyword tag: IppMsg.Keyword
name: "output-bin" name: "output-bin"
prettyName: qsTr("Output bin") prettyName: qsTr("Output bin")
mime_type: selectedFileType
} }
MediaColSetting { ChoiceSetting {
tag: IppMsg.BeginCollection tag: IppMsg.Integer
name: "media-col" name: "media-top-margin"
prettyName: qsTr("Zero margins") subkey: "media-col"
prettyName: qsTr("Top")
}
ChoiceSetting {
tag: IppMsg.Integer
name: "media-bottom-margin"
subkey: "media-col"
prettyName: qsTr("Bottom")
}
ChoiceSetting {
tag: IppMsg.Integer
name: "media-left-margin"
subkey: "media-col"
prettyName: qsTr("Left")
}
ChoiceSetting {
tag: IppMsg.Integer
name: "media-right-margin"
subkey: "media-col"
prettyName: qsTr("Right")
} }
} }
} }

View file

@ -462,10 +462,6 @@
<source>Media source</source> <source>Media source</source>
<translation>Papierquelle</translation> <translation>Papierquelle</translation>
</message> </message>
<message>
<source>Zero margins</source>
<translation>Keine Ränder</translation>
</message>
<message> <message>
<source>Page range</source> <source>Page range</source>
<translation>Seiten Auswählen</translation> <translation>Seiten Auswählen</translation>
@ -498,6 +494,22 @@
<source>Media type</source> <source>Media type</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Top</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bottom</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Left</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Right</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>RangeSetting</name> <name>RangeSetting</name>

View file

@ -462,10 +462,6 @@
<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>
<message> <message>
<source>Page range</source> <source>Page range</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -498,6 +494,22 @@
<source>Media type</source> <source>Media type</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Top</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bottom</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Left</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Right</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>RangeSetting</name> <name>RangeSetting</name>

View file

@ -462,10 +462,6 @@
<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>
<message> <message>
<source>Page range</source> <source>Page range</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -498,6 +494,22 @@
<source>Media type</source> <source>Media type</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Top</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bottom</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Left</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Right</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>RangeSetting</name> <name>RangeSetting</name>

View file

@ -462,10 +462,6 @@
<source>Media source</source> <source>Media source</source>
<translation>Media bron</translation> <translation>Media bron</translation>
</message> </message>
<message>
<source>Zero margins</source>
<translation>Geen marges</translation>
</message>
<message> <message>
<source>Page range</source> <source>Page range</source>
<translation>Paginabereik</translation> <translation>Paginabereik</translation>
@ -498,6 +494,22 @@
<source>Media type</source> <source>Media type</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Top</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bottom</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Left</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Right</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>RangeSetting</name> <name>RangeSetting</name>

View file

@ -466,10 +466,6 @@
<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>
<message> <message>
<source>Collated copies</source> <source>Collated copies</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -498,6 +494,22 @@
<source>Media type</source> <source>Media type</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Top</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bottom</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Left</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Right</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>RangeSetting</name> <name>RangeSetting</name>

View file

@ -462,10 +462,6 @@
<source>Media source</source> <source>Media source</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>Zero margins</source>
<translation></translation>
</message>
<message> <message>
<source>Page range</source> <source>Page range</source>
<translation></translation> <translation></translation>
@ -498,6 +494,22 @@
<source>Media type</source> <source>Media type</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Top</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bottom</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Left</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Right</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>RangeSetting</name> <name>RangeSetting</name>

View file

@ -462,10 +462,6 @@
<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>
<message> <message>
<source>Page range</source> <source>Page range</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -498,6 +494,22 @@
<source>Media type</source> <source>Media type</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Top</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bottom</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Left</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Right</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>RangeSetting</name> <name>RangeSetting</name>