2021-03-21 00:45:58 +03:00
|
|
|
import QtQuick 2.6
|
2019-12-01 22:27:00 +03:00
|
|
|
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
|
2021-03-21 16:01:19 +03:00
|
|
|
property alias printer: settingsColumn.printer
|
|
|
|
property alias jobParams: settingsColumn.jobParams
|
|
|
|
property alias selectedFile: settingsColumn.selectedFile
|
|
|
|
property alias selectedFileType: settingsColumn.selectedFileType
|
2019-12-01 22:27:00 +03:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2021-06-28 21:31:42 +03:00
|
|
|
Connections {
|
|
|
|
target: printer
|
|
|
|
onAttrsChanged: {
|
|
|
|
if(Object.keys(printer.attrs).length === 0) {
|
|
|
|
pageStack.pop()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
2021-03-21 16:01:19 +03:00
|
|
|
contentHeight: settingsColumn.height
|
2020-11-23 20:34:38 +03:00
|
|
|
|
|
|
|
// PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView
|
|
|
|
PullDownMenu {
|
2021-03-21 00:45:58 +03:00
|
|
|
|
2021-03-21 14:49:54 +03:00
|
|
|
MenuLabel {
|
|
|
|
text: qsTr("Default settings for %1 on this printer").arg(db.simplifyType(selectedFileType).translatable)
|
|
|
|
visible: printer.attrs.hasOwnProperty("printer-uuid")
|
|
|
|
}
|
|
|
|
|
2021-03-21 00:45:58 +03:00
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Clear default settings")
|
|
|
|
visible: printer.attrs.hasOwnProperty("printer-uuid")
|
|
|
|
onClicked: {
|
2021-03-21 14:49:54 +03:00
|
|
|
db.removeJobSettings(printer.attrs["printer-uuid"].value, selectedFileType);
|
2021-03-21 00:45:58 +03:00
|
|
|
pageStack.pop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Save default settings")
|
|
|
|
visible: printer.attrs.hasOwnProperty("printer-uuid")
|
|
|
|
onClicked: {
|
|
|
|
var tmp = jobParams;
|
2021-03-21 15:09:38 +03:00
|
|
|
// Varies between documents, would be confusing to save
|
2021-03-21 00:45:58 +03:00
|
|
|
tmp["page-ranges"] = undefined;
|
2021-03-21 14:49:54 +03:00
|
|
|
db.setJobSettings(printer.attrs["printer-uuid"].value, selectedFileType, JSON.stringify(tmp))
|
2021-03-21 00:45:58 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-23 20:34:38 +03:00
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Print")
|
|
|
|
onClicked: {
|
|
|
|
console.log(JSON.stringify(jobParams))
|
|
|
|
pageStack.replace(Qt.resolvedUrl("BusyPage.qml"),{printer:printer},
|
|
|
|
PageStackAction.Immediate)
|
2021-06-19 18:47:11 +03:00
|
|
|
printer.print(jobParams, page.selectedFile)
|
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
|
|
|
|
2021-03-21 16:01:19 +03:00
|
|
|
SettingsColumn {
|
|
|
|
id: settingsColumn
|
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
|
2021-03-06 18:25:08 +03:00
|
|
|
description: Utils.basename(selectedFile)
|
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")
|
|
|
|
}
|
|
|
|
ChoiceSetting {
|
|
|
|
tag: IppMsg.Keyword
|
|
|
|
name: "media"
|
|
|
|
prettyName: qsTr("Print media")
|
2021-06-21 22:31:36 +03:00
|
|
|
preferred_choices: printer.attrs.hasOwnProperty("media-ready") ? printer.attrs["media-ready"].value : []
|
|
|
|
preferred_choice_suffix: qsTr("(loaded)")
|
2020-11-23 20:34:38 +03:00
|
|
|
}
|
|
|
|
IntegerSetting {
|
|
|
|
tag: IppMsg.Integer
|
|
|
|
name: "copies"
|
|
|
|
prettyName: qsTr("Copies")
|
|
|
|
}
|
|
|
|
ChoiceSetting {
|
|
|
|
tag: IppMsg.Keyword
|
|
|
|
name: "multiple-document-handling"
|
|
|
|
prettyName: qsTr("Collated copies")
|
|
|
|
}
|
|
|
|
RangeSetting {
|
|
|
|
tag: IppMsg.IntegerRange
|
|
|
|
name: "page-ranges"
|
|
|
|
prettyName: qsTr("Page range")
|
2021-03-21 16:01:19 +03:00
|
|
|
valid: (_valid || ConvertChecker.pdf) &&
|
2021-03-06 19:20:51 +03:00
|
|
|
(selectedFileType == "application/pdf" || Mimer.isOffice(selectedFileType))
|
2020-11-23 20:34:38 +03:00
|
|
|
|
|
|
|
property var pdfpages: ConvertChecker.pdfPages(selectedFile)
|
2021-03-21 00:45:58 +03:00
|
|
|
high: pdfpages == 0 ? 65535 : pdfpages
|
2020-11-23 20:34:38 +03:00
|
|
|
}
|
2021-07-09 23:13:49 +03:00
|
|
|
ChoiceSetting {
|
|
|
|
tag: IppMsg.Integer
|
|
|
|
name: "number-up"
|
|
|
|
prettyName: qsTr("Pages per page")
|
2021-07-31 13:35:41 +03:00
|
|
|
valid: _valid && !Mimer.isImage(selectedFileType)
|
2021-07-09 23:13:49 +03:00
|
|
|
DependentOn {
|
|
|
|
target: transferFormatSetting
|
|
|
|
values: [Mimer.PDF, Mimer.Postscript]
|
|
|
|
}
|
|
|
|
}
|
2020-11-23 20:34:38 +03:00
|
|
|
ChoiceSetting {
|
|
|
|
tag: IppMsg.Keyword
|
|
|
|
name: "print-color-mode"
|
|
|
|
prettyName: qsTr("Color mode")
|
|
|
|
}
|
|
|
|
ChoiceSetting {
|
|
|
|
tag: IppMsg.Enum
|
|
|
|
name: "print-quality"
|
|
|
|
prettyName: qsTr("Quality")
|
|
|
|
}
|
|
|
|
ChoiceSetting {
|
|
|
|
tag: IppMsg.Resolution
|
|
|
|
name: "printer-resolution"
|
|
|
|
prettyName: qsTr("Resolution")
|
|
|
|
}
|
|
|
|
ChoiceSetting {
|
2021-07-09 23:13:49 +03:00
|
|
|
tag: IppMsg.Keyword
|
|
|
|
name: "print-scaling"
|
|
|
|
prettyName: qsTr("Scaling")
|
|
|
|
valid: _valid && selectedFileType == Mimer.JPEG
|
|
|
|
DependentOn {
|
|
|
|
target: transferFormatSetting
|
|
|
|
values: [Mimer.JPEG]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ChoiceSetting {
|
|
|
|
id: transferFormatSetting
|
2020-11-23 20:34:38 +03:00
|
|
|
tag: IppMsg.MimeMediaType
|
|
|
|
name: "document-format"
|
|
|
|
prettyName: qsTr("Transfer format")
|
|
|
|
}
|
2021-07-09 23:46:21 +03:00
|
|
|
|
|
|
|
BarButton {
|
|
|
|
id: mediaButton
|
2021-07-11 15:30:23 +03:00
|
|
|
text: qsTr("Media handling")
|
2021-07-09 23:46:21 +03:00
|
|
|
}
|
2021-07-09 18:44:16 +03:00
|
|
|
ChoiceSetting {
|
2021-07-09 23:46:21 +03:00
|
|
|
visible: mediaButton.active
|
2021-07-09 18:44:16 +03:00
|
|
|
tag: IppMsg.Keyword
|
|
|
|
name: "media-type"
|
2021-07-09 20:17:45 +03:00
|
|
|
subkey: "media-col"
|
2021-07-09 18:44:16 +03:00
|
|
|
prettyName: qsTr("Media type")
|
|
|
|
}
|
2020-11-23 20:34:38 +03:00
|
|
|
ChoiceSetting {
|
2021-07-09 23:46:21 +03:00
|
|
|
visible: mediaButton.active
|
2020-11-23 20:34:38 +03:00
|
|
|
tag: IppMsg.Keyword
|
|
|
|
name: "media-source"
|
2021-07-09 20:17:45 +03:00
|
|
|
subkey: "media-col"
|
2020-11-23 20:34:38 +03:00
|
|
|
prettyName: qsTr("Media source")
|
|
|
|
}
|
2021-07-09 18:19:32 +03:00
|
|
|
ChoiceSetting {
|
2021-07-09 23:46:21 +03:00
|
|
|
visible: mediaButton.active
|
2021-07-09 18:19:32 +03:00
|
|
|
tag: IppMsg.Keyword
|
|
|
|
name: "output-bin"
|
|
|
|
prettyName: qsTr("Output bin")
|
|
|
|
}
|
2021-07-09 20:34:31 +03:00
|
|
|
|
|
|
|
BarButton {
|
|
|
|
id: marginsButton
|
|
|
|
text: qsTr("Margins")
|
|
|
|
}
|
2021-07-09 20:17:45 +03:00
|
|
|
ChoiceSetting {
|
2021-07-09 20:34:31 +03:00
|
|
|
visible: marginsButton.active
|
2021-07-09 20:17:45 +03:00
|
|
|
tag: IppMsg.Integer
|
|
|
|
name: "media-top-margin"
|
|
|
|
subkey: "media-col"
|
|
|
|
prettyName: qsTr("Top")
|
|
|
|
}
|
|
|
|
ChoiceSetting {
|
2021-07-09 20:34:31 +03:00
|
|
|
visible: marginsButton.active
|
2021-07-09 20:17:45 +03:00
|
|
|
tag: IppMsg.Integer
|
|
|
|
name: "media-bottom-margin"
|
|
|
|
subkey: "media-col"
|
|
|
|
prettyName: qsTr("Bottom")
|
|
|
|
}
|
|
|
|
ChoiceSetting {
|
2021-07-09 20:34:31 +03:00
|
|
|
visible: marginsButton.active
|
2021-07-09 20:17:45 +03:00
|
|
|
tag: IppMsg.Integer
|
|
|
|
name: "media-left-margin"
|
|
|
|
subkey: "media-col"
|
|
|
|
prettyName: qsTr("Left")
|
|
|
|
}
|
|
|
|
ChoiceSetting {
|
2021-07-09 20:34:31 +03:00
|
|
|
visible: marginsButton.active
|
2021-07-09 20:17:45 +03:00
|
|
|
tag: IppMsg.Integer
|
|
|
|
name: "media-right-margin"
|
|
|
|
subkey: "media-col"
|
|
|
|
prettyName: qsTr("Right")
|
2019-12-01 22:27:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|