diff options
Diffstat (limited to 'src/printsupport/kernel')
-rw-r--r-- | src/printsupport/kernel/qplatformprintersupport_qpa.cpp | 20 | ||||
-rw-r--r-- | src/printsupport/kernel/qplatformprintersupport_qpa.h | 3 | ||||
-rw-r--r-- | src/printsupport/kernel/qplatformprintplugin.cpp | 26 | ||||
-rw-r--r-- | src/printsupport/kernel/qprinter.cpp | 17 |
4 files changed, 47 insertions, 19 deletions
diff --git a/src/printsupport/kernel/qplatformprintersupport_qpa.cpp b/src/printsupport/kernel/qplatformprintersupport_qpa.cpp index aeb4599955..b6f65ee893 100644 --- a/src/printsupport/kernel/qplatformprintersupport_qpa.cpp +++ b/src/printsupport/kernel/qplatformprintersupport_qpa.cpp @@ -124,6 +124,26 @@ void QPlatformPrinterSupport::setPrinterInfoCupsPrinterIndex(QPrinterInfo *p, in #endif } +/* + Converts QSizeF in millimeters to a predefined PaperSize (returns Custom if + the size isn't a standard size) +*/ +QPrinter::PaperSize QPlatformPrinterSupport::convertQSizeFToPaperSize(const QSizeF &sizef) +{ + extern QPrinter::PaperSize qSizeFTopaperSize(const QSizeF &); + return qSizeFTopaperSize(sizef); +} + +/* + Converts a predefined PaperSize to a QSizeF in millimeters (returns + QSizeF(0.0, 0.0) if PaperSize is Custom) +*/ +QSizeF QPlatformPrinterSupport::convertPaperSizeToQSizeF(QPrinter::PaperSize paperSize) +{ + extern QSizeF qt_paperSizeToQSizeF(QPrinter::PaperSize size); + return qt_paperSizeToQSizeF(paperSize); +} + QT_END_NAMESPACE #endif // QT_NO_PRINTER diff --git a/src/printsupport/kernel/qplatformprintersupport_qpa.h b/src/printsupport/kernel/qplatformprintersupport_qpa.h index 53f5900cce..5dba56579c 100644 --- a/src/printsupport/kernel/qplatformprintersupport_qpa.h +++ b/src/printsupport/kernel/qplatformprintersupport_qpa.h @@ -66,6 +66,9 @@ public: virtual QList<QPrinterInfo> availablePrinters(); virtual QPrinterInfo defaultPrinter(); + static QPrinter::PaperSize convertQSizeFToPaperSize(const QSizeF &sizef); + static QSizeF convertPaperSizeToQSizeF(QPrinter::PaperSize paperSize); + protected: static QPrinterInfo printerInfo(const QString &printerName, bool isDefault = false); static void setPrinterInfoDefault(QPrinterInfo *p, bool isDefault); diff --git a/src/printsupport/kernel/qplatformprintplugin.cpp b/src/printsupport/kernel/qplatformprintplugin.cpp index 409de3eb4a..2c87fcc5e6 100644 --- a/src/printsupport/kernel/qplatformprintplugin.cpp +++ b/src/printsupport/kernel/qplatformprintplugin.cpp @@ -58,15 +58,27 @@ QPlatformPrinterSupportPlugin::~QPlatformPrinterSupportPlugin() { } +/*! + \internal + + Returns a lazily-initialized singleton. Ownership is granted to the + QPlatformPrinterSupportPlugin, which is never unloaded or destroyed until + application exit, i.e. you can expect this pointer to always be valid and + multiple calls to this function will always return the same pointer. +*/ QPlatformPrinterSupport *QPlatformPrinterSupportPlugin::get() { - QStringList k = loader()->keys(); - if (k.isEmpty()) - return 0; - QPlatformPrinterSupportPlugin *plugin = qobject_cast<QPlatformPrinterSupportPlugin *>(loader()->instance(k.first())); - if (!plugin) - return 0; - return plugin->create(k.first()); + static QPlatformPrinterSupport *singleton = 0; + if (!singleton) { + QStringList k = loader()->keys(); + if (k.isEmpty()) + return 0; + QPlatformPrinterSupportPlugin *plugin = qobject_cast<QPlatformPrinterSupportPlugin *>(loader()->instance(k.first())); + if (!plugin) + return 0; + singleton = plugin->create(k.first()); + } + return singleton; } QT_END_NAMESPACE diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp index e0373d99e8..f56d34975d 100644 --- a/src/printsupport/kernel/qprinter.cpp +++ b/src/printsupport/kernel/qprinter.cpp @@ -58,8 +58,6 @@ #if defined (Q_WS_WIN) #include <private/qprintengine_win_p.h> -#elif defined (Q_WS_MAC) -#include <private/qprintengine_mac_p.h> #elif defined (QTOPIA_PRINTENGINE) #include <private/qprintengine_qws_p.h> #endif @@ -176,11 +174,6 @@ void QPrinterPrivate::createDefaultEngines() paintEngine = pdfEngine; printEngine = pdfEngine; } -#if defined (Q_WS_MAC) - QMacPrintEngine *macEngine = new QMacPrintEngine(printerMode); - paintEngine = macEngine; - printEngine = macEngine; -#endif } break; case QPrinter::PdfFormat: { @@ -264,14 +257,14 @@ void QPrinterPrivate::addToManualSetList(QPrintEngine::PrintEnginePropertyKey ke The most important parameters are: \list - \i setOrientation() tells QPrinter which page orientation to use. - \i setPaperSize() tells QPrinter what paper size to expect from the + \li setOrientation() tells QPrinter which page orientation to use. + \li setPaperSize() tells QPrinter what paper size to expect from the printer. - \i setResolution() tells QPrinter what resolution you wish the + \li setResolution() tells QPrinter what resolution you wish the printer to provide, in dots per inch (DPI). - \i setFullPage() tells QPrinter whether you want to deal with the + \li setFullPage() tells QPrinter whether you want to deal with the full page or just with the part the printer can draw on. - \i setCopyCount() tells QPrinter how many copies of the document + \li setCopyCount() tells QPrinter how many copies of the document it should print. \endlist |