summaryrefslogtreecommitdiffstats
path: root/src/printsupport/dialogs/qprintdialog_unix.cpp
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-03-24 16:10:15 +0100
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-03-24 16:10:15 +0100
commit3b5c0bc0780f1749fed7c07bd8b691400a0282b7 (patch)
tree1022f5553ad5a0aca9b5f3b49ca38a01c2329d20 /src/printsupport/dialogs/qprintdialog_unix.cpp
parentc79918733a194ebbe5a2fe1617c884659f3e4b9f (diff)
parent21f1738a94fc8544ece04b3b1ee03a11986fe59b (diff)
Merge remote-tracking branch 'origin/stable' into dev
Conflicts: src/gui/image/qjpeghandler.cpp Change-Id: I9db3acea7d5c82f5da679c8eaeb29431136665f0
Diffstat (limited to 'src/printsupport/dialogs/qprintdialog_unix.cpp')
-rw-r--r--src/printsupport/dialogs/qprintdialog_unix.cpp167
1 files changed, 81 insertions, 86 deletions
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index 2ec1088bb4..ab31db76aa 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -52,8 +52,11 @@
#include <QtWidgets/qfilesystemmodel.h>
#include <QtWidgets/qstyleditemdelegate.h>
#include <QtPrintSupport/qprinter.h>
-#include <QtPrintSupport/qprinterinfo.h>
-#include <private/qprintengine_pdf_p.h>
+
+#include <qpa/qplatformprintplugin.h>
+#include <qpa/qplatformprintersupport.h>
+
+#include <private/qprintdevice_p.h>
#include <QtWidgets/qdialogbuttonbox.h>
@@ -62,12 +65,9 @@
#include "ui_qprintsettingsoutput.h"
#include "ui_qprintwidget.h"
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
-# include <private/qcups_p.h>
-# include "qcupsjobwidget_p.h"
-#else
-# include <QtCore/qlibrary.h>
-# include <private/qprintengine_pdf_p.h>
+#ifndef QT_NO_CUPS
+#include <private/qcups_p.h>
+#include "qcupsjobwidget_p.h"
#endif
/*
@@ -120,8 +120,7 @@ public:
QPrintPropertiesDialog(QAbstractPrintDialog *parent = 0);
~QPrintPropertiesDialog();
- void selectPrinter();
- void selectPdfPsPrinter(const QPrinter *p);
+ void selectPrinter(QPrinter::OutputFormat outputFormat, const QString &printerName);
/// copy printer properties to the widget
void applyPrinterProperties(QPrinter *p);
@@ -134,7 +133,7 @@ private:
friend class QUnixPrintWidgetPrivate;
Ui::QPrintPropertiesWidget widget;
QDialogButtonBox *m_buttons;
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+#ifndef QT_NO_CUPS
QCupsJobWidget *m_jobOptions;
#endif
};
@@ -181,6 +180,8 @@ public:
Ui::QPrintWidget widget;
QAbstractPrintDialog * q;
QPrinter *printer;
+ QPrintDevice m_currentPrintDevice;
+
void updateWidget();
private:
@@ -249,11 +250,9 @@ QPrintPropertiesDialog::QPrintPropertiesDialog(QAbstractPrintDialog *parent)
connect(m_buttons->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept()));
connect(m_buttons->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- if (QCUPSSupport::isAvailable()) {
- m_jobOptions = new QCupsJobWidget();
- widget.tabs->addTab(m_jobOptions, tr("Job Options"));
- }
+#ifndef QT_NO_CUPS
+ m_jobOptions = new QCupsJobWidget();
+ widget.tabs->addTab(m_jobOptions, tr("Job Options"));
#endif
}
@@ -264,31 +263,22 @@ QPrintPropertiesDialog::~QPrintPropertiesDialog()
void QPrintPropertiesDialog::applyPrinterProperties(QPrinter *p)
{
widget.pageSetup->setPrinter(p);
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- if (QCUPSSupport::isAvailable()) {
- m_jobOptions->setPrinter(p);
- }
+#ifndef QT_NO_CUPS
+ m_jobOptions->setPrinter(p);
#endif
}
void QPrintPropertiesDialog::setupPrinter() const
{
widget.pageSetup->setupPrinter();
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- if (QCUPSSupport::isAvailable()) {
- m_jobOptions->setupPrinter();
- }
+#ifndef QT_NO_CUPS
+ m_jobOptions->setupPrinter();
#endif
}
-void QPrintPropertiesDialog::selectPrinter()
+void QPrintPropertiesDialog::selectPrinter(QPrinter::OutputFormat outputFormat, const QString &printerName)
{
- widget.pageSetup->selectPrinter();
-}
-
-void QPrintPropertiesDialog::selectPdfPsPrinter(const QPrinter *p)
-{
- widget.pageSetup->selectPdfPsPrinter(p);
+ widget.pageSetup->selectPrinter(outputFormat, printerName);
}
void QPrintPropertiesDialog::showEvent(QShowEvent* event)
@@ -329,13 +319,11 @@ void QPrintDialogPrivate::init()
options.grayscale->setIconSize(QSize(32, 32));
options.grayscale->setIcon(QIcon(QLatin1String(":/qt-project.org/dialogs/qprintdialog/images/status-gray-scale.png")));
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+#ifndef QT_NO_CUPS
// Add Page Set widget if CUPS is available
- if (QCUPSSupport::isAvailable()) {
- options.pageSetCombo->addItem(tr("All Pages"), QVariant::fromValue(QCUPSSupport::AllPages));
- options.pageSetCombo->addItem(tr("Odd Pages"), QVariant::fromValue(QCUPSSupport::OddPages));
- options.pageSetCombo->addItem(tr("Even Pages"), QVariant::fromValue(QCUPSSupport::EvenPages));
- }
+ options.pageSetCombo->addItem(tr("All Pages"), QVariant::fromValue(QCUPSSupport::AllPages));
+ options.pageSetCombo->addItem(tr("Odd Pages"), QVariant::fromValue(QCUPSSupport::OddPages));
+ options.pageSetCombo->addItem(tr("Even Pages"), QVariant::fromValue(QCUPSSupport::EvenPages));
#endif
top->d->setOptionsPane(this);
@@ -453,24 +441,27 @@ void QPrintDialogPrivate::setupPrinter()
}
}
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+#ifndef QT_NO_CUPS
// page set
- if (QCUPSSupport::isAvailable()) {
- if (p->printRange() == QPrinter::AllPages || p->printRange() == QPrinter::PageRange) {
- //If the application is selecting pages and the first page number is even then need to adjust the odd-even accordingly
- QCUPSSupport::PageSet pageSet = options.pageSetCombo->itemData(options.pageSetCombo->currentIndex()).value<QCUPSSupport::PageSet>();
- if (q->isOptionEnabled(QPrintDialog::PrintPageRange)
- && p->printRange() == QPrinter::PageRange
- && (q->fromPage() % 2 == 0)) {
-
- if (pageSet == QCUPSSupport::OddPages)
- QCUPSSupport::setPageSet(p, QCUPSSupport::EvenPages);
- else if (pageSet == QCUPSSupport::EvenPages)
- QCUPSSupport::setPageSet(p, QCUPSSupport::OddPages);
- } else if (pageSet != QCUPSSupport::AllPages) {
- QCUPSSupport::setPageSet(p, pageSet);
+ if (p->printRange() == QPrinter::AllPages || p->printRange() == QPrinter::PageRange) {
+ //If the application is selecting pages and the first page number is even then need to adjust the odd-even accordingly
+ QCUPSSupport::PageSet pageSet = options.pageSetCombo->itemData(options.pageSetCombo->currentIndex()).value<QCUPSSupport::PageSet>();
+ if (q->isOptionEnabled(QPrintDialog::PrintPageRange)
+ && p->printRange() == QPrinter::PageRange
+ && (q->fromPage() % 2 == 0)) {
+
+ switch (pageSet) {
+ case QCUPSSupport::AllPages:
+ break;
+ case QCUPSSupport::OddPages:
+ QCUPSSupport::setPageSet(p, QCUPSSupport::EvenPages);
+ break;
+ case QCUPSSupport::EvenPages:
+ QCUPSSupport::setPageSet(p, QCUPSSupport::OddPages);
+ break;
}
-
+ } else if (pageSet != QCUPSSupport::AllPages) {
+ QCUPSSupport::setPageSet(p, pageSet);
}
// server-side page range, since we set the page range on the printer to 0-0/AllPages above,
@@ -533,26 +524,22 @@ void QPrintDialogPrivate::updateWidgets()
options.printCurrentPage->setVisible(q->isOptionEnabled(QPrintDialog::PrintCurrentPage));
options.collate->setVisible(q->isOptionEnabled(QPrintDialog::PrintCollateCopies));
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- if (QCUPSSupport::isAvailable()) {
- // Don't display Page Set if only Selection or Current Page are enabled
- if (!q->isOptionEnabled(QPrintDialog::PrintPageRange) && (
- q->isOptionEnabled(QPrintDialog::PrintSelection) ||
- q->isOptionEnabled(QPrintDialog::PrintCurrentPage))) {
-
- options.pageSetCombo->setVisible(false);
- options.pageSetLabel->setVisible(false);
- } else {
- options.pageSetCombo->setVisible(true);
- options.pageSetLabel->setVisible(true);
- }
+#ifndef QT_NO_CUPS
+ // Don't display Page Set if only Selection or Current Page are enabled
+ if (!q->isOptionEnabled(QPrintDialog::PrintPageRange)
+ && (q->isOptionEnabled(QPrintDialog::PrintSelection) || q->isOptionEnabled(QPrintDialog::PrintCurrentPage))) {
+ options.pageSetCombo->setVisible(false);
+ options.pageSetLabel->setVisible(false);
+ } else {
+ options.pageSetCombo->setVisible(true);
+ options.pageSetLabel->setVisible(true);
+ }
- if (!q->isOptionEnabled(QPrintDialog::PrintPageRange)) {
- // If we can do CUPS server side pages selection,
- // display the page range widgets
- options.gbPrintRange->setVisible(true);
- options.printRange->setEnabled(true);
- }
+ if (!q->isOptionEnabled(QPrintDialog::PrintPageRange)) {
+ // If we can do CUPS server side pages selection,
+ // display the page range widgets
+ options.gbPrintRange->setVisible(true);
+ options.printRange->setEnabled(true);
}
#endif
@@ -681,12 +668,17 @@ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p, QPrinter *
widget.setupUi(parent);
int currentPrinterIndex = 0;
- QList<QPrinterInfo> printers = QPrinterInfo::availablePrinters();
+ QStringList printers;
+ QString defaultPrinter;
+ QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
+ if (ps) {
+ printers = ps->availablePrintDeviceIds();
+ defaultPrinter = ps->defaultPrintDeviceId();
+ }
for (int i = 0; i < printers.size(); ++i) {
- QPrinterInfo pInfo = printers.at(i);
- widget.printers->addItem(pInfo.printerName());
- if (pInfo.isDefault())
+ widget.printers->addItem(printers.at(i));
+ if (printers.at(i) == defaultPrinter)
currentPrinterIndex = i;
}
widget.properties->setEnabled(true);
@@ -775,12 +767,14 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
}
if (printer) {
- QString printerName = widget.printers->itemText(index);
- printer->setPrinterName(printerName);
+ QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
+ if (ps)
+ m_currentPrintDevice = ps->createPrintDevice(widget.printers->itemText(index));
+
+ printer->setPrinterName(m_currentPrintDevice.id());
- QPrinterInfo printerInfo = QPrinterInfo::printerInfo(printer->printerName());
- widget.location->setText(printerInfo.location());
- widget.type->setText(printerInfo.makeAndModel());
+ widget.location->setText(m_currentPrintDevice.location());
+ widget.type->setText(m_currentPrintDevice.makeAndModel());
if (optionsPane)
optionsPane->selectPrinter(QPrinter::NativeFormat);
}
@@ -847,7 +841,7 @@ void QUnixPrintWidgetPrivate::applyPrinterProperties()
}
}
}
- // PDF and PS printers are not added to the dialog yet, we'll handle those cases in QUnixPrintWidgetPrivate::updateWidget
+ // PDF printer not added to the dialog yet, we'll handle those cases in QUnixPrintWidgetPrivate::updateWidget
if (propertiesDialog)
propertiesDialog->applyPrinterProperties(printer);
@@ -884,9 +878,10 @@ bool QUnixPrintWidgetPrivate::checkFields()
}
}
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+#ifndef QT_NO_CUPS
if (propertiesDialogShown) {
- QCUPSSupport::PagesPerSheet pagesPerSheet = propertiesDialog->widget.pageSetup->widget.pagesPerSheetCombo->currentData().value<QCUPSSupport::PagesPerSheet>();
+ QCUPSSupport::PagesPerSheet pagesPerSheet = propertiesDialog->widget.pageSetup->m_ui.pagesPerSheetCombo
+ ->currentData().value<QCUPSSupport::PagesPerSheet>();
QCUPSSupport::PageSet pageSet = optionsPane->options.pageSetCombo->currentData().value<QCUPSSupport::PageSet>();
@@ -918,10 +913,10 @@ void QUnixPrintWidgetPrivate::setupPrinterProperties()
if (q->isOptionEnabled(QPrintDialog::PrintToFile)
&& (widget.printers->currentIndex() == widget.printers->count() - 1)) {// PDF
- propertiesDialog->selectPdfPsPrinter(q->printer());
+ propertiesDialog->selectPrinter(QPrinter::PdfFormat, QString());
}
else
- propertiesDialog->selectPrinter();
+ propertiesDialog->selectPrinter(QPrinter::NativeFormat, widget.printers->currentText());
}
void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked()