Rework applying initial settings
This commit is contained in:
parent
576f6a616f
commit
8fad10a2d1
1 changed files with 24 additions and 14 deletions
|
@ -64,7 +64,7 @@ Page {
|
||||||
visible: printer.attrs.hasOwnProperty("printer-uuid")
|
visible: printer.attrs.hasOwnProperty("printer-uuid")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var tmp = jobParams;
|
var tmp = jobParams;
|
||||||
// Support varies between formats and values varies between documents, would be confusing to save
|
// Varies between documents, would be confusing to save
|
||||||
tmp["page-ranges"] = undefined;
|
tmp["page-ranges"] = undefined;
|
||||||
db.setJobSettings(printer.attrs["printer-uuid"].value, selectedFileType, JSON.stringify(tmp))
|
db.setJobSettings(printer.attrs["printer-uuid"].value, selectedFileType, JSON.stringify(tmp))
|
||||||
}
|
}
|
||||||
|
@ -101,8 +101,18 @@ Page {
|
||||||
function isValid(name) {
|
function isValid(name) {
|
||||||
return printer.attrs.hasOwnProperty(name+"-supported");
|
return printer.attrs.hasOwnProperty(name+"-supported");
|
||||||
}
|
}
|
||||||
function getInitialChoice(name) {
|
function setInitialChoice(setting) {
|
||||||
return jobParams.hasOwnProperty(name) ? jobParams[name].value : undefined
|
if(jobParams.hasOwnProperty(setting.name))
|
||||||
|
{
|
||||||
|
if(setting.valid)
|
||||||
|
{
|
||||||
|
setting.choice = jobParams[setting.name].value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Clear jobParams of invalid settings
|
||||||
|
jobParams[setting.name] = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function getChoices(name) {
|
function getChoices(name) {
|
||||||
return isValid(name) ? printer.attrs[name+"-supported"].value : [];
|
return isValid(name) ? printer.attrs[name+"-supported"].value : [];
|
||||||
|
@ -117,48 +127,48 @@ Page {
|
||||||
name: "sides"
|
name: "sides"
|
||||||
prettyName: qsTr("Sides")
|
prettyName: qsTr("Sides")
|
||||||
valid: utils.isValid(name)
|
valid: utils.isValid(name)
|
||||||
choice: utils.getInitialChoice(name)
|
|
||||||
choices: utils.getChoices(name)
|
choices: utils.getChoices(name)
|
||||||
default_choice: utils.getDefaultChoice(name)
|
default_choice: utils.getDefaultChoice(name)
|
||||||
mime_type: selectedFileType
|
mime_type: selectedFileType
|
||||||
|
|
||||||
onChoiceChanged: page.choiceMade(this)
|
onChoiceChanged: page.choiceMade(this)
|
||||||
|
Component.onCompleted: utils.setInitialChoice(this)
|
||||||
}
|
}
|
||||||
ChoiceSetting {
|
ChoiceSetting {
|
||||||
tag: IppMsg.Keyword
|
tag: IppMsg.Keyword
|
||||||
name: "media"
|
name: "media"
|
||||||
prettyName: qsTr("Print media")
|
prettyName: qsTr("Print media")
|
||||||
valid: utils.isValid(name)
|
valid: utils.isValid(name)
|
||||||
choice: utils.getInitialChoice(name)
|
|
||||||
choices: utils.getChoices(name)
|
choices: utils.getChoices(name)
|
||||||
default_choice: utils.getDefaultChoice(name)
|
default_choice: utils.getDefaultChoice(name)
|
||||||
mime_type: selectedFileType
|
mime_type: selectedFileType
|
||||||
|
|
||||||
onChoiceChanged: page.choiceMade(this)
|
onChoiceChanged: page.choiceMade(this)
|
||||||
|
Component.onCompleted: utils.setInitialChoice(this)
|
||||||
}
|
}
|
||||||
IntegerSetting {
|
IntegerSetting {
|
||||||
tag: IppMsg.Integer
|
tag: IppMsg.Integer
|
||||||
name: "copies"
|
name: "copies"
|
||||||
prettyName: qsTr("Copies")
|
prettyName: qsTr("Copies")
|
||||||
valid: utils.isValid(name)
|
valid: utils.isValid(name)
|
||||||
choice: utils.getInitialChoice(name)
|
|
||||||
low: valid ? printer.attrs[name+"-supported"].value.low : 0
|
low: valid ? printer.attrs[name+"-supported"].value.low : 0
|
||||||
high: valid ? printer.attrs[name+"-supported"].value.high : 0
|
high: valid ? printer.attrs[name+"-supported"].value.high : 0
|
||||||
default_choice: utils.getDefaultChoice(name)
|
default_choice: utils.getDefaultChoice(name)
|
||||||
|
|
||||||
onChoiceChanged: page.choiceMade(this)
|
onChoiceChanged: page.choiceMade(this)
|
||||||
|
Component.onCompleted: utils.setInitialChoice(this)
|
||||||
}
|
}
|
||||||
ChoiceSetting {
|
ChoiceSetting {
|
||||||
tag: IppMsg.Keyword
|
tag: IppMsg.Keyword
|
||||||
name: "multiple-document-handling"
|
name: "multiple-document-handling"
|
||||||
prettyName: qsTr("Collated copies")
|
prettyName: qsTr("Collated copies")
|
||||||
valid: utils.isValid(name)
|
valid: utils.isValid(name)
|
||||||
choice: utils.getInitialChoice(name)
|
|
||||||
choices: utils.getChoices(name)
|
choices: utils.getChoices(name)
|
||||||
default_choice: utils.getDefaultChoice(name)
|
default_choice: utils.getDefaultChoice(name)
|
||||||
mime_type: selectedFileType
|
mime_type: selectedFileType
|
||||||
|
|
||||||
onChoiceChanged: page.choiceMade(this)
|
onChoiceChanged: page.choiceMade(this)
|
||||||
|
Component.onCompleted: utils.setInitialChoice(this)
|
||||||
}
|
}
|
||||||
RangeSetting {
|
RangeSetting {
|
||||||
tag: IppMsg.IntegerRange
|
tag: IppMsg.IntegerRange
|
||||||
|
@ -166,82 +176,82 @@ Page {
|
||||||
prettyName: qsTr("Page range")
|
prettyName: qsTr("Page range")
|
||||||
valid: (utils.isValid(name) || ConvertChecker.pdf) &&
|
valid: (utils.isValid(name) || ConvertChecker.pdf) &&
|
||||||
(selectedFileType == "application/pdf" || Mimer.isOffice(selectedFileType))
|
(selectedFileType == "application/pdf" || Mimer.isOffice(selectedFileType))
|
||||||
choice: utils.getInitialChoice(name)
|
|
||||||
|
|
||||||
property var pdfpages: ConvertChecker.pdfPages(selectedFile)
|
property var pdfpages: ConvertChecker.pdfPages(selectedFile)
|
||||||
high: pdfpages == 0 ? 65535 : pdfpages
|
high: pdfpages == 0 ? 65535 : pdfpages
|
||||||
|
|
||||||
onChoiceChanged: page.choiceMade(this)
|
onChoiceChanged: page.choiceMade(this)
|
||||||
|
Component.onCompleted: utils.setInitialChoice(this)
|
||||||
}
|
}
|
||||||
ChoiceSetting {
|
ChoiceSetting {
|
||||||
tag: IppMsg.Keyword
|
tag: IppMsg.Keyword
|
||||||
name: "print-color-mode"
|
name: "print-color-mode"
|
||||||
prettyName: qsTr("Color mode")
|
prettyName: qsTr("Color mode")
|
||||||
valid: utils.isValid(name)
|
valid: utils.isValid(name)
|
||||||
choice: utils.getInitialChoice(name)
|
|
||||||
choices: utils.getChoices(name)
|
choices: utils.getChoices(name)
|
||||||
default_choice: utils.getDefaultChoice(name)
|
default_choice: utils.getDefaultChoice(name)
|
||||||
mime_type: selectedFileType
|
mime_type: selectedFileType
|
||||||
|
|
||||||
onChoiceChanged: page.choiceMade(this)
|
onChoiceChanged: page.choiceMade(this)
|
||||||
|
Component.onCompleted: utils.setInitialChoice(this)
|
||||||
}
|
}
|
||||||
ChoiceSetting {
|
ChoiceSetting {
|
||||||
tag: IppMsg.Enum
|
tag: IppMsg.Enum
|
||||||
name: "print-quality"
|
name: "print-quality"
|
||||||
prettyName: qsTr("Quality")
|
prettyName: qsTr("Quality")
|
||||||
choice: utils.getInitialChoice(name)
|
|
||||||
valid: utils.isValid(name)
|
valid: utils.isValid(name)
|
||||||
choices: utils.getChoices(name)
|
choices: utils.getChoices(name)
|
||||||
default_choice: utils.getDefaultChoice(name)
|
default_choice: utils.getDefaultChoice(name)
|
||||||
mime_type: selectedFileType
|
mime_type: selectedFileType
|
||||||
|
|
||||||
onChoiceChanged: page.choiceMade(this)
|
onChoiceChanged: page.choiceMade(this)
|
||||||
|
Component.onCompleted: utils.setInitialChoice(this)
|
||||||
}
|
}
|
||||||
ChoiceSetting {
|
ChoiceSetting {
|
||||||
tag: IppMsg.Resolution
|
tag: IppMsg.Resolution
|
||||||
name: "printer-resolution"
|
name: "printer-resolution"
|
||||||
prettyName: qsTr("Resolution")
|
prettyName: qsTr("Resolution")
|
||||||
valid: utils.isValid(name)
|
valid: utils.isValid(name)
|
||||||
choice: utils.getInitialChoice(name)
|
|
||||||
choices: utils.getChoices(name)
|
choices: utils.getChoices(name)
|
||||||
default_choice: utils.getDefaultChoice(name)
|
default_choice: utils.getDefaultChoice(name)
|
||||||
mime_type: selectedFileType
|
mime_type: selectedFileType
|
||||||
|
|
||||||
onChoiceChanged: page.choiceMade(this)
|
onChoiceChanged: page.choiceMade(this)
|
||||||
|
Component.onCompleted: utils.setInitialChoice(this)
|
||||||
}
|
}
|
||||||
ChoiceSetting {
|
ChoiceSetting {
|
||||||
tag: IppMsg.MimeMediaType
|
tag: IppMsg.MimeMediaType
|
||||||
name: "document-format"
|
name: "document-format"
|
||||||
prettyName: qsTr("Transfer format")
|
prettyName: qsTr("Transfer format")
|
||||||
valid: utils.isValid(name)
|
valid: utils.isValid(name)
|
||||||
choice: utils.getInitialChoice(name)
|
|
||||||
choices: utils.getChoices(name)
|
choices: utils.getChoices(name)
|
||||||
default_choice: utils.getDefaultChoice(name)
|
default_choice: utils.getDefaultChoice(name)
|
||||||
mime_type: selectedFileType
|
mime_type: selectedFileType
|
||||||
|
|
||||||
onChoiceChanged: page.choiceMade(this)
|
onChoiceChanged: page.choiceMade(this)
|
||||||
|
Component.onCompleted: utils.setInitialChoice(this)
|
||||||
}
|
}
|
||||||
ChoiceSetting {
|
ChoiceSetting {
|
||||||
tag: IppMsg.Keyword
|
tag: IppMsg.Keyword
|
||||||
name: "media-source"
|
name: "media-source"
|
||||||
prettyName: qsTr("Media source")
|
prettyName: qsTr("Media source")
|
||||||
valid: utils.isValid(name)
|
valid: utils.isValid(name)
|
||||||
choice: utils.getInitialChoice(name)
|
|
||||||
choices: utils.getChoices(name)
|
choices: utils.getChoices(name)
|
||||||
default_choice: utils.getDefaultChoice(name)
|
default_choice: utils.getDefaultChoice(name)
|
||||||
mime_type: selectedFileType
|
mime_type: selectedFileType
|
||||||
|
|
||||||
onChoiceChanged: page.choiceMade(this)
|
onChoiceChanged: page.choiceMade(this)
|
||||||
|
Component.onCompleted: utils.setInitialChoice(this)
|
||||||
}
|
}
|
||||||
MediaColSetting {
|
MediaColSetting {
|
||||||
tag: IppMsg.BeginCollection
|
tag: IppMsg.BeginCollection
|
||||||
name: "media-col"
|
name: "media-col"
|
||||||
prettyName: qsTr("Zero margins")
|
prettyName: qsTr("Zero margins")
|
||||||
valid: false
|
valid: false
|
||||||
choice: utils.getInitialChoice(name)
|
|
||||||
printer: page.printer
|
printer: page.printer
|
||||||
|
|
||||||
onChoiceChanged: page.choiceMade(this)
|
onChoiceChanged: page.choiceMade(this)
|
||||||
|
Component.onCompleted: utils.setInitialChoice(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue