diff options
author | John Layt <jlayt@kde.org> | 2012-05-09 23:47:14 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-31 17:40:55 +0200 |
commit | f70924e9ccc016b979bc74bba156600639184be7 (patch) | |
tree | a470d6ac093035526cbc3840e0588d33c003e05f /src/printsupport/kernel/qprinter.cpp | |
parent | 704bd686315deeaf86a15d1eb37af56b0b0e184b (diff) |
QtPrintSupport: Add CUPS printsupport plugin
Move CUPS code around to create a new CUPS printsupport plugin, this
fixes QPrinterInfo for CUPS which depends on the plugin to work.
It QT_NO_CUPS is defined then the plugin is not built and only Print
to PDF is supported under Linux.
* Move unused genericiunixprintersupport plugin to start new CUPS
printsupport plugin
* Split QPdfPrintEngine to create QCupsPrintEngine
* Remove LPR related code from QPdfPrintEngine
* Move CUPS specific code from plugin base class to derived CUPS class
* Remove forcing CUPS print engine to use PDF mode as PDF is now Native
* Move qt_getCupsPrinterPaperSizes from qprinterinfo_unix to
QCUPSSupport
* Remove qprinterinfo_unix as no longer used
* Remove all QT_NO_LPR uses
There is now no CUPS specific code left in printsupport/kernel except
QCUPSSupport which is needed for the dialogs.
Task-number: QTBUG-23060
Change-Id: Ie8fa4512a2424edc8943068e0fa9fb714cc42db9
Reviewed-by: Teemu Katajisto <teemu.katajisto@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: John Layt <jlayt@kde.org>
Diffstat (limited to 'src/printsupport/kernel/qprinter.cpp')
-rw-r--r-- | src/printsupport/kernel/qprinter.cpp | 61 |
1 files changed, 13 insertions, 48 deletions
diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp index 2fd6f60de5..176d1ad5f6 100644 --- a/src/printsupport/kernel/qprinter.cpp +++ b/src/printsupport/kernel/qprinter.cpp @@ -41,19 +41,18 @@ #include "qprinter_p.h" #include "qprinter.h" + +#ifndef QT_NO_PRINTER + +#include <qpa/qplatformprintplugin.h> +#include <qpa/qplatformprintersupport.h> + #include "qprintengine.h" #include "qprinterinfo.h" #include "qlist.h" #include <qcoreapplication.h> #include <qfileinfo.h> -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) -#include "private/qcups_p.h" -#endif -#ifndef QT_NO_PRINTER - -#include <qpa/qplatformprintplugin.h> -#include <qpa/qplatformprintersupport.h> #include <private/qpagedpaintdevice_p.h> #if defined(Q_WS_X11) @@ -150,33 +149,15 @@ Q_PRINTSUPPORT_EXPORT QSizeF qt_printerPaperSize(QPrinter::Orientation orientati void QPrinterPrivate::createDefaultEngines() { - QPrinter::OutputFormat realOutputFormat = outputFormat; -#if defined (Q_OS_UNIX) && !defined(Q_OS_MAC) - if(outputFormat == QPrinter::NativeFormat) { - realOutputFormat = QPrinter::PdfFormat; - } -#endif - - switch (realOutputFormat) { - case QPrinter::NativeFormat: { - QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get(); - if (ps) { - printEngine = ps->createNativePrintEngine(printerMode); - paintEngine = ps->createPaintEngine(printEngine, printerMode); - } else { - QPdfPrintEngine *pdfEngine = new QPdfPrintEngine(printerMode); - paintEngine = pdfEngine; - printEngine = pdfEngine; - } - } - break; - case QPrinter::PdfFormat: { + QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get(); + if (outputFormat == QPrinter::NativeFormat && ps) { + printEngine = ps->createNativePrintEngine(printerMode); + paintEngine = ps->createPaintEngine(printEngine, printerMode); + } else { QPdfPrintEngine *pdfEngine = new QPdfPrintEngine(printerMode); paintEngine = pdfEngine; printEngine = pdfEngine; } - break; - } use_default_engine = true; had_default_engines = true; } @@ -236,7 +217,7 @@ void QPrinterPrivate::addToManualSetList(QPrintEngine::PrintEnginePropertyKey ke When printing directly to a printer on Windows or Mac OS X, QPrinter uses the built-in printer drivers. On X11, QPrinter uses the - \l{Common Unix Printing System (CUPS)} or the standard Unix \l lpr utility + \l{Common Unix Printing System (CUPS)} to send PDF output to the printer. As an alternative, the printProgram() function can be used to specify the command or utility to use instead of the system default. @@ -513,9 +494,7 @@ QPrinter::QPrinter(PrinterMode mode) QPrinterInfo defPrn(QPrinterInfo::defaultPrinter()); if (!defPrn.isNull()) { setPrinterName(defPrn.printerName()); - } else if (QPrinterInfo::availablePrinters().isEmpty() - && d_ptr->paintEngine->type() != QPaintEngine::Windows - && d_ptr->paintEngine->type() != QPaintEngine::MacPrinter) { + } else if (QPrinterInfo::availablePrinters().isEmpty()) { setOutputFormat(QPrinter::PdfFormat); } } @@ -553,13 +532,6 @@ void QPrinterPrivate::init(QPrinter::PrinterMode mode) #endif realPrintEngine = 0; realPaintEngine = 0; - -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) - if (QCUPSSupport::cupsVersion() >= 10200 && QCUPSSupport().currentPPD()) { - q_func()->setOutputFormat(QPrinter::PdfFormat); - outputFormat = QPrinter::NativeFormat; - } -#endif } /*! @@ -707,13 +679,6 @@ void QPrinter::setPrinterName(const QString &name) Q_D(QPrinter); ABORT_IF_ACTIVE("QPrinter::setPrinterName"); -#if defined(Q_OS_UNIX) && !defined(QT_NO_CUPS) - if(d->use_default_engine && d->outputFormat == QPrinter::NativeFormat) { - setOutputFormat(QPrinter::PdfFormat); - d->outputFormat = QPrinter::NativeFormat; - } -#endif - QList<QPrinterInfo> prnList = QPrinterInfo::availablePrinters(); if (name.isEmpty()) { d->validPrinter = d->outputFormat == QPrinter::PdfFormat; |