summaryrefslogtreecommitdiffstats
path: root/src/plugins/printsupport/cups
diff options
context:
space:
mode:
authorAlbert Astals Cid <albert.astals.cid@kdab.com>2017-12-04 14:05:55 +0100
committerAlbert Astals Cid <albert.astals.cid@kdab.com>2017-12-13 08:17:50 +0000
commite79efe94e3e77ee035ff7d046158a577759f8c7c (patch)
treeae4a7b2ed8526c5aefa893c70dd004334351e4ab /src/plugins/printsupport/cups
parent70f6a35c8f0b6a73f4d568532e1365cd3e8ff8dd (diff)
Allow access to ppd file and ppdMarkOption via QPpdPrintDevice::property/setProperty
Change-Id: I47b49b52121950fa8e3ea7a056974d9f3033490f Reviewed-by: Liang Qi <liang.qi@qt.io>
Diffstat (limited to 'src/plugins/printsupport/cups')
-rw-r--r--src/plugins/printsupport/cups/qppdprintdevice.cpp21
-rw-r--r--src/plugins/printsupport/cups/qppdprintdevice.h3
2 files changed, 24 insertions, 0 deletions
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.cpp b/src/plugins/printsupport/cups/qppdprintdevice.cpp
index 9efa83d409..ad829df23d 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.cpp
+++ b/src/plugins/printsupport/cups/qppdprintdevice.cpp
@@ -42,6 +42,8 @@
#include <QtCore/QMimeDatabase>
#include <qdebug.h>
+#include "private/qcups_p.h" // Only needed for PDPK_*
+
#ifndef QT_LINUXBASE // LSB merges everything into cups.h
#include <cups/language.h>
#endif
@@ -421,6 +423,25 @@ QPrint::ColorMode QPpdPrintDevice::defaultColorMode() const
return QPrint::GrayScale;
}
+QVariant QPpdPrintDevice::property(QPrintDevice::PrintDevicePropertyKey key) const
+{
+ if (key == PDPK_PpdFile)
+ return QVariant::fromValue<ppd_file_t *>(m_ppd);
+
+ return QVariant();
+}
+
+bool QPpdPrintDevice::setProperty(QPrintDevice::PrintDevicePropertyKey key, const QVariant &value)
+{
+ if (key == PDPK_PpdOption) {
+ const QStringList values = value.toStringList();
+ if (values.count() == 2)
+ return ppdMarkOption(m_ppd, values[0].toLatin1(), values[1].toLatin1()) == 0;
+ }
+
+ return false;
+}
+
#ifndef QT_NO_MIMETYPE
void QPpdPrintDevice::loadMimeTypes() const
{
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.h b/src/plugins/printsupport/cups/qppdprintdevice.h
index 3cd7518b14..2e4dd3ab3b 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.h
+++ b/src/plugins/printsupport/cups/qppdprintdevice.h
@@ -89,6 +89,9 @@ public:
QPrint::ColorMode defaultColorMode() const override;
+ QVariant property(QPrintDevice::PrintDevicePropertyKey key) const override;
+ bool setProperty(QPrintDevice::PrintDevicePropertyKey key, const QVariant &value) override;
+
protected:
void loadPageSizes() const override;
void loadResolutions() const override;