diff options
author | Albert Astals Cid <albert.astals.cid@kdab.com> | 2017-12-06 11:28:55 +0100 |
---|---|---|
committer | Albert Astals Cid <albert.astals.cid@kdab.com> | 2017-12-18 15:23:43 +0000 |
commit | 83538a360e246ac2242977015e4a374a9f0e21b8 (patch) | |
tree | c598f921b0ce490d7d54983ba2d085783888f335 /src/printsupport/kernel | |
parent | 33f08a68c10df117c881a33cbf7421d172bbdd9d (diff) |
CUPS: Use printer job-sheets as default instead of none,none
This also reads the job-sheets from lpoptions if set there for the particular printer
Change-Id: I35aff103261ef58492779071d866e8a15ac78607
Reviewed-by: Laurent Montel <laurent.montel@kdab.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'src/printsupport/kernel')
-rw-r--r-- | src/printsupport/kernel/qcups.cpp | 26 | ||||
-rw-r--r-- | src/printsupport/kernel/qcups_p.h | 8 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp index b9e162abe9..aa1cdff5fb 100644 --- a/src/printsupport/kernel/qcups.cpp +++ b/src/printsupport/kernel/qcups.cpp @@ -150,6 +150,32 @@ static inline QString bannerPageToString(const QCUPSSupport::BannerPage bannerPa return QString(); } +static inline QCUPSSupport::BannerPage stringToBannerPage(const QString &bannerPage) +{ + if (bannerPage == QLatin1String("none")) return QCUPSSupport::NoBanner; + else if (bannerPage == QLatin1String("standard")) return QCUPSSupport::Standard; + else if (bannerPage == QLatin1String("unclassified")) return QCUPSSupport::Unclassified; + else if (bannerPage == QLatin1String("confidential")) return QCUPSSupport::Confidential; + else if (bannerPage == QLatin1String("classified")) return QCUPSSupport::Classified; + else if (bannerPage == QLatin1String("secret")) return QCUPSSupport::Secret; + else if (bannerPage == QLatin1String("topsecret")) return QCUPSSupport::TopSecret; + + return QCUPSSupport::NoBanner; +} + +QCUPSSupport::JobSheets QCUPSSupport::parseJobSheets(const QString &jobSheets) +{ + JobSheets result; + + const QStringList parts = jobSheets.split(QLatin1Char(',')); + if (parts.count() == 2) { + result.startBannerPage = stringToBannerPage(parts[0]); + result.endBannerPage = stringToBannerPage(parts[1]); + } + + return result; +} + void QCUPSSupport::setBannerPages(QPrinter *printer, const BannerPage startBannerPage, const BannerPage endBannerPage) { QStringList cupsOptions = cupsOptionsList(printer); diff --git a/src/printsupport/kernel/qcups_p.h b/src/printsupport/kernel/qcups_p.h index 3abccf2fb6..906a5486c0 100644 --- a/src/printsupport/kernel/qcups_p.h +++ b/src/printsupport/kernel/qcups_p.h @@ -70,6 +70,7 @@ QT_BEGIN_NAMESPACE #define PDPK_PpdFile QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase) #define PDPK_PpdOption QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 1) #define PDPK_CupsJobPriority QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 2) +#define PDPK_CupsJobSheets QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 3) class Q_PRINTSUPPORT_EXPORT QCUPSSupport { @@ -139,6 +140,13 @@ public: static void setPagesPerSheetLayout(QPrinter *printer, const PagesPerSheet pagesPerSheet, const PagesPerSheetLayout pagesPerSheetLayout); static void setPageRange(QPrinter *printer, int pageFrom, int pageTo); + + struct JobSheets + { + BannerPage startBannerPage = QCUPSSupport::NoBanner; + BannerPage endBannerPage = QCUPSSupport::NoBanner; + }; + static JobSheets parseJobSheets(const QString &jobSheets); }; Q_DECLARE_TYPEINFO(QCUPSSupport::JobHoldUntil, Q_PRIMITIVE_TYPE); Q_DECLARE_TYPEINFO(QCUPSSupport::BannerPage, Q_PRIMITIVE_TYPE); |