2019-12-01 22:27:00 +03:00
|
|
|
import QtQuick 2.0
|
|
|
|
import Sailfish.Silica 1.0
|
2020-06-04 22:31:46 +03:00
|
|
|
import seaprint.mimer 1.0
|
2020-06-06 18:20:30 +03:00
|
|
|
import seaprint.ippmsg 1.0
|
2020-08-01 21:18:47 +03:00
|
|
|
import seaprint.convertchecker 1.0
|
2019-12-01 22:27:00 +03:00
|
|
|
import "utils.js" as Utils
|
2020-11-23 20:34:38 +03:00
|
|
|
import "../components"
|
2019-12-01 22:27:00 +03:00
|
|
|
|
|
|
|
Page {
|
2020-08-06 18:34:14 +03:00
|
|
|
allowedOrientations: Orientation.All
|
|
|
|
|
2019-12-01 22:27:00 +03:00
|
|
|
id: page
|
|
|
|
property var printer
|
|
|
|
property var jobParams: new Object();
|
|
|
|
property string selectedFile
|
|
|
|
|
2021-02-14 16:38:35 +03:00
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: wifi
|
|
|
|
onConnectedChanged: {
|
|
|
|
if(!wifi.connected) {
|
|
|
|
pageStack.pop()
|
|
|
|
}
|
|
|
|
}
|
2019-12-01 22:27:00 +03:00
|
|
|
}
|
|
|
|
|
2020-11-23 21:55:52 +03:00
|
|
|
function choiceMade(name, tag, choice)
|
|
|
|
{
|
|
|
|
if(choice != undefined)
|
|
|
|
{
|
|
|
|
jobParams[name] = {tag: tag, value: choice};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
jobParams[name] = undefined
|
|
|
|
}
|
|
|
|
console.log(JSON.stringify(jobParams));
|
|
|
|
}
|
|
|
|
|
2019-12-01 22:27:00 +03:00
|
|
|
// To enable PullDownMenu, place our content in a SilicaFlickable
|
|
|
|
SilicaFlickable {
|
2020-11-23 20:34:38 +03:00
|
|
|
anchors.fill: parent
|
2020-11-23 20:57:42 +03:00
|
|
|
contentHeight: settingColumn.height
|
2020-11-23 20:34:38 +03:00
|
|
|
|
|
|
|
// PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView
|
|
|
|
PullDownMenu {
|
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Print")
|
|
|
|
onClicked: {
|
|
|
|
console.log(JSON.stringify(jobParams))
|
|
|
|
pageStack.replace(Qt.resolvedUrl("BusyPage.qml"),{printer:printer},
|
|
|
|
PageStackAction.Immediate)
|
|
|
|
printer.print(jobParams, page.selectedFile,
|
|
|
|
alwaysConvertSetting.value,
|
|
|
|
alwaysUseMediaColSetting.value)
|
2019-12-01 22:27:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-23 20:34:38 +03:00
|
|
|
VerticalScrollDecorator {}
|
2019-12-01 22:27:00 +03:00
|
|
|
|
2020-11-23 20:34:38 +03:00
|
|
|
Column {
|
|
|
|
id: settingColumn
|
2019-12-01 22:27:00 +03:00
|
|
|
width: parent.width
|
2020-11-23 20:34:38 +03:00
|
|
|
|
|
|
|
PageHeader {
|
2019-12-01 22:27:00 +03:00
|
|
|
id: pageHeader
|
|
|
|
title: printer.attrs["printer-name"].value
|
|
|
|
description: selectedFile
|
|
|
|
}
|
|
|
|
|
2020-11-23 20:34:38 +03:00
|
|
|
Item {
|
|
|
|
id: utils
|
2019-12-01 22:27:00 +03:00
|
|
|
|
2020-11-23 20:34:38 +03:00
|
|
|
function isValid(name) {
|
|
|
|
return printer.attrs.hasOwnProperty(name+"-supported");
|
2019-12-01 22:27:00 +03:00
|
|
|
}
|
2020-11-23 20:34:38 +03:00
|
|
|
function getChoices(name) {
|
|
|
|
return isValid(name) ? printer.attrs[name+"-supported"].value : [];
|
2019-12-01 22:27:00 +03:00
|
|
|
}
|
2020-11-23 20:34:38 +03:00
|
|
|
function getDefaultChoice(name) {
|
2020-11-24 20:13:03 +03:00
|
|
|
return printer.attrs.hasOwnProperty(name+"-default") ? printer.attrs[name+"-default"].value : undefined;
|
2020-11-23 20:34:38 +03:00
|
|
|
}
|
|
|
|
}
|
2019-12-01 22:27:00 +03:00
|
|
|
|
2020-11-23 20:34:38 +03:00
|
|
|
ChoiceSetting {
|
|
|
|
tag: IppMsg.Keyword
|
|
|
|
name: "sides"
|
|
|
|
prettyName: qsTr("Sides")
|
|
|
|
valid: utils.isValid(name)
|
|
|
|
choices: utils.getChoices(name)
|
|
|
|
default_choice: utils.getDefaultChoice(name)
|
|
|
|
mime_type: Mimer.get_type(selectedFile)
|
2020-11-23 21:55:52 +03:00
|
|
|
|
|
|
|
onChoiceChanged: page.choiceMade(name, tag, choice)
|
2020-11-23 20:34:38 +03:00
|
|
|
}
|
|
|
|
ChoiceSetting {
|
|
|
|
tag: IppMsg.Keyword
|
|
|
|
name: "media"
|
|
|
|
prettyName: qsTr("Print media")
|
|
|
|
valid: utils.isValid(name)
|
|
|
|
choices: utils.getChoices(name)
|
|
|
|
default_choice: utils.getDefaultChoice(name)
|
|
|
|
mime_type: Mimer.get_type(selectedFile)
|
2020-11-23 21:55:52 +03:00
|
|
|
|
|
|
|
onChoiceChanged: page.choiceMade(name, tag, choice)
|
2020-11-23 20:34:38 +03:00
|
|
|
}
|
|
|
|
IntegerSetting {
|
|
|
|
tag: IppMsg.Integer
|
|
|
|
name: "copies"
|
|
|
|
prettyName: qsTr("Copies")
|
|
|
|
valid: utils.isValid(name)
|
|
|
|
low: valid ? printer.attrs[name+"-supported"].value.low : 0
|
|
|
|
high: valid ? printer.attrs[name+"-supported"].value.high : 0
|
2020-11-24 20:13:03 +03:00
|
|
|
default_choice: utils.getDefaultChoice(name)
|
2020-11-23 21:55:52 +03:00
|
|
|
|
|
|
|
onChoiceChanged: page.choiceMade(name, tag, choice)
|
2020-11-23 20:34:38 +03:00
|
|
|
}
|
|
|
|
ChoiceSetting {
|
|
|
|
tag: IppMsg.Keyword
|
|
|
|
name: "multiple-document-handling"
|
|
|
|
prettyName: qsTr("Collated copies")
|
|
|
|
valid: utils.isValid(name)
|
|
|
|
choices: utils.getChoices(name)
|
|
|
|
default_choice: utils.getDefaultChoice(name)
|
|
|
|
mime_type: Mimer.get_type(selectedFile)
|
2020-11-23 21:55:52 +03:00
|
|
|
|
|
|
|
onChoiceChanged: page.choiceMade(name, tag, choice)
|
2020-11-23 20:34:38 +03:00
|
|
|
}
|
|
|
|
RangeSetting {
|
|
|
|
tag: IppMsg.IntegerRange
|
|
|
|
name: "page-ranges"
|
|
|
|
prettyName: qsTr("Page range")
|
|
|
|
valid: (utils.isValid(name) || ConvertChecker.pdf) && Mimer.get_type(selectedFile) == "application/pdf"
|
|
|
|
|
|
|
|
property var pdfpages: ConvertChecker.pdfPages(selectedFile)
|
|
|
|
high: name=="page-ranges" ? (pdfpages == 0 ? 65535 : pdfpages) : 0
|
2020-11-23 21:55:52 +03:00
|
|
|
|
|
|
|
onChoiceChanged: page.choiceMade(name, tag, choice)
|
2020-11-23 20:34:38 +03:00
|
|
|
}
|
|
|
|
ChoiceSetting {
|
|
|
|
tag: IppMsg.Keyword
|
|
|
|
name: "print-color-mode"
|
|
|
|
prettyName: qsTr("Color mode")
|
|
|
|
valid: utils.isValid(name)
|
|
|
|
choices: utils.getChoices(name)
|
|
|
|
default_choice: utils.getDefaultChoice(name)
|
|
|
|
mime_type: Mimer.get_type(selectedFile)
|
2020-11-23 21:55:52 +03:00
|
|
|
|
|
|
|
onChoiceChanged: page.choiceMade(name, tag, choice)
|
2020-11-23 20:34:38 +03:00
|
|
|
}
|
|
|
|
ChoiceSetting {
|
|
|
|
tag: IppMsg.Enum
|
|
|
|
name: "print-quality"
|
|
|
|
prettyName: qsTr("Quality")
|
|
|
|
valid: utils.isValid(name)
|
|
|
|
choices: utils.getChoices(name)
|
|
|
|
default_choice: utils.getDefaultChoice(name)
|
|
|
|
mime_type: Mimer.get_type(selectedFile)
|
2020-11-23 21:55:52 +03:00
|
|
|
|
|
|
|
onChoiceChanged: page.choiceMade(name, tag, choice)
|
2020-11-23 20:34:38 +03:00
|
|
|
}
|
|
|
|
ChoiceSetting {
|
|
|
|
tag: IppMsg.Resolution
|
|
|
|
name: "printer-resolution"
|
|
|
|
prettyName: qsTr("Resolution")
|
|
|
|
valid: utils.isValid(name)
|
|
|
|
choices: utils.getChoices(name)
|
|
|
|
default_choice: utils.getDefaultChoice(name)
|
|
|
|
mime_type: Mimer.get_type(selectedFile)
|
2020-11-23 21:55:52 +03:00
|
|
|
|
|
|
|
onChoiceChanged: page.choiceMade(name, tag, choice)
|
2020-11-23 20:34:38 +03:00
|
|
|
}
|
|
|
|
ChoiceSetting {
|
|
|
|
tag: IppMsg.MimeMediaType
|
|
|
|
name: "document-format"
|
|
|
|
prettyName: qsTr("Transfer format")
|
|
|
|
valid: utils.isValid(name)
|
|
|
|
choices: utils.getChoices(name)
|
|
|
|
default_choice: utils.getDefaultChoice(name)
|
|
|
|
mime_type: Mimer.get_type(selectedFile)
|
2020-11-23 21:55:52 +03:00
|
|
|
|
|
|
|
onChoiceChanged: page.choiceMade(name, tag, choice)
|
2020-11-23 20:34:38 +03:00
|
|
|
}
|
|
|
|
ChoiceSetting {
|
|
|
|
tag: IppMsg.Keyword
|
|
|
|
name: "media-source"
|
|
|
|
prettyName: qsTr("Media source")
|
|
|
|
valid: utils.isValid(name)
|
|
|
|
choices: utils.getChoices(name)
|
|
|
|
default_choice: utils.getDefaultChoice(name)
|
|
|
|
mime_type: Mimer.get_type(selectedFile)
|
2020-11-23 21:55:52 +03:00
|
|
|
|
|
|
|
onChoiceChanged: page.choiceMade(name, tag, choice)
|
2020-11-23 20:34:38 +03:00
|
|
|
}
|
|
|
|
MediaColSetting {
|
|
|
|
tag: IppMsg.BeginCollection
|
|
|
|
name: "media-col"
|
|
|
|
prettyName: qsTr("Zero margins")
|
|
|
|
valid: false
|
|
|
|
printer: page.printer
|
2020-11-23 21:55:52 +03:00
|
|
|
|
|
|
|
onChoiceChanged: page.choiceMade(name, tag, choice)
|
2019-12-01 22:27:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|