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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
console.log(JSON.stringify(printer.attrs))
|
|
|
|
}
|
|
|
|
|
|
|
|
// To enable PullDownMenu, place our content in a SilicaFlickable
|
|
|
|
SilicaFlickable {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
// PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView
|
|
|
|
PullDownMenu {
|
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Print")
|
|
|
|
onClicked: {
|
|
|
|
console.log(JSON.stringify(jobParams))
|
2020-05-14 22:05:23 +03:00
|
|
|
pageStack.replace(Qt.resolvedUrl("BusyPage.qml"),{printer:printer},
|
|
|
|
PageStackAction.Immediate)
|
2020-06-06 15:59:44 +03:00
|
|
|
printer.print(jobParams, page.selectedFile,
|
2020-06-07 15:33:35 +03:00
|
|
|
alwaysConvertSetting.value,
|
2020-06-21 16:49:50 +03:00
|
|
|
removeRedundantConvertAttrsSetting.value,
|
|
|
|
alwaysUseMediaColSetting.value)
|
2019-12-01 22:27:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ListModel {
|
|
|
|
id:mod
|
2020-06-06 18:20:30 +03:00
|
|
|
ListElement {name: "sides"; prettyName: qsTr("Sides"); tag: IppMsg.Enum}
|
|
|
|
ListElement {name: "media"; prettyName: qsTr("Print media"); tag: IppMsg.Keyword}
|
|
|
|
ListElement {name: "copies"; prettyName: qsTr("Copies"); tag: IppMsg.Integer}
|
2020-08-01 21:18:47 +03:00
|
|
|
ListElement {name: "page-ranges"; prettyName: qsTr("Page range"); tag: IppMsg.IntegerRange}
|
2020-06-06 18:20:30 +03:00
|
|
|
ListElement {name: "print-color-mode"; prettyName: qsTr("Color mode"); tag: IppMsg.Enum}
|
|
|
|
// ListElement {name: "orientation-requested"; prettyName: qsTr("Orientation"); tag: IppMsg.Enum}
|
|
|
|
ListElement {name: "print-quality"; prettyName: qsTr("Quality"); tag: IppMsg.Enum}
|
|
|
|
ListElement {name: "printer-resolution"; prettyName: qsTr("Resolution"); tag: IppMsg.Resolution}
|
|
|
|
ListElement {name: "document-format"; prettyName: qsTr("Transfer format"); tag: IppMsg.MimeMediaType}
|
|
|
|
ListElement {name: "media-source"; prettyName: qsTr("Media source"); tag: IppMsg.Keyword}
|
2020-06-16 20:51:29 +03:00
|
|
|
ListElement {name: "media-col"; prettyName: qsTr("Zero margins"); tag: IppMsg.BeginCollection}
|
2019-12-01 22:27:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
SilicaListView {
|
|
|
|
id: listView
|
|
|
|
model: mod
|
|
|
|
clip: true
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
width: parent.width
|
|
|
|
header: PageHeader {
|
|
|
|
id: pageHeader
|
|
|
|
title: printer.attrs["printer-name"].value
|
|
|
|
description: selectedFile
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
delegate: ListItem {
|
|
|
|
id: delegate
|
|
|
|
property alias loaderItem: loader.item
|
|
|
|
|
|
|
|
openMenuOnPressAndHold: false
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: loader
|
|
|
|
anchors.fill: parent
|
2020-06-07 12:06:14 +03:00
|
|
|
|
|
|
|
onLoaded: {
|
2020-06-16 20:51:29 +03:00
|
|
|
delegate.visible = true
|
2020-06-07 12:06:14 +03:00
|
|
|
if(loaderItem.menu.enabled)
|
|
|
|
{
|
|
|
|
menu = loaderItem.menu
|
|
|
|
loaderItem.clicked.connect(openMenu)
|
|
|
|
}
|
|
|
|
loaderItem.choiceMade.connect(function(tag, choice) {
|
|
|
|
console.log("choice changed", tag, JSON.stringify(choice))
|
2020-06-16 20:51:29 +03:00
|
|
|
if(choice != undefined)
|
|
|
|
{
|
|
|
|
jobParams[name] = {tag: tag, value: choice};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
jobParams[name] = undefined
|
|
|
|
}
|
2020-06-07 12:06:14 +03:00
|
|
|
console.log(JSON.stringify(jobParams));
|
|
|
|
})
|
|
|
|
}
|
2019-12-01 22:27:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
switch(tag) {
|
2020-06-06 18:20:30 +03:00
|
|
|
case IppMsg.Integer:
|
2020-08-24 22:45:45 +03:00
|
|
|
var valid = printer.attrs.hasOwnProperty(name+"-supported")
|
2019-12-17 23:10:05 +03:00
|
|
|
loader.setSource("../components/IntegerSetting.qml",
|
2019-12-01 22:27:00 +03:00
|
|
|
{name: name,
|
|
|
|
prettyName: prettyName,
|
|
|
|
tag: tag,
|
2020-08-24 22:45:45 +03:00
|
|
|
valid: valid,
|
|
|
|
low: valid ? printer.attrs[name+"-supported"].value.low : 0,
|
|
|
|
high: valid ? printer.attrs[name+"-supported"].value.high : 0,
|
2020-06-16 20:51:29 +03:00
|
|
|
default_choice: printer.attrs.hasOwnProperty(name+"-default") ? printer.attrs[name+"-default"].value : undefined
|
2019-12-01 22:27:00 +03:00
|
|
|
})
|
|
|
|
break
|
2020-06-06 18:20:30 +03:00
|
|
|
case IppMsg.IntegerRange:
|
2020-08-01 21:18:47 +03:00
|
|
|
var valid = printer.attrs.hasOwnProperty(name+"-supported") &&
|
|
|
|
name=="page-ranges" && Mimer.get_type(selectedFile) == "application/pdf";
|
2020-08-01 21:43:52 +03:00
|
|
|
var pdfpages = ConvertChecker.pdfPages(selectedFile);
|
2019-12-17 23:10:05 +03:00
|
|
|
loader.setSource("../components/RangeSetting.qml",
|
2019-12-01 22:27:00 +03:00
|
|
|
{name: name,
|
|
|
|
prettyName: prettyName,
|
2020-02-17 21:58:46 +03:00
|
|
|
tag: tag,
|
2020-08-01 21:18:47 +03:00
|
|
|
valid: valid,
|
2020-08-01 21:43:52 +03:00
|
|
|
high: name=="page-ranges" ? (pdfpages == 0 ? 65535 : pdfpages) : 0
|
2019-12-01 22:27:00 +03:00
|
|
|
})
|
|
|
|
break
|
2020-06-06 18:20:30 +03:00
|
|
|
case IppMsg.Resolution:
|
|
|
|
case IppMsg.Enum:
|
|
|
|
case IppMsg.Keyword:
|
|
|
|
case IppMsg.MimeMediaType:
|
2020-08-24 22:45:45 +03:00
|
|
|
var valid = printer.attrs.hasOwnProperty(name+"-supported")
|
2019-12-17 23:10:05 +03:00
|
|
|
loader.setSource("../components/ChoiceSetting.qml",
|
2019-12-01 22:27:00 +03:00
|
|
|
{name: name,
|
|
|
|
prettyName: prettyName,
|
|
|
|
tag: tag,
|
2020-08-24 22:45:45 +03:00
|
|
|
valid: valid,
|
|
|
|
choices: valid ? printer.attrs[name+"-supported"].value : [],
|
2020-06-16 20:51:29 +03:00
|
|
|
default_choice: printer.attrs.hasOwnProperty(name+"-default") ? printer.attrs[name+"-default"].value : "",
|
2020-06-04 22:31:46 +03:00
|
|
|
mime_type: Mimer.get_type(selectedFile)
|
2019-12-01 22:27:00 +03:00
|
|
|
})
|
|
|
|
break
|
2020-06-16 20:51:29 +03:00
|
|
|
case IppMsg.BeginCollection:
|
|
|
|
loader.setSource("../components/MediaColSetting.qml",
|
|
|
|
{name: name,
|
|
|
|
prettyName: prettyName,
|
|
|
|
tag: tag,
|
|
|
|
valid: false,
|
|
|
|
printer: printer
|
|
|
|
})
|
2019-12-01 22:27:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
VerticalScrollDecorator {}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|