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
|
2019-12-01 22:27:00 +03:00
|
|
|
import "utils.js" as Utils
|
2020-05-16 17:03:42 +03:00
|
|
|
import Nemo.Configuration 1.0
|
2019-12-01 22:27:00 +03:00
|
|
|
|
|
|
|
Page {
|
|
|
|
id: page
|
|
|
|
property var printer
|
|
|
|
property var jobParams: new Object();
|
|
|
|
property string selectedFile
|
|
|
|
|
2020-05-16 17:03:42 +03:00
|
|
|
ConfigurationValue
|
|
|
|
{
|
|
|
|
id: alwaysConvert
|
|
|
|
key: "/apps/harbour-seaprint/settings/always_convert"
|
|
|
|
defaultValue: false
|
|
|
|
}
|
|
|
|
|
2020-06-05 22:12:19 +03:00
|
|
|
ConfigurationValue
|
|
|
|
{
|
|
|
|
id: forceIncluDeDocumentFormat
|
|
|
|
key: "/apps/harbour-seaprint/settings/force_include_document_format"
|
|
|
|
defaultValue: false
|
|
|
|
}
|
|
|
|
|
2020-06-06 15:59:44 +03:00
|
|
|
ConfigurationValue
|
|
|
|
{
|
|
|
|
id: removeDuplexAttributesForRaster
|
|
|
|
key: "/apps/harbour-seaprint/settings/remove_duplex_attribute_for_raster"
|
|
|
|
defaultValue: false
|
|
|
|
}
|
|
|
|
|
2019-12-01 22:27:00 +03:00
|
|
|
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,
|
|
|
|
alwaysConvert.value, forceIncluDeDocumentFormat.value, removeDuplexAttributesForRaster.value)
|
2019-12-01 22:27:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ListModel {
|
|
|
|
id:mod
|
2020-06-05 19:49:52 +03:00
|
|
|
ListElement {name: "sides"; prettyName: qsTr("Sides"); tag: 0x23}
|
|
|
|
ListElement {name: "media"; prettyName: qsTr("Print media"); tag: 0x44}
|
|
|
|
ListElement {name: "copies"; prettyName: qsTr("Copies"); tag: 0x21}
|
|
|
|
// ListElement {name: "page-ranges"; prettyName: qsTr("Page range"); tag: 0x33}
|
|
|
|
ListElement {name: "print-color-mode"; prettyName: qsTr("Color mode"); tag: 0x23}
|
|
|
|
// ListElement {name: "orientation-requested"; prettyName: qsTr("Orientation"); tag: 0x23}
|
|
|
|
ListElement {name: "print-quality"; prettyName: qsTr("Quality"); tag: 0x23}
|
|
|
|
ListElement {name: "printer-resolution"; prettyName: qsTr("Resolution"); tag: 0x32}
|
|
|
|
ListElement {name: "document-format"; prettyName: qsTr("Transfer format"); tag: 0x49}
|
|
|
|
ListElement {name: "media-source"; prettyName: qsTr("Media source"); tag: 0x44}
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
switch(tag) {
|
|
|
|
case 0x21:
|
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-02-17 21:58:46 +03:00
|
|
|
valid: printer.attrs.hasOwnProperty(name+"-supported"),
|
2019-12-01 22:27:00 +03:00
|
|
|
low: printer.attrs[name+"-supported"].value.low,
|
|
|
|
high: printer.attrs[name+"-supported"].value.high,
|
|
|
|
default_choice: printer.attrs[name+"-default"].value
|
|
|
|
})
|
|
|
|
break
|
|
|
|
case 0x33:
|
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,
|
|
|
|
valid: false //TODO printer.attrs.hasOwnProperty(name+"-supported"),
|
2019-12-01 22:27:00 +03:00
|
|
|
})
|
|
|
|
break
|
|
|
|
case 0x32:
|
|
|
|
case 0x23:
|
2020-04-30 23:20:31 +03:00
|
|
|
case 0x44:
|
2020-06-04 22:31:46 +03:00
|
|
|
case 0x49:
|
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-02-17 21:58:46 +03:00
|
|
|
valid: printer.attrs.hasOwnProperty(name+"-supported"),
|
2020-06-05 21:05:48 +03:00
|
|
|
choices: name == "document-format" ? printer.attrs[name+"-supported"].value.concat(printer.additionalDocumentFormats)
|
|
|
|
: printer.attrs[name+"-supported"].value,
|
2020-06-04 22:31:46 +03:00
|
|
|
default_choice: printer.attrs[name+"-default"].value,
|
|
|
|
mime_type: Mimer.get_type(selectedFile)
|
2019-12-01 22:27:00 +03:00
|
|
|
})
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onLoaderItemChanged: {
|
|
|
|
menu = loaderItem.menu
|
|
|
|
loaderItem.clicked.connect(function() {
|
|
|
|
openMenu()
|
|
|
|
})
|
|
|
|
loaderItem.choiceMade.connect(function(tag, choice) {
|
|
|
|
console.log("choice changed", tag, JSON.stringify(choice))
|
|
|
|
jobParams[name] = {tag: tag, value: choice};
|
|
|
|
console.log(JSON.stringify(jobParams));
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
VerticalScrollDecorator {}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|