From c0fdb314832b3bfe884bb0a99fcd91329667ed13 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Fri, 9 Jul 2021 22:13:49 +0200 Subject: [PATCH] Add number-up and print-scaling format-dependent settings --- harbour-seaprint.pro | 1 + qml/components/ChoiceSetting.qml | 2 +- qml/components/DependentOn.qml | 40 ++++++++++++++++++++++++++ qml/components/Setting.qml | 7 ++++- qml/pages/PrinterPage.qml | 21 ++++++++++++++ qml/pages/utils.js | 16 +++++++++++ translations/harbour-seaprint-de.ts | 28 ++++++++++++++++++ translations/harbour-seaprint-es.ts | 28 ++++++++++++++++++ translations/harbour-seaprint-fr.ts | 28 ++++++++++++++++++ translations/harbour-seaprint-nl.ts | 28 ++++++++++++++++++ translations/harbour-seaprint-pl.ts | 28 ++++++++++++++++++ translations/harbour-seaprint-zh_CN.ts | 28 ++++++++++++++++++ translations/harbour-seaprint.ts | 28 ++++++++++++++++++ 13 files changed, 281 insertions(+), 2 deletions(-) create mode 100644 qml/components/DependentOn.qml diff --git a/harbour-seaprint.pro b/harbour-seaprint.pro index e4f7fed..149a7ee 100644 --- a/harbour-seaprint.pro +++ b/harbour-seaprint.pro @@ -50,6 +50,7 @@ SOURCES += src/harbour-seaprint.cpp \ src/svgprovider.cpp DISTFILES += qml/harbour-seaprint.qml \ + qml/components/DependentOn.qml \ qml/cover/CoverPage.qml \ qml/components/*qml \ qml/pages/*.qml \ diff --git a/qml/components/ChoiceSetting.qml b/qml/components/ChoiceSetting.qml index 16c5912..41a7b0c 100644 --- a/qml/components/ChoiceSetting.qml +++ b/qml/components/ChoiceSetting.qml @@ -19,7 +19,7 @@ Setting { if(limited_choices.length>num_large_choices) { var dialog = pageStack.push("LargeChoiceDialog.qml", - {name:name, choice: choice ? choice : default_choice, choices: limited_choices, + {name:name, choice: choice != undefined ? choice : default_choice, choices: limited_choices, preferred_choices: preferred_choices, preferred_choice_suffix: preferred_choice_suffix}) dialog.accepted.connect(function() { choice = dialog.choice diff --git a/qml/components/DependentOn.qml b/qml/components/DependentOn.qml new file mode 100644 index 0000000..528b09f --- /dev/null +++ b/qml/components/DependentOn.qml @@ -0,0 +1,40 @@ +import QtQuick 2.6 + +Item { + property alias target: targetConnection.target + property var values + property var overlap: [] + + Component.onCompleted: + { + for(var i in values) + { + if(target.limited_choices.indexOf(values[i]) != -1) + { + overlap.push(values[i]) + } + } + parent.valid = parent.valid && overlap != [] + } + + Connections { + id: targetConnection + onChoiceChanged: + { + if(overlap.indexOf(target.choice) == -1) + { + parent.reset() + } + } + } + Connections { + target: parent + onChoiceChanged: + { + if(parent.choice != undefined) + { + targetConnection.target.choice = overlap[0] + } + } + } +} diff --git a/qml/components/Setting.qml b/qml/components/Setting.qml index d38cdbe..ea12d5b 100644 --- a/qml/components/Setting.qml +++ b/qml/components/Setting.qml @@ -46,12 +46,17 @@ Item { property var menu property bool hasMenu: true + function reset() + { + choice = undefined + } + ContextMenu { id: resetMenu MenuItem { text: qsTr("Reset") - onClicked: choice = undefined + onClicked: reset() } } diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index 91d3cf7..3d24c5c 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -121,6 +121,16 @@ Page { property var pdfpages: ConvertChecker.pdfPages(selectedFile) high: pdfpages == 0 ? 65535 : pdfpages } + ChoiceSetting { + tag: IppMsg.Integer + name: "number-up" + prettyName: qsTr("Pages per page") + valid: !Mimer.isImage(selectedFileType) + DependentOn { + target: transferFormatSetting + values: [Mimer.PDF, Mimer.Postscript] + } + } ChoiceSetting { tag: IppMsg.Keyword name: "print-color-mode" @@ -137,6 +147,17 @@ Page { prettyName: qsTr("Resolution") } ChoiceSetting { + tag: IppMsg.Keyword + name: "print-scaling" + prettyName: qsTr("Scaling") + valid: _valid && selectedFileType == Mimer.JPEG + DependentOn { + target: transferFormatSetting + values: [Mimer.JPEG] + } + } + ChoiceSetting { + id: transferFormatSetting tag: IppMsg.MimeMediaType name: "document-format" prettyName: qsTr("Transfer format") diff --git a/qml/pages/utils.js b/qml/pages/utils.js index 72a9d0f..7a37ce8 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -211,6 +211,22 @@ function ippName(name, value) default: return value } + case "print-scaling": + switch(value) { + case "auto": + return qsTr("auto"); + case "auto-fit": + return qsTr("auto (fit)"); + case "fill": + return qsTr("fill"); + case "fit": + return qsTr("fit"); + case "none": + return qsTr("none"); + default: + return value; + } + case "document-format": switch(value) { case Mimer.OctetStream: diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index 526fdf9..376590e 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -503,6 +503,14 @@ Margins + + Pages per page + + + + Scaling + + RangeSetting @@ -873,5 +881,25 @@ my mailbox + + auto + + + + auto (fit) + + + + fill + + + + fit + + + + none + + diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index 20e522b..d728d8e 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -503,6 +503,14 @@ Margins + + Pages per page + + + + Scaling + + RangeSetting @@ -873,5 +881,25 @@ my mailbox + + auto + + + + auto (fit) + + + + fill + + + + fit + + + + none + + diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index bac48d7..37f7e00 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -503,6 +503,14 @@ Margins + + Pages per page + + + + Scaling + + RangeSetting @@ -873,5 +881,25 @@ my mailbox + + auto + + + + auto (fit) + + + + fill + + + + fit + + + + none + + diff --git a/translations/harbour-seaprint-nl.ts b/translations/harbour-seaprint-nl.ts index 9b22a58..9190a24 100644 --- a/translations/harbour-seaprint-nl.ts +++ b/translations/harbour-seaprint-nl.ts @@ -503,6 +503,14 @@ Margins + + Pages per page + + + + Scaling + + RangeSetting @@ -873,5 +881,25 @@ my mailbox + + auto + + + + auto (fit) + + + + fill + + + + fit + + + + none + + diff --git a/translations/harbour-seaprint-pl.ts b/translations/harbour-seaprint-pl.ts index 3e44a6c..c404cd1 100644 --- a/translations/harbour-seaprint-pl.ts +++ b/translations/harbour-seaprint-pl.ts @@ -503,6 +503,14 @@ Margins + + Pages per page + + + + Scaling + + RangeSetting @@ -873,5 +881,25 @@ my mailbox + + auto + + + + auto (fit) + + + + fill + + + + fit + + + + none + + diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index c6b48ee..faf57a4 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -503,6 +503,14 @@ Margins + + Pages per page + + + + Scaling + + RangeSetting @@ -873,5 +881,25 @@ my mailbox + + auto + + + + auto (fit) + + + + fill + + + + fit + + + + none + + diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index 425b33d..0801e7b 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -503,6 +503,14 @@ Margins + + Pages per page + + + + Scaling + + RangeSetting @@ -873,5 +881,25 @@ my mailbox + + auto + + + + auto (fit) + + + + fill + + + + fit + + + + none + +