#include <QtGui/QPlatformFontDatabase>
#include <QtGui/QPlatformClipboard>
+#include <QtGui/QPlatformPrinterSupport>
QT_BEGIN_NAMESPACE
return false;
}
+/*!
+ Returns the platform's printing support.
+ \since 5.0
+*/
+QPlatformPrinterSupport *QPlatformIntegration::printerSupport() const
+{
+ static QPlatformPrinterSupport *ps = 0;
+ if (!ps)
+ ps = new QPlatformPrinterSupport;
+ return ps;
+}
QT_END_NAMESPACE
class QPlatformFontDatabase;
class QPlatformClipboard;
class QPlatformNativeInterface;
-
+class QPlatformPrinterSupport;
class Q_GUI_EXPORT QPlatformIntegration
{
// Access native handles. The window handle is already available from Wid;
virtual QPlatformNativeInterface *nativeInterface() const;
+
+ virtual QPlatformPrinterSupport *printerSupport() const;
};
QT_END_NAMESPACE
SOURCES += \
painting/qcolormap_win.cpp \
painting/qpaintdevice_win.cpp \
- painting/qprintengine_win.cpp \
- painting/qprinterinfo_win.cpp
+ painting/qprintengine_win.cpp
!win32-borland:!wince*:LIBS += -lmsimg32
}
}
qpa {
+ HEADERS += painting/qplatformprintersupport_qpa.h
SOURCES += \
painting/qcolormap_qpa.cpp \
- painting/qpaintdevice_qpa.cpp
+ painting/qpaintdevice_qpa.cpp \
+ painting/qplatformprintersupport_qpa.cpp
}
symbian {
****************************************************************************/
#include <qdebug.h>
#include "qcups_p.h"
+#include "qprinterinfo_unix_p.h"
#ifndef QT_NO_CUPS
return _cupsPrintFile(printerName, filename, title, num_options, options);
}
+QCUPSSupport::Printer::Printer(const QString &n) : name(n), isDefault(false), cupsPrinterIndex(-1)
+{
+}
+
+QList<QCUPSSupport::Printer> QCUPSSupport::availableUnixPrinters()
+{
+ QList<Printer> printers;
+
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ if (QCUPSSupport::isAvailable()) {
+ QCUPSSupport cups;
+ int cupsPrinterCount = cups.availablePrintersCount();
+ const cups_dest_t* cupsPrinters = cups.availablePrinters();
+ for (int i = 0; i < cupsPrinterCount; ++i) {
+ QString printerName(QString::fromLocal8Bit(cupsPrinters[i].name));
+ if (cupsPrinters[i].instance)
+ printerName += QLatin1Char('/') + QString::fromLocal8Bit(cupsPrinters[i].instance);
+
+ Printer p(printerName);
+ if (cupsPrinters[i].is_default)
+ p.isDefault = true;
+ p.cupsPrinterIndex = i;
+ printers.append(p);
+ }
+ } else
+#endif
+ {
+ QList<QPrinterDescription> lprPrinters;
+ int defprn = qt_getLprPrinters(lprPrinters);
+ // populating printer combo
+ foreach (const QPrinterDescription &description, lprPrinters)
+ printers.append(Printer(description.name));
+ if (defprn >= 0 && defprn < printers.size())
+ printers[defprn].isDefault = true;
+ }
+
+ return printers;
+}
+
+QList<QPrinter::PaperSize> QCUPSSupport::getCupsPrinterPaperSizes(int cupsPrinterIndex)
+{
+ return qt_getCupsPrinterPaperSizes(cupsPrinterIndex);
+}
+
QT_END_NAMESPACE
#endif // QT_NO_CUPS
//
#include "QtCore/qstring.h"
#include "QtCore/qstringlist.h"
+#include "QtCore/qpair.h"
#include "QtGui/qprinter.h"
#ifndef QT_NO_CUPS
class Q_GUI_EXPORT QCUPSSupport
{
public:
+ struct Printer
+ {
+ Printer(const QString &name = QString());
+
+ QString name;
+ bool isDefault;
+ int cupsPrinterIndex;
+ };
QCUPSSupport();
~QCUPSSupport();
int printFile(const char * printerName, const char * filename, const char * title,
int num_options, cups_option_t * options);
+ static QList<Printer> availableUnixPrinters();
+ static QList<QPrinter::PaperSize> getCupsPrinterPaperSizes(int cupsPrinterIndex);
+
private:
void collectMarkedOptions(QStringList& list, const ppd_group_t* group = 0) const;
void collectMarkedOptionsHelper(QStringList& list, const ppd_group_t* group) const;
--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformprintersupport_qpa.h"
+
+#include <QtGui/qprinterinfo.h>
+
+#include <private/qprinterinfo_p.h>
+
+#ifndef QT_NO_PRINTER
+
+QT_BEGIN_NAMESPACE
+
+QPlatformPrinterSupport::QPlatformPrinterSupport()
+{
+}
+
+QPlatformPrinterSupport::~QPlatformPrinterSupport()
+{
+}
+
+QPrintEngine *QPlatformPrinterSupport::createNativePrintEngine(QPrinter::PrinterMode)
+{
+ return 0;
+}
+
+QPaintEngine *QPlatformPrinterSupport::createPaintEngine(QPrintEngine *, QPrinter::PrinterMode)
+{
+ return 0;
+}
+
+QList<QPrinter::PaperSize> QPlatformPrinterSupport::supportedPaperSizes(const QPrinterInfo &) const
+{
+ return QList<QPrinter::PaperSize>();
+}
+
+QList<QPrinterInfo> QPlatformPrinterSupport::availablePrinters()
+{
+ return QList<QPrinterInfo>();
+}
+
+QPrinterInfo QPlatformPrinterSupport::defaultPrinter()
+{
+ const QList<QPrinterInfo> printers = availablePrinters();
+ foreach (const QPrinterInfo &printerInfo, printers) {
+ if (printerInfo.isDefault())
+ return printerInfo;
+ }
+ return printers.isEmpty() ? QPrinterInfo() : printers.front();
+}
+
+QPrinterInfo QPlatformPrinterSupport::printerInfo(const QString &printerName, bool isDefault)
+{
+ QPrinterInfo pi = QPrinterInfo(printerName);
+ pi.d_func()->isDefault = isDefault;
+ return pi;
+}
+
+void QPlatformPrinterSupport::setPrinterInfoDefault(QPrinterInfo *p, bool isDefault)
+{
+ p->d_func()->isDefault = isDefault;
+}
+
+bool QPlatformPrinterSupport::printerInfoIsDefault(const QPrinterInfo &p)
+{
+ return p.d_func()->isDefault;
+}
+
+int QPlatformPrinterSupport::printerInfoCupsPrinterIndex(const QPrinterInfo &p)
+{
+ int i = -1;
+#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN)) || defined(Q_WS_QPA)
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ if (!p.isNull())
+ return i = p.d_func()->cupsPrinterIndex;
+#endif
+#endif
+ Q_UNUSED(p)
+ return i;
+}
+
+void QPlatformPrinterSupport::setPrinterInfoCupsPrinterIndex(QPrinterInfo *p, int index)
+{
+#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN)) || defined(Q_WS_QPA)
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ p->d_func()->cupsPrinterIndex = index;
+#endif
+#endif
+ Q_UNUSED(p)
+ Q_UNUSED(index)
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_PRINTER
--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLATFORMPRINTINGSUPPORT_H
+#define QPLATFORMPRINTINGSUPPORT_H
+
+#include <QtGui/qprinter.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_PRINTER
+
+class QPrintEngine;
+
+class Q_GUI_EXPORT QPlatformPrinterSupport
+{
+public:
+ QPlatformPrinterSupport();
+ virtual ~QPlatformPrinterSupport();
+
+ virtual QPrintEngine *createNativePrintEngine(QPrinter::PrinterMode printerMode);
+ virtual QPaintEngine *createPaintEngine(QPrintEngine *, QPrinter::PrinterMode printerMode);
+ virtual QList<QPrinter::PaperSize> supportedPaperSizes(const QPrinterInfo &) const;
+
+ virtual QList<QPrinterInfo> availablePrinters();
+ virtual QPrinterInfo defaultPrinter();
+
+protected:
+ static QPrinterInfo printerInfo(const QString &printerName, bool isDefault = false);
+ static void setPrinterInfoDefault(QPrinterInfo *p, bool isDefault);
+ static bool printerInfoIsDefault(const QPrinterInfo &p);
+ static int printerInfoCupsPrinterIndex(const QPrinterInfo &p);
+ static void setPrinterInfoCupsPrinterIndex(QPrinterInfo *p, int index);
+};
+
+#endif // QT_NO_PRINTER
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPLATFORMPRINTINGSUPPORT_H
#ifndef QT_NO_PRINTER
+#include <private/qguiapplication_p.h>
+#include <QtGui/QPlatformPrinterSupport>
+
#if defined (Q_WS_WIN)
#include <private/qprintengine_win_p.h>
#elif defined (Q_WS_MAC)
switch (realOutputFormat) {
case QPrinter::NativeFormat: {
-#if defined (Q_WS_WIN)
+#if defined (Q_WS_QPA)
+ printEngine = QGuiApplicationPrivate::platformIntegration()->printerSupport()->createNativePrintEngine(printerMode);
+ paintEngine = QGuiApplicationPrivate::platformIntegration()->printerSupport()->createPaintEngine(printEngine, printerMode);
+#elif defined (Q_WS_WIN)
QWin32PrintEngine *winEngine = new QWin32PrintEngine(printerMode);
paintEngine = winEngine;
printEngine = winEngine;
#ifndef QT_NO_PRINTER
+#include <private/qguiapplication_p.h>
+#include <QtGui/QPlatformPrinterSupport>
+
QT_BEGIN_NAMESPACE
QPrinterInfoPrivate QPrinterInfoPrivate::shared_null;
On Mac OS X 10.3, this function always returns an empty list.
*/
+#ifdef Q_WS_QPA
+QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
+{
+ const Q_D(QPrinterInfo);
+ if (!isNull() && !d->hasPaperSizes) {
+ d->paperSizes = QGuiApplicationPrivate::platformIntegration()->printerSupport()->supportedPaperSizes(*this);
+ d->hasPaperSizes = true;
+ }
+ return d->paperSizes;
+}
+
+QList<QPrinterInfo> QPrinterInfo::availablePrinters()
+{
+ return QGuiApplicationPrivate::platformIntegration()->printerSupport()->availablePrinters();
+}
+
+QPrinterInfo QPrinterInfo::defaultPrinter()
+{
+ return QGuiApplicationPrivate::platformIntegration()->printerSupport()->defaultPrinter();
+}
+
+#endif //Q_WS_QPA
+
QT_END_NAMESPACE
#endif // QT_NO_PRINTER
QPrinterInfo(const QString &name);
private:
+ friend class QPlatformPrinterSupport;
Q_DECLARE_PRIVATE(QPrinterInfo)
QScopedPointer<QPrinterInfoPrivate, QPrinterInfoPrivateDeleter> d_ptr;
};
name(name), isDefault(false)
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN)) || defined(Q_WS_QPA)
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- , cupsPrinterIndex(0), hasPaperSizes(false)
+ , cupsPrinterIndex(0)
#endif
#endif
+ , hasPaperSizes(false)
{}
~QPrinterInfoPrivate()
{}
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN)) || defined(Q_WS_QPA)
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
int cupsPrinterIndex;
- mutable bool hasPaperSizes;
- mutable QList<QPrinter::PaperSize> paperSizes;
#endif
#endif
+ mutable bool hasPaperSizes;
+ mutable QList<QPrinter::PaperSize> paperSizes;
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-QList<QPrinterInfo> QPrinterInfo::availablePrinters()
+QList<QPrinter::PaperSize> qt_getCupsPrinterPaperSizes(int cupsPrinterIndex)
{
- QList<QPrinterInfo> printers;
-
+ QList<QPrinter::PaperSize> result;
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- if (QCUPSSupport::isAvailable()) {
- QCUPSSupport cups;
- int cupsPrinterCount = cups.availablePrintersCount();
- const cups_dest_t* cupsPrinters = cups.availablePrinters();
- for (int i = 0; i < cupsPrinterCount; ++i) {
- QString printerName(QString::fromLocal8Bit(cupsPrinters[i].name));
- if (cupsPrinters[i].instance)
- printerName += QLatin1Char('/') + QString::fromLocal8Bit(cupsPrinters[i].instance);
-
- QPrinterInfo printerInfo(printerName);
- if (cupsPrinters[i].is_default)
- printerInfo.d_ptr->isDefault = true;
- printerInfo.d_ptr->cupsPrinterIndex = i;
- printers.append(printerInfo);
- }
- } else
-#endif
- {
- QList<QPrinterDescription> lprPrinters;
- int defprn = qt_getLprPrinters(lprPrinters);
- // populating printer combo
- foreach (const QPrinterDescription &description, lprPrinters)
- printers.append(QPrinterInfo(description.name));
- if (defprn >= 0 && defprn < printers.size())
- printers[defprn].d_ptr->isDefault = true;
+ if (!QCUPSSupport::isAvailable() || cupsPrinterIndex < 0)
+ return result;
+ // Find paper sizes from CUPS.
+ QCUPSSupport cups;
+ cups.setCurrentPrinter(cupsPrinterIndex);
+ if (const ppd_option_t* size = cups.pageSizes()) {
+ for (int j = 0; j < size->num_choices; ++j)
+ result.append(string2PaperSize(size->choices[j].choice));
}
-
- return printers;
-}
-
-QPrinterInfo QPrinterInfo::defaultPrinter()
-{
- QList<QPrinterInfo> printers = availablePrinters();
- foreach (const QPrinterInfo &printerInfo, printers) {
- if (printerInfo.isDefault())
- return printerInfo;
- }
-
- return printers.value(0);
-}
-
-QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
-{
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- const Q_D(QPrinterInfo);
-
- if (isNull())
- return d->paperSizes;
-
- if (!d->hasPaperSizes) {
- d->hasPaperSizes = true;
-
- if (QCUPSSupport::isAvailable()) {
- // Find paper sizes from CUPS.
- QCUPSSupport cups;
- cups.setCurrentPrinter(d->cupsPrinterIndex);
- const ppd_option_t* sizes = cups.pageSizes();
- if (sizes) {
- for (int j = 0; j < sizes->num_choices; ++j)
- d->paperSizes.append(string2PaperSize(sizes->choices[j].choice));
- }
- }
- }
-
- return d->paperSizes;
-#else
- return QList<QPrinter::PaperSize>();
+ return result;
#endif
}
#ifndef QPRINTERINFO_UNIX_P_H
#define QPRINTERINFO_UNIX_P_H
+#include <QtGui/qprinter.h>
+#include <QtCore/qstringlist.h>
+
#ifndef QT_NO_NIS
# ifndef BOOL_DEFINED
# define BOOL_DEFINED
void qt_parseQconfig(QList<QPrinterDescription> *printers);
int qt_getLprPrinters(QList<QPrinterDescription>& printers);
+QList<QPrinter::PaperSize> qt_getCupsPrinterPaperSizes(int cupsPrinterIndex);
+
#endif // QT_NO_PRINTER
QT_END_NAMESPACE
--- /dev/null
+INCLUDEPATH += $$PWD
+HEADERS += $$PWD/qgenericunixprintersupport.h
+SOURCES += $$PWD/qgenericunixprintersupport.cpp
+QT += gui-private
--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qgenericunixprintersupport.h>
+
+#include <QtGui/QPrinterInfo>
+#include <private/qcups_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QList<QPrinter::PaperSize> QGenericUnixPrinterSupport::supportedPaperSizes(const QPrinterInfo &printerInfo) const
+{
+ return QCUPSSupport::getCupsPrinterPaperSizes(QPlatformPrinterSupport::printerInfoCupsPrinterIndex(printerInfo));
+}
+
+QList<QPrinterInfo> QGenericUnixPrinterSupport::availablePrinters()
+{
+ QList<QPrinterInfo> printers;
+ foreach (const QCUPSSupport::Printer &p, QCUPSSupport::availableUnixPrinters()) {
+ QPrinterInfo printer(QPlatformPrinterSupport::printerInfo(p.name, p.isDefault));
+ QPlatformPrinterSupport::setPrinterInfoCupsPrinterIndex(&printer, p.cupsPrinterIndex);
+ printers.append(printer);
+ }
+ return printers;
+}
+
+QT_END_NAMESPACE
--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGENERICUNIXPRINTINGSUPPORT_H
+#define QGENERICUNIXPRINTINGSUPPORT_H
+
+#include <QtGui/QPlatformPrinterSupport>
+
+QT_BEGIN_NAMESPACE
+
+class QGenericUnixPrinterSupport : public QPlatformPrinterSupport
+{
+public:
+ virtual QList<QPrinter::PaperSize> supportedPaperSizes(const QPrinterInfo &) const;
+
+ virtual QList<QPrinterInfo> availablePrinters();
+};
+
+QT_END_NAMESPACE
+
+#endif // QGENERICUNIXPRINTINGSUPPORT_H
--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qwindowsprintersupport.h>
+#include <qprintengine_win_p.h>
+
+#include <QtGui/QPrinterInfo>
+
+#include <QtCore/QStringList>
+
+#include <QtCore/qt_windows.h>
+
+QT_BEGIN_NAMESPACE
+
+QPrintEngine *QWindowsPrinterSupport::createNativePrintEngine(QPrinter::PrinterMode mode)
+{
+ return new QWin32PrintEngine(mode);
+}
+
+QPaintEngine *QWindowsPrinterSupport::createPaintEngine(QPrintEngine *engine, QPrinter::PrinterMode)
+{
+ return static_cast<QWin32PrintEngine *>(engine);
+}
+
+QList<QPrinter::PaperSize> QWindowsPrinterSupport::supportedPaperSizes(const QPrinterInfo &printerInfo) const
+{
+ QList<QPrinter::PaperSize> paperSizes;
+ const QString printerName = printerInfo.printerName();
+ const wchar_t *nameUtf16 = reinterpret_cast<const wchar_t*>(printerName.utf16());
+ DWORD size = DeviceCapabilities(nameUtf16, NULL, DC_PAPERS, NULL, NULL);
+ if ((int)size != -1) {
+ wchar_t *papers = new wchar_t[size];
+ size = DeviceCapabilities(nameUtf16, NULL, DC_PAPERS, papers, NULL);
+ for (int c = 0; c < (int)size; ++c)
+ paperSizes.append(mapDevmodePaperSize(papers[c]));
+ delete [] papers;
+ }
+ return paperSizes;
+}
+
+QList<QPrinterInfo> QWindowsPrinterSupport::availablePrinters()
+{
+ QList<QPrinterInfo> printers;
+
+ DWORD needed = 0;
+ DWORD returned = 0;
+ if (!EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 4, 0, 0, &needed, &returned)) {
+ LPBYTE buffer = new BYTE[needed];
+ if (EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 4, buffer, needed, &needed, &returned)) {
+ PPRINTER_INFO_4 infoList = reinterpret_cast<PPRINTER_INFO_4>(buffer);
+ QPrinterInfo defPrn = defaultPrinter();
+ for (uint i = 0; i < returned; ++i) {
+ const QString printerName(QString::fromWCharArray(infoList[i].pPrinterName));
+ const bool isDefault = printerName == defPrn.printerName();
+ printers.append(QPlatformPrinterSupport::printerInfo(printerName,
+ isDefault));
+ }
+ }
+ delete [] buffer;
+ }
+
+ return printers;
+}
+
+QPrinterInfo QWindowsPrinterSupport::defaultPrinter()
+{
+ QString noPrinters(QLatin1String("qt_no_printers"));
+ wchar_t buffer[256];
+ GetProfileString(L"windows", L"device", (wchar_t*)noPrinters.utf16(), buffer, 256);
+ QString output = QString::fromWCharArray(buffer);
+ if (output != noPrinters) {
+ // Filter out the name of the printer, which should be everything before a comma.
+ const QString printerName = output.split(QLatin1Char(',')).value(0);
+ return QPlatformPrinterSupport::printerInfo(printerName, true);
+ }
+
+ return QPrinterInfo();
+}
+
+QT_END_NAMESPACE
--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOWSPRINTERSUPPORT_H
+#define QWINDOWSPRINTERSUPPORT_H
+
+#include <QtGui/QPlatformPrinterSupport>
+
+QT_BEGIN_NAMESPACE
+
+class QWindowsPrinterSupport : public QPlatformPrinterSupport
+{
+public:
+ virtual QPrintEngine *createNativePrintEngine(QPrinter::PrinterMode);
+ virtual QPaintEngine *createPaintEngine(QPrintEngine *, QPrinter::PrinterMode);
+
+ virtual QList<QPrinter::PaperSize> supportedPaperSizes(const QPrinterInfo &) const;
+ virtual QPrinterInfo defaultPrinter();
+ virtual QList<QPrinterInfo> availablePrinters();
+};
+
+QT_END_NAMESPACE
+
+#endif // QWINDOWSPRINTERSUPPORT_H
--- /dev/null
+INCLUDEPATH += $$PWD $$QT_SOURCE_TREE/src/3rdparty/harfbuzz/src
+
+HEADERS += $$PWD/qwindowsprintersupport.h \
+ $$PWD/qprintengine_win_p.h
+SOURCES += $$PWD/qwindowsprintersupport.cpp \
+ $$PWD/qprintengine_win.cpp
+QT += core-private widgets-private
#include "qxcbwindowsurface.h"
#include "qxcbnativeinterface.h"
+#include <qgenericunixprintersupport.h>
+
#include <xcb/xcb.h>
#include <private/qpixmap_raster_p.h>
#endif
QXcbIntegration::QXcbIntegration()
- : m_connection(new QXcbConnection)
+ : m_connection(new QXcbConnection), m_printerSupport(new QGenericUnixPrinterSupport)
{
foreach (QXcbScreen *screen, m_connection->screens())
m_screens << screen;
{
return m_nativeInterface;
}
+
+QPlatformPrinterSupport *QXcbIntegration::printerSupport() const
+{
+ return m_printerSupport;
+}
QPlatformNativeInterface *nativeInterface()const;
+ QPlatformPrinterSupport *printerSupport() const;
+
private:
bool hasOpenGL() const;
QList<QPlatformScreen *> m_screens;
QPlatformFontDatabase *m_fontDatabase;
QPlatformNativeInterface *m_nativeInterface;
+ QPlatformPrinterSupport *m_printerSupport;
};
QT_END_NAMESPACE
LIBS += -lxcb -lxcb-image -lxcb-keysyms -lxcb-icccm -lxcb-sync
include (../fontdatabases/genericunix/genericunix.pri)
+include (../printersupport/genericunix/genericunix.pri)
target.path += $$[QT_INSTALL_PLUGINS]/platforms
INSTALLS += target