summaryrefslogtreecommitdiffstats
path: root/src/plugins/printsupport
diff options
context:
space:
mode:
authorAlbert Astals Cid <albert.astals.cid@kdab.com>2017-12-29 15:18:52 +0100
committerAlbert Astals Cid <albert.astals.cid@kdab.com>2018-01-12 12:04:51 +0000
commitc45947aeefa1a83eda767edca4fd4c6f9404d3ff (patch)
tree5081bb5775dd4dd87567978e639b6167faa71fc7 /src/plugins/printsupport
parente35878bf57f4107fa1a49a8a4d552ea5ce1b53a9 (diff)
CUPS: Don't show choices that conflict with the printer installed options
Some options only make sense if the printer has installed some extensions, e.g. we should not shown "Staple" options if the Stapler addon is not installed, so with this change we use ppdInstallableConflict to know whether an option should be shown to the user or not. Change-Id: I5733e1ac8b667c26b292aeafc90a10c155b751a4 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'src/plugins/printsupport')
-rw-r--r--src/plugins/printsupport/cups/qppdprintdevice.cpp15
-rw-r--r--src/plugins/printsupport/cups/qppdprintdevice.h1
2 files changed, 14 insertions, 2 deletions
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.cpp b/src/plugins/printsupport/cups/qppdprintdevice.cpp
index 9c4b699c3e..340b1a1ff4 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.cpp
+++ b/src/plugins/printsupport/cups/qppdprintdevice.cpp
@@ -436,7 +436,7 @@ QVariant QPpdPrintDevice::property(QPrintDevice::PrintDevicePropertyKey key) con
else if (key == PDPK_CupsJobHoldUntil)
return printerOption(QStringLiteral("job-hold-until"));
- return QVariant();
+ return QPlatformPrintDevice::property(key);
}
bool QPpdPrintDevice::setProperty(QPrintDevice::PrintDevicePropertyKey key, const QVariant &value)
@@ -449,7 +449,18 @@ bool QPpdPrintDevice::setProperty(QPrintDevice::PrintDevicePropertyKey key, cons
}
}
- return false;
+ return QPlatformPrintDevice::setProperty(key, value);
+}
+
+bool QPpdPrintDevice::isFeatureAvailable(QPrintDevice::PrintDevicePropertyKey key, const QVariant &params) const
+{
+ if (key == PDPK_PpdChoiceIsInstallableConflict) {
+ const QStringList values = params.toStringList();
+ if (values.count() == 2)
+ return ppdInstallableConflict(m_ppd, values[0].toLatin1(), values[1].toLatin1());
+ }
+
+ return QPlatformPrintDevice::isFeatureAvailable(key, params);
}
#ifndef QT_NO_MIMETYPE
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.h b/src/plugins/printsupport/cups/qppdprintdevice.h
index 2e4dd3ab3b..9867083bd7 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.h
+++ b/src/plugins/printsupport/cups/qppdprintdevice.h
@@ -91,6 +91,7 @@ public:
QVariant property(QPrintDevice::PrintDevicePropertyKey key) const override;
bool setProperty(QPrintDevice::PrintDevicePropertyKey key, const QVariant &value) override;
+ bool isFeatureAvailable(QPrintDevice::PrintDevicePropertyKey key, const QVariant &params) const override;
protected:
void loadPageSizes() const override;