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

View file

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

View file

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