CUPS: Use default cups job-priority instead of 50

This also reads the job-priority from lpoptions if set there for the particular printer

Change-Id: I75d983c377d2135a0b0d3e028829a7384a5e1897
Reviewed-by: Laurent Montel <laurent.montel@kdab.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
This commit is contained in:
Albert Astals Cid 2017-12-06 10:19:13 +01:00
parent c61810b6f5
commit ad77a2447e
5 changed files with 26 additions and 7 deletions

View File

@ -427,6 +427,8 @@ QVariant QPpdPrintDevice::property(QPrintDevice::PrintDevicePropertyKey key) con
{
if (key == PDPK_PpdFile)
return QVariant::fromValue<ppd_file_t *>(m_ppd);
else if (key == PDPK_CupsJobPriority)
return printerOption(QStringLiteral("job-priority"));
return QVariant();
}

View File

@ -333,7 +333,7 @@ QPrintPropertiesDialog::QPrintPropertiesDialog(QPrinter *printer, QPrintDevice *
widget.pageSetup->setPrinter(printer, outputFormat, printerName);
#if QT_CONFIG(cupsjobwidget)
m_jobOptions = new QCupsJobWidget(printer);
m_jobOptions = new QCupsJobWidget(printer, currentPrintDevice);
widget.tabs->insertTab(1, m_jobOptions, tr("Job Options"));
#endif

View File

@ -67,8 +67,9 @@ 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_PpdFile QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase)
#define PDPK_PpdOption QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 1)
#define PDPK_CupsJobPriority QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 2)
class Q_PRINTSUPPORT_EXPORT QCUPSSupport
{

View File

@ -52,6 +52,8 @@
#include <QPrinter>
#include <QPrintEngine>
#include <kernel/qprintdevice_p.h>
QT_BEGIN_NAMESPACE
/*!
@ -64,9 +66,10 @@ QT_BEGIN_NAMESPACE
\inmodule QtPrintSupport
*/
QCupsJobWidget::QCupsJobWidget(QPrinter *printer, QWidget *parent)
QCupsJobWidget::QCupsJobWidget(QPrinter *printer, QPrintDevice *printDevice, QWidget *parent)
: QWidget(parent),
m_printer(printer)
m_printer(printer),
m_printDevice(printDevice)
{
m_ui.setupUi(this);
//set all the default values
@ -151,7 +154,18 @@ QString QCupsJobWidget::jobBilling() const
void QCupsJobWidget::initJobPriority()
{
setJobPriority(50);
int priority = -1;
if (m_printDevice) {
bool ok;
priority = m_printDevice->property(PDPK_CupsJobPriority).toInt(&ok);
if (!ok)
priority = -1;
}
if (priority < 0 || priority > 100)
priority = 50;
setJobPriority(priority);
}
void QCupsJobWidget::setJobPriority(int jobPriority)

View File

@ -65,13 +65,14 @@ QT_BEGIN_NAMESPACE
class QString;
class QTime;
class QPrinter;
class QPrintDevice;
class QCupsJobWidget : public QWidget
{
Q_OBJECT
public:
explicit QCupsJobWidget(QPrinter *printer, QWidget *parent = nullptr);
explicit QCupsJobWidget(QPrinter *printer, QPrintDevice *printDevice, QWidget *parent = nullptr);
~QCupsJobWidget();
void setupPrinter();
@ -102,6 +103,7 @@ private:
void initBannerPages();
QPrinter *m_printer;
QPrintDevice *m_printDevice;
Ui::QCupsJobWidget m_ui;
Q_DISABLE_COPY(QCupsJobWidget)