Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP7:GA
libqt5-qtbase.16540
0011-CUPS-Use-printer-job-hold-until-as-default...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0011-CUPS-Use-printer-job-hold-until-as-default-instead-of-the-nohold.patch of Package libqt5-qtbase.16540
From 414a703036db6d5b4b1f48b85d8c3b4702f869ec Mon Sep 17 00:00:00 2001 From: Albert Astals Cid <albert.astals.cid@kdab.com> Date: Wed, 6 Dec 2017 13:00:30 +0100 Subject: [PATCH] CUPS: Use printer job-hold-until as default instead of the nohold This also reads the job-hold-until from lpoptions if set there for the particular printer Change-Id: Ic60fef675ab9f4760cd99ee9ac417b0478459681 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io> --- src/plugins/printsupport/cups/qppdprintdevice.cpp | 2 ++ src/printsupport/kernel/qcups.cpp | 31 +++++++++++++++++++++++ src/printsupport/kernel/qcups_p.h | 18 +++++++++---- src/printsupport/widgets/qcupsjobwidget.cpp | 10 ++++++-- 4 files changed, 54 insertions(+), 7 deletions(-) diff --git a/src/plugins/printsupport/cups/qppdprintdevice.cpp b/src/plugins/printsupport/cups/qppdprintdevice.cpp index 0fd6f5f..14c14fa 100644 --- a/src/plugins/printsupport/cups/qppdprintdevice.cpp +++ b/src/plugins/printsupport/cups/qppdprintdevice.cpp @@ -433,6 +433,8 @@ QVariant QPpdPrintDevice::property(QPrintDevice::PrintDevicePropertyKey key) con return printerOption(QStringLiteral("job-sheets")); else if (key == PDPK_CupsJobBilling) return printerOption(QStringLiteral("job-billing")); + else if (key == PDPK_CupsJobHoldUntil) + return printerOption(QStringLiteral("job-hold-until")); return QVariant(); } diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp index aa1cdff..50c6953 100644 --- a/src/printsupport/kernel/qcups.cpp +++ b/src/printsupport/kernel/qcups.cpp @@ -107,6 +107,37 @@ static inline QString jobHoldToString(const QCUPSSupport::JobHoldUntil jobHold, return QString(); } +QCUPSSupport::JobHoldUntilWithTime QCUPSSupport::parseJobHoldUntil(const QString &jobHoldUntil) +{ + if (jobHoldUntil == QLatin1String("indefinite")) { + return { QCUPSSupport::Indefinite, QTime() }; + } else if (jobHoldUntil == QLatin1String("day-time")) { + return { QCUPSSupport::DayTime, QTime() }; + } else if (jobHoldUntil == QLatin1String("night")) { + return { QCUPSSupport::Night, QTime() }; + } else if (jobHoldUntil == QLatin1String("second-shift")) { + return { QCUPSSupport::SecondShift, QTime() }; + } else if (jobHoldUntil == QLatin1String("third-shift")) { + return { QCUPSSupport::ThirdShift, QTime() }; + } else if (jobHoldUntil == QLatin1String("weekend")) { + return { QCUPSSupport::Weekend, QTime() }; + } + + + QTime parsedTime = QTime::fromString(jobHoldUntil, QStringLiteral("h:m:s")); + if (!parsedTime.isValid()) + parsedTime = QTime::fromString(jobHoldUntil, QStringLiteral("h:m")); + if (parsedTime.isValid()) { + // CUPS time is in UTC, user expects local time, so get the equivalent + QDateTime dateTimeUtc = QDateTime::currentDateTimeUtc(); + dateTimeUtc.setTime(parsedTime); + return { QCUPSSupport::SpecificTime, dateTimeUtc.toLocalTime().time() }; + } + + return { QCUPSSupport::NoHold, QTime() }; +} + + void QCUPSSupport::setJobHold(QPrinter *printer, const JobHoldUntil jobHold, const QTime &holdUntilTime) { QStringList cupsOptions = cupsOptionsList(printer); diff --git a/src/printsupport/kernel/qcups_p.h b/src/printsupport/kernel/qcups_p.h index c6bbacc..afddfdb 100644 --- a/src/printsupport/kernel/qcups_p.h +++ b/src/printsupport/kernel/qcups_p.h @@ -67,11 +67,12 @@ QT_BEGIN_NAMESPACE // removed from the dialogs. #define PPK_CupsOptions QPrintEngine::PrintEnginePropertyKey(0xfe00) -#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) -#define PDPK_CupsJobBilling QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 4) +#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) +#define PDPK_CupsJobBilling QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 4) +#define PDPK_CupsJobHoldUntil QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 5) class Q_PRINTSUPPORT_EXPORT QCUPSSupport { @@ -148,6 +149,13 @@ public: BannerPage endBannerPage = QCUPSSupport::NoBanner; }; static JobSheets parseJobSheets(const QString &jobSheets); + + struct JobHoldUntilWithTime + { + JobHoldUntil jobHold; + QTime time; + }; + static JobHoldUntilWithTime parseJobHoldUntil(const QString &jobHoldUntil); }; Q_DECLARE_TYPEINFO(QCUPSSupport::JobHoldUntil, Q_PRIMITIVE_TYPE); Q_DECLARE_TYPEINFO(QCUPSSupport::BannerPage, Q_PRIMITIVE_TYPE); diff --git a/src/printsupport/widgets/qcupsjobwidget.cpp b/src/printsupport/widgets/qcupsjobwidget.cpp index adaaff8..5d026d4 100644 --- a/src/printsupport/widgets/qcupsjobwidget.cpp +++ b/src/printsupport/widgets/qcupsjobwidget.cpp @@ -73,7 +73,6 @@ QCupsJobWidget::QCupsJobWidget(QPrinter *printer, QPrintDevice *printDevice, QWi { m_ui.setupUi(this); //set all the default values - //TODO restore last used values initJobHold(); initJobBilling(); initJobPriority(); @@ -105,7 +104,14 @@ void QCupsJobWidget::initJobHold() connect(m_ui.jobHoldComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(toggleJobHoldTime())); - setJobHold(QCUPSSupport::NoHold, QTime()); + QCUPSSupport::JobHoldUntilWithTime jobHoldWithTime; + + if (m_printDevice) { + const QString jobHoldUntilString = m_printDevice->property(PDPK_CupsJobHoldUntil).toString(); + jobHoldWithTime = QCUPSSupport::parseJobHoldUntil(jobHoldUntilString); + } + + setJobHold(jobHoldWithTime.jobHold, jobHoldWithTime.time); toggleJobHoldTime(); } -- 2.7.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor