Add CUPS Banner Pages options to print support
Adds a way to set standard CUPS Banner Pages. This widget is part of the Job Options widget/tab in Properties dialog. [ChangeLog][QtPrintSupport][QPrintDialog] Added support for setting CUPS Banner pages in the print dialog. Change-Id: Ia7a22b7a0f51c12d170986caee61af7109e781e9 Reviewed-by: John Layt <jlayt@kde.org>bb10
parent
8a42502682
commit
ea3f8ff6d0
|
|
@ -433,6 +433,63 @@ void QCUPSSupport::setJobPriority(QPrinter *printer, int priority)
|
|||
setCupsOptions(printer, cupsOptions);
|
||||
}
|
||||
|
||||
void QCUPSSupport::setBannerPages(QPrinter *printer, const BannerPage startBannerPage, const BannerPage endBannerPage)
|
||||
{
|
||||
QStringList cupsOptions = cupsOptionsList(printer);
|
||||
QString startBanner, endBanner;
|
||||
|
||||
switch (startBannerPage) {
|
||||
case NoBanner:
|
||||
startBanner = QStringLiteral("none");
|
||||
break;
|
||||
case Standard:
|
||||
startBanner = QStringLiteral("standard");
|
||||
break;
|
||||
case Unclassified:
|
||||
startBanner = QStringLiteral("unclassified");
|
||||
break;
|
||||
case Confidential:
|
||||
startBanner = QStringLiteral("confidential");
|
||||
break;
|
||||
case Classified:
|
||||
startBanner = QStringLiteral("classified");
|
||||
break;
|
||||
case Secret:
|
||||
startBanner = QStringLiteral("secret");
|
||||
break;
|
||||
case TopSecret:
|
||||
startBanner = QStringLiteral("topsecret");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (endBannerPage) {
|
||||
case NoBanner:
|
||||
endBanner = QStringLiteral("none");
|
||||
break;
|
||||
case Standard:
|
||||
endBanner = QStringLiteral("standard");
|
||||
break;
|
||||
case Unclassified:
|
||||
endBanner = QStringLiteral("unclassified");
|
||||
break;
|
||||
case Confidential:
|
||||
endBanner = QStringLiteral("confidential");
|
||||
break;
|
||||
case Classified:
|
||||
endBanner = QStringLiteral("classified");
|
||||
break;
|
||||
case Secret:
|
||||
endBanner = QStringLiteral("secret");
|
||||
break;
|
||||
case TopSecret:
|
||||
endBanner = QStringLiteral("topsecret");
|
||||
break;
|
||||
}
|
||||
|
||||
setCupsOption(cupsOptions, QStringLiteral("job-sheets"), startBanner + QLatin1Char(',') + endBanner);
|
||||
setCupsOptions(printer, cupsOptions);
|
||||
}
|
||||
|
||||
bool QCUPSSupport::printerHasPPD(const char *printerName)
|
||||
{
|
||||
if (!isAvailable())
|
||||
|
|
|
|||
|
|
@ -103,6 +103,17 @@ public:
|
|||
SpecificTime
|
||||
};
|
||||
|
||||
// Enum for valid banner pages
|
||||
enum BannerPage {
|
||||
NoBanner = 0, //CUPS Default 'none'
|
||||
Standard,
|
||||
Unclassified,
|
||||
Confidential,
|
||||
Classified,
|
||||
Secret,
|
||||
TopSecret
|
||||
};
|
||||
|
||||
static bool isAvailable();
|
||||
static int cupsVersion() { return isAvailable() ? CUPS_VERSION_MAJOR*10000+CUPS_VERSION_MINOR*100+CUPS_VERSION_PATCH : 0; }
|
||||
int availablePrintersCount() const;
|
||||
|
|
@ -131,6 +142,7 @@ public:
|
|||
static void setJobHold(QPrinter *printer, const JobHoldUntil jobHold = NoHold, const QTime &holdUntilTime = QTime());
|
||||
static void setJobBilling(QPrinter *printer, const QString &jobBilling = QString());
|
||||
static void setJobPriority(QPrinter *printer, int priority = 50);
|
||||
static void setBannerPages(QPrinter *printer, const BannerPage startBannerPage, const BannerPage endBannerPage);
|
||||
|
||||
static bool printerHasPPD(const char *printerName);
|
||||
|
||||
|
|
@ -161,6 +173,7 @@ private:
|
|||
QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(QCUPSSupport::JobHoldUntil)
|
||||
Q_DECLARE_METATYPE(QCUPSSupport::BannerPage)
|
||||
|
||||
#endif // QT_NO_CUPS
|
||||
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ QCupsJobWidget::QCupsJobWidget(QWidget *parent)
|
|||
initJobHold();
|
||||
initJobBilling();
|
||||
initJobPriority();
|
||||
initBannerPages();
|
||||
}
|
||||
|
||||
QCupsJobWidget::~QCupsJobWidget()
|
||||
|
|
@ -91,6 +92,7 @@ void QCupsJobWidget::setupPrinter()
|
|||
QCUPSSupport::setJobHold(m_printer, jobHold(), jobHoldTime());
|
||||
QCUPSSupport::setJobBilling(m_printer, jobBilling());
|
||||
QCUPSSupport::setJobPriority(m_printer, jobPriority());
|
||||
QCUPSSupport::setBannerPages(m_printer, startBannerPage(), endBannerPage());
|
||||
}
|
||||
|
||||
void QCupsJobWidget::initJobHold()
|
||||
|
|
@ -168,4 +170,46 @@ int QCupsJobWidget::jobPriority() const
|
|||
return m_ui.jobPrioritySpinBox->value();
|
||||
}
|
||||
|
||||
void QCupsJobWidget::initBannerPages()
|
||||
{
|
||||
m_ui.startBannerPageCombo->addItem(tr("None", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::NoBanner));
|
||||
m_ui.startBannerPageCombo->addItem(tr("Standard", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::Standard));
|
||||
m_ui.startBannerPageCombo->addItem(tr("Unclassified", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::Unclassified));
|
||||
m_ui.startBannerPageCombo->addItem(tr("Confidential", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::Confidential));
|
||||
m_ui.startBannerPageCombo->addItem(tr("Classified", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::Classified));
|
||||
m_ui.startBannerPageCombo->addItem(tr("Secret", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::Secret));
|
||||
m_ui.startBannerPageCombo->addItem(tr("Top Secret", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::TopSecret));
|
||||
|
||||
m_ui.endBannerPageCombo->addItem(tr("None", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::NoBanner));
|
||||
m_ui.endBannerPageCombo->addItem(tr("Standard", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::Standard));
|
||||
m_ui.endBannerPageCombo->addItem(tr("Unclassified", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::Unclassified));
|
||||
m_ui.endBannerPageCombo->addItem(tr("Confidential", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::Confidential));
|
||||
m_ui.endBannerPageCombo->addItem(tr("Classified", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::Classified));
|
||||
m_ui.endBannerPageCombo->addItem(tr("Secret", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::Secret));
|
||||
m_ui.endBannerPageCombo->addItem(tr("Top Secret", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::TopSecret));
|
||||
|
||||
setStartBannerPage(QCUPSSupport::NoBanner);
|
||||
setEndBannerPage(QCUPSSupport::NoBanner);
|
||||
}
|
||||
|
||||
void QCupsJobWidget::setStartBannerPage(const QCUPSSupport::BannerPage bannerPage)
|
||||
{
|
||||
m_ui.startBannerPageCombo->setCurrentIndex(m_ui.startBannerPageCombo->findData(QVariant::fromValue(bannerPage)));
|
||||
}
|
||||
|
||||
QCUPSSupport::BannerPage QCupsJobWidget::startBannerPage() const
|
||||
{
|
||||
return m_ui.startBannerPageCombo->itemData(m_ui.startBannerPageCombo->currentIndex()).value<QCUPSSupport::BannerPage>();
|
||||
}
|
||||
|
||||
void QCupsJobWidget::setEndBannerPage(const QCUPSSupport::BannerPage bannerPage)
|
||||
{
|
||||
m_ui.endBannerPageCombo->setCurrentIndex(m_ui.endBannerPageCombo->findData(QVariant::fromValue(bannerPage)));
|
||||
}
|
||||
|
||||
QCUPSSupport::BannerPage QCupsJobWidget::endBannerPage() const
|
||||
{
|
||||
return m_ui.endBannerPageCombo->itemData(m_ui.endBannerPageCombo->currentIndex()).value<QCUPSSupport::BannerPage>();
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@
|
|||
<property name="windowTitle" >
|
||||
<string>Job</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3" >
|
||||
<item row="0" column="0" >
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="jobControlGroupBox" >
|
||||
<property name="title" >
|
||||
<string>Job Control</string>
|
||||
|
|
@ -72,23 +72,39 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="1" >
|
||||
<spacer name="verticalSpacer" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" rowspan="2" colspan="2">
|
||||
<widget class="QGroupBox" name="bannerPagesGroupBox">
|
||||
<property name="title">
|
||||
<string>Banner Pages</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="endBannerPageCombo"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="startBannerPageCombo"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="endBannerLabel">
|
||||
<property name="text">
|
||||
<string comment="Banner page at end">End:</string>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="startBannerLabel">
|
||||
<property name="text">
|
||||
<string comment="Banner page at start">Start:</string>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<item row="3" column="0">
|
||||
<spacer name="verticalSpacer_3" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
|
|
|||
|
|
@ -89,9 +89,16 @@ private:
|
|||
void setJobPriority(int priority = 50);
|
||||
int jobPriority() const;
|
||||
|
||||
void setStartBannerPage(const QCUPSSupport::BannerPage bannerPage = QCUPSSupport::NoBanner);
|
||||
QCUPSSupport::BannerPage startBannerPage() const;
|
||||
|
||||
void setEndBannerPage(const QCUPSSupport::BannerPage bannerPage = QCUPSSupport::NoBanner);
|
||||
QCUPSSupport::BannerPage endBannerPage() const;
|
||||
|
||||
void initJobHold();
|
||||
void initJobBilling();
|
||||
void initJobPriority();
|
||||
void initBannerPages();
|
||||
|
||||
QPrinter *m_printer;
|
||||
Ui::QCupsJobWidget m_ui;
|
||||
|
|
|
|||
Loading…
Reference in New Issue