harbour-seaprint/qml/pages/PrinterPage.qml

226 lines
7.4 KiB
QML
Raw Normal View History

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
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
}
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 {
anchors.fill: parent
2021-03-21 16:01:19 +03:00
contentHeight: settingsColumn.height
// 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
}
}
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)
2019-12-01 22:27:00 +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
PageHeader {
2019-12-01 22:27:00 +03:00
id: pageHeader
title: printer.attrs["printer-name"].value
description: Utils.basename(selectedFile)
2019-12-01 22:27:00 +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)")
}
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))
property var pdfpages: ConvertChecker.pdfPages(selectedFile)
2021-03-21 00:45:58 +03:00
high: pdfpages == 0 ? 65535 : pdfpages
}
ChoiceSetting {
tag: IppMsg.Integer
name: "number-up"
prettyName: qsTr("Pages per page")
valid: _valid && !Mimer.isImage(selectedFileType)
DependentOn {
target: transferFormatSetting
values: [Mimer.PDF, Mimer.Postscript]
}
}
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 {
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")
}
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
}
ChoiceSetting {
2021-07-09 23:46:21 +03:00
visible: mediaButton.active
tag: IppMsg.Keyword
name: "media-type"
subkey: "media-col"
prettyName: qsTr("Media type")
}
ChoiceSetting {
2021-07-09 23:46:21 +03:00
visible: mediaButton.active
tag: IppMsg.Keyword
name: "media-source"
subkey: "media-col"
prettyName: qsTr("Media source")
}
ChoiceSetting {
2021-07-09 23:46:21 +03:00
visible: mediaButton.active
tag: IppMsg.Keyword
name: "output-bin"
prettyName: qsTr("Output bin")
}
2021-07-09 20:34:31 +03:00
BarButton {
id: marginsButton
text: qsTr("Margins")
}
ChoiceSetting {
2021-07-09 20:34:31 +03:00
visible: marginsButton.active
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
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
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
tag: IppMsg.Integer
name: "media-right-margin"
subkey: "media-col"
prettyName: qsTr("Right")
2019-12-01 22:27:00 +03:00
}
}
}
}