harbour-seaprint/qml/pages/JobsPage.qml

102 lines
3.2 KiB
QML
Raw Permalink Normal View History

2021-07-11 15:27:03 +03:00
import QtQuick 2.6
2019-12-08 15:55:56 +03:00
import Sailfish.Silica 1.0
2020-01-03 15:37:51 +03:00
import "utils.js" as Utils
2019-12-08 15:55:56 +03:00
Page {
id: page
allowedOrientations: Orientation.All
property var printer
Component.onCompleted: {
printer.getJobs()
}
2020-02-23 15:11:28 +03:00
Connections {
target: printer
onCancelStatus: {
if(status != true) {
notifier.notify(qsTr("Cancelling job failed"))
}
}
}
2019-12-08 15:55:56 +03:00
// 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 {
2019-12-12 22:53:46 +03:00
// MenuItem {
// text: qsTr("Remove all")
// onClicked: {
// console.log("todo")
// }
// }
2019-12-08 15:55:56 +03:00
MenuItem {
text: qsTr("Refresh")
onClicked: {
printer.getJobs();
}
}
}
SilicaListView {
anchors.fill: parent
id: listView
model: printer.jobs.length
header: PageHeader {
id: pageHeader
title: Utils.unknownForEmptyString(printer.attrs["printer-name"].value)
2019-12-13 21:24:14 +03:00
description: printer.jobs.length==1 ? printer.jobs.length+" "+qsTr("job") : printer.jobs.length+" "+qsTr("jobs")
2019-12-08 15:55:56 +03:00
}
delegate: ListItem {
2019-12-12 22:53:46 +03:00
id: jobDelegate
2019-12-08 15:55:56 +03:00
Label {
2019-12-12 22:53:46 +03:00
id: idLabel
2019-12-08 15:55:56 +03:00
leftPadding: Theme.horizontalPageMargin
anchors.verticalCenter: parent.verticalCenter
2020-01-03 15:37:51 +03:00
color: Theme.highlightColor
2019-12-08 15:55:56 +03:00
text: printer.jobs[index]["job-id"].value
}
2019-12-12 22:53:46 +03:00
2020-01-03 15:37:51 +03:00
Column {
2019-12-12 22:53:46 +03:00
anchors.left: idLabel.right
anchors.leftMargin: Theme.horizontalPageMargin
anchors.verticalCenter: parent.verticalCenter
2020-01-03 15:37:51 +03:00
Label {
text: printer.jobs[index]["job-name"] ? printer.jobs[index]["job-name"].value : qsTr("Untitled job")
}
Label {
font.pixelSize: Theme.fontSizeTiny
color: Theme.secondaryColor
2020-01-03 16:13:23 +03:00
property var msg: printer.jobs[index]["job-printer-state-message"] && printer.jobs[index]["job-printer-state-message"].value != ""
? " ("+printer.jobs[index]["job-printer-state-message"].value+")" : ""
text: Utils.ippName("job-state", printer.jobs[index]["job-state"].value)+msg
2020-01-03 15:37:51 +03:00
}
2019-12-12 22:53:46 +03:00
}
RemorseItem {
id: cancelRemorse
}
menu: ContextMenu {
MenuItem {
text: qsTr("Cancel job")
onClicked: {
cancelRemorse.execute(jobDelegate, qsTr("Cancelling job"),
function() {printer.cancelJob(printer.jobs[index]["job-id"].value) })
}
}
}
2019-12-08 15:55:56 +03:00
}
}
}
}