harbour-seaprint/qml/pages/PrinterPage.qml

156 lines
5.3 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
}
// 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")
2021-03-06 19:20:51 +03:00
mime_type: selectedFileType
}
ChoiceSetting {
tag: IppMsg.Keyword
name: "media"
prettyName: qsTr("Print media")
2021-03-06 19:20:51 +03:00
mime_type: selectedFileType
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")
2021-03-06 19:20:51 +03:00
mime_type: selectedFileType
}
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.Keyword
name: "print-color-mode"
prettyName: qsTr("Color mode")
2021-03-06 19:20:51 +03:00
mime_type: selectedFileType
}
ChoiceSetting {
tag: IppMsg.Enum
name: "print-quality"
prettyName: qsTr("Quality")
2021-03-06 19:20:51 +03:00
mime_type: selectedFileType
}
ChoiceSetting {
tag: IppMsg.Resolution
name: "printer-resolution"
prettyName: qsTr("Resolution")
2021-03-06 19:20:51 +03:00
mime_type: selectedFileType
}
ChoiceSetting {
tag: IppMsg.MimeMediaType
name: "document-format"
prettyName: qsTr("Transfer format")
2021-03-06 19:20:51 +03:00
mime_type: selectedFileType
}
ChoiceSetting {
tag: IppMsg.Keyword
name: "media-source"
prettyName: qsTr("Media source")
2021-03-06 19:20:51 +03:00
mime_type: selectedFileType
}
MediaColSetting {
tag: IppMsg.BeginCollection
name: "media-col"
prettyName: qsTr("Zero margins")
2019-12-01 22:27:00 +03:00
}
}
}
}