1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 John Layt <jlayt@kde.org>
4 ** Copyright (C) 2018 The Qt Company Ltd.
5 ** Contact: https://www.qt.io/licensing/
6 **
7 ** This file is part of the QtPrintSupport module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** Commercial License Usage
11 ** Licensees holding valid commercial Qt licenses may use this file in
12 ** accordance with the commercial license agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and The Qt Company. For licensing terms
15 ** and conditions see https://www.qt.io/terms-conditions. For further
16 ** information use the contact form at https://www.qt.io/contact-us.
17 **
18 ** GNU Lesser General Public License Usage
19 ** Alternatively, this file may be used under the terms of the GNU Lesser
20 ** General Public License version 3 as published by the Free Software
21 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
22 ** packaging of this file. Please review the following information to
23 ** ensure the GNU Lesser General Public License version 3 requirements
24 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
25 **
26 ** GNU General Public License Usage
27 ** Alternatively, this file may be used under the terms of the GNU
28 ** General Public License version 2.0 or (at your option) the GNU General
29 ** Public license version 3 or any later version approved by the KDE Free
30 ** Qt Foundation. The licenses are as published by the Free Software
31 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
32 ** included in the packaging of this file. Please review the following
33 ** information to ensure the GNU General Public License requirements will
34 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
35 ** https://www.gnu.org/licenses/gpl-3.0.html.
36 **
37 ** $QT_END_LICENSE$
38 **
39 ****************************************************************************/
40 
41 #ifndef QPLATFORMPRINTDEVICE_H
42 #define QPLATFORMPRINTDEVICE_H
43 
44 //
45 //  W A R N I N G
46 //  -------------
47 //
48 // This file is not part of the Qt API.  It exists for the convenience
49 // of internal files.  This header file may change from version to version
50 // without notice, or even be removed.
51 //
52 // We mean it.
53 //
54 
55 #include <QtPrintSupport/qtprintsupportglobal.h>
56 #include <private/qprint_p.h>
57 #include <private/qprintdevice_p.h>
58 
59 #include <QtCore/qvariant.h>
60 #include <QtCore/qvector.h>
61 #if QT_CONFIG(mimetype)
62 #include <QtCore/qmimetype.h>
63 #endif
64 #include <QtGui/qpagelayout.h>
65 
66 
67 QT_BEGIN_NAMESPACE
68 
69 #ifndef QT_NO_PRINTER
70 
71 class Q_PRINTSUPPORT_EXPORT QPlatformPrintDevice
72 {
73     Q_DISABLE_COPY(QPlatformPrintDevice)
74 public:
75     explicit QPlatformPrintDevice(const QString &id = QString());
76     virtual ~QPlatformPrintDevice();
77 
78     virtual QString id() const;
79     virtual QString name() const;
80     virtual QString location() const;
81     virtual QString makeAndModel() const;
82 
83     virtual bool isValid() const;
84     virtual bool isDefault() const;
85     virtual bool isRemote() const;
86 
87     virtual QPrint::DeviceState state() const;
88 
89     virtual bool isValidPageLayout(const QPageLayout &layout, int resolution) const;
90 
91     virtual bool supportsMultipleCopies() const;
92     virtual bool supportsCollateCopies() const;
93 
94     virtual QPageSize defaultPageSize() const;
95     virtual QList<QPageSize> supportedPageSizes() const;
96 
97     virtual QPageSize supportedPageSize(const QPageSize &pageSize) const;
98     virtual QPageSize supportedPageSize(QPageSize::PageSizeId pageSizeId) const;
99     virtual QPageSize supportedPageSize(const QString &pageName) const;
100     virtual QPageSize supportedPageSize(const QSize &pointSize) const;
101     virtual QPageSize supportedPageSize(const QSizeF &size, QPageSize::Unit units) const;
102 
103     virtual bool supportsCustomPageSizes() const;
104 
105     virtual QSize minimumPhysicalPageSize() const;
106     virtual QSize maximumPhysicalPageSize() const;
107 
108     virtual QMarginsF printableMargins(const QPageSize &pageSize, QPageLayout::Orientation orientation,
109                                        int resolution) const;
110 
111     virtual int defaultResolution() const;
112     virtual QList<int> supportedResolutions() const;
113 
114     virtual QPrint::InputSlot defaultInputSlot() const;
115     virtual QVector<QPrint::InputSlot> supportedInputSlots() const;
116 
117     virtual QPrint::OutputBin defaultOutputBin() const;
118     virtual QVector<QPrint::OutputBin> supportedOutputBins() const;
119 
120     virtual QPrint::DuplexMode defaultDuplexMode() const;
121     virtual QVector<QPrint::DuplexMode> supportedDuplexModes() const;
122 
123     virtual QPrint::ColorMode defaultColorMode() const;
124     virtual QVector<QPrint::ColorMode> supportedColorModes() const;
125 
126     virtual QVariant property(QPrintDevice::PrintDevicePropertyKey key) const;
127     virtual bool setProperty(QPrintDevice::PrintDevicePropertyKey key, const QVariant &value);
128     virtual bool isFeatureAvailable(QPrintDevice::PrintDevicePropertyKey key, const QVariant &params) const;
129 
130 #if QT_CONFIG(mimetype)
131     virtual QList<QMimeType> supportedMimeTypes() const;
132 #endif
133 
134     static QPageSize createPageSize(const QString &key, const QSize &size, const QString &localizedName);
135     static QPageSize createPageSize(int windowsId, const QSize &size, const QString &localizedName);
136 
137 protected:
138     virtual void loadPageSizes() const;
139     virtual void loadResolutions() const;
140     virtual void loadInputSlots() const;
141     virtual void loadOutputBins() const;
142     virtual void loadDuplexModes() const;
143     virtual void loadColorModes() const;
144 #if QT_CONFIG(mimetype)
145     virtual void loadMimeTypes() const;
146 #endif
147 
148     QPageSize supportedPageSizeMatch(const QPageSize &pageSize) const;
149 
150     QString m_id;
151     QString m_name;
152     QString m_location;
153     QString m_makeAndModel;
154 
155     bool m_isRemote;
156 
157     mutable bool m_supportsMultipleCopies;
158     mutable bool m_supportsCollateCopies;
159 
160     mutable bool m_havePageSizes;
161     mutable QList<QPageSize> m_pageSizes;
162 
163     mutable bool m_supportsCustomPageSizes;
164 
165     mutable QSize m_minimumPhysicalPageSize;
166     mutable QSize m_maximumPhysicalPageSize;
167 
168     mutable bool m_haveResolutions;
169     mutable QList<int> m_resolutions;
170 
171     mutable bool m_haveInputSlots;
172     mutable QVector<QPrint::InputSlot> m_inputSlots;
173 
174     mutable bool m_haveOutputBins;
175     mutable QVector<QPrint::OutputBin> m_outputBins;
176 
177     mutable bool m_haveDuplexModes;
178     mutable QVector<QPrint::DuplexMode> m_duplexModes;
179 
180     mutable bool m_haveColorModes;
181     mutable QVector<QPrint::ColorMode> m_colorModes;
182 
183 #if QT_CONFIG(mimetype)
184     mutable bool m_haveMimeTypes;
185     mutable QList<QMimeType> m_mimeTypes;
186 #endif
187 };
188 
189 #endif // QT_NO_PRINTER
190 
191 QT_END_NAMESPACE
192 
193 #endif // QPLATFORMPRINTDEVICE_H
194