Expose IPP type enums to QML

This commit is contained in:
Anton Thomasson 2020-06-06 17:20:30 +02:00
parent 37c0abee74
commit 231e7df644
4 changed files with 23 additions and 20 deletions

View file

@ -1,6 +1,7 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
import seaprint.mimer 1.0
import seaprint.ippmsg 1.0
import "utils.js" as Utils
import Nemo.Configuration 1.0
@ -55,16 +56,16 @@ Page {
ListModel {
id:mod
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}
ListElement {name: "sides"; prettyName: qsTr("Sides"); tag: IppMsg.Enum}
ListElement {name: "media"; prettyName: qsTr("Print media"); tag: IppMsg.Keyword}
ListElement {name: "copies"; prettyName: qsTr("Copies"); tag: IppMsg.Integer}
// ListElement {name: "page-ranges"; prettyName: qsTr("Page range"); tag: IppMsg.IntegerRange}
ListElement {name: "print-color-mode"; prettyName: qsTr("Color mode"); tag: IppMsg.Enum}
// ListElement {name: "orientation-requested"; prettyName: qsTr("Orientation"); tag: IppMsg.Enum}
ListElement {name: "print-quality"; prettyName: qsTr("Quality"); tag: IppMsg.Enum}
ListElement {name: "printer-resolution"; prettyName: qsTr("Resolution"); tag: IppMsg.Resolution}
ListElement {name: "document-format"; prettyName: qsTr("Transfer format"); tag: IppMsg.MimeMediaType}
ListElement {name: "media-source"; prettyName: qsTr("Media source"); tag: IppMsg.Keyword}
}
SilicaListView {
@ -96,7 +97,7 @@ Page {
Component.onCompleted: {
switch(tag) {
case 0x21:
case IppMsg.Integer:
loader.setSource("../components/IntegerSetting.qml",
{name: name,
prettyName: prettyName,
@ -107,7 +108,7 @@ Page {
default_choice: printer.attrs[name+"-default"].value
})
break
case 0x33:
case IppMsg.IntegerRange:
loader.setSource("../components/RangeSetting.qml",
{name: name,
prettyName: prettyName,
@ -115,10 +116,10 @@ Page {
valid: false //TODO printer.attrs.hasOwnProperty(name+"-supported"),
})
break
case 0x32:
case 0x23:
case 0x44:
case 0x49:
case IppMsg.Resolution:
case IppMsg.Enum:
case IppMsg.Keyword:
case IppMsg.MimeMediaType:
loader.setSource("../components/ChoiceSetting.qml",
{name: name,
prettyName: prettyName,

View file

@ -37,6 +37,7 @@ int main(int argc, char *argv[])
qmlRegisterSingletonType<Mimer>("seaprint.mimer", 1, 0, "Mimer", singletontype_provider<Mimer>);
qmlRegisterSingletonType<ConvertChecker>("seaprint.convertchecker", 1, 0, "ConvertChecker", singletontype_provider<ConvertChecker>);
qmlRegisterType<IppPrinter>("seaprint.ippprinter", 1, 0, "IppPrinter");
qmlRegisterUncreatableType<IppMsg>("seaprint.ippmsg", 1, 0, "IppMsg", "Only used to supply an enum type");
QQuickView* view = SailfishApp::createView();

View file

@ -4,6 +4,7 @@
#include "bytestream.h"
#include <QByteArray>
#include <QObject>
#include <QDebug>
#include <QUrl>
#include <QtNetwork>
@ -12,6 +13,7 @@
class IppMsg
{
Q_GADGET
public:
enum IppTag : quint8 {
@ -39,6 +41,7 @@ public:
NaturalLanguage = 0x48,
MimeMediaType = 0x49
};
Q_ENUMS(IppTag)
enum Operation : quint16 {
PrintJob = 0x0002,
@ -59,8 +62,8 @@ public:
PurgeJobs = 0x0012
};
IppMsg();
IppMsg(QNetworkReply* resp);
explicit IppMsg();
explicit IppMsg(QNetworkReply* resp);
IppMsg(QJsonObject opAttrs, QJsonObject jobAttrs = QJsonObject());
IppMsg(const IppMsg& other) = default;
~IppMsg();

View file

@ -31,8 +31,6 @@ public:
Q_INVOKABLE bool getJobs();
Q_INVOKABLE bool cancelJob(qint32 jobId);
bool hasPrinterDeviceIdCmd(QString cmd);
signals:
void urlChanged();
void attrsChanged();