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 plugins 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 QWINDOWSPRINTDEVICE_H 42 #define QWINDOWSPRINTDEVICE_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 <qpa/qplatformprintdevice.h> 56 57 #include <QtCore/qt_windows.h> 58 59 QT_BEGIN_NAMESPACE 60 61 class QWindowsPrinterInfo 62 { 63 public: 64 bool operator==(const QWindowsPrinterInfo &other) const 65 { 66 // We only need to check if these are the same for matching up 67 return m_id == other.m_id && m_name == other.m_name && 68 m_location == other.m_location && 69 m_makeAndModel == other.m_makeAndModel && 70 m_isRemote == other.m_isRemote; 71 } 72 QString m_id; 73 QString m_name; 74 QString m_location; 75 QString m_makeAndModel; 76 QList<QPageSize> m_pageSizes; 77 QList<int> m_resolutions; 78 QVector<QPrint::InputSlot> m_inputSlots; 79 QVector<QPrint::OutputBin> m_outputBins; 80 QVector<QPrint::DuplexMode> m_duplexModes; 81 QVector<QPrint::ColorMode> m_colorModes; 82 QSize m_minimumPhysicalPageSize; 83 QSize m_maximumPhysicalPageSize; 84 bool m_isRemote = false; 85 bool m_havePageSizes = false; 86 bool m_haveResolutions = false; 87 bool m_haveCopies = false; 88 bool m_supportsMultipleCopies = false; 89 bool m_supportsCollateCopies = false; 90 bool m_haveMinMaxPageSizes = false; 91 bool m_supportsCustomPageSizes = false; 92 bool m_haveInputSlots = false; 93 bool m_haveOutputBins = false; 94 bool m_haveDuplexModes = false; 95 bool m_haveColorModes = false; 96 }; 97 98 class QWindowsPrintDevice : public QPlatformPrintDevice 99 { 100 public: 101 QWindowsPrintDevice(); 102 explicit QWindowsPrintDevice(const QString &id); 103 virtual ~QWindowsPrintDevice(); 104 105 bool isValid() const override; 106 bool isDefault() const override; 107 108 QPrint::DeviceState state() const override; 109 110 QPageSize defaultPageSize() const override; 111 112 QMarginsF printableMargins(const QPageSize &pageSize, QPageLayout::Orientation orientation, 113 int resolution) const override; 114 115 int defaultResolution() const override; 116 117 QPrint::InputSlot defaultInputSlot() const override; 118 119 QPrint::DuplexMode defaultDuplexMode() const override; 120 121 QPrint::ColorMode defaultColorMode() const override; 122 123 static QStringList availablePrintDeviceIds(); 124 static QString defaultPrintDeviceId(); 125 126 bool supportsCollateCopies() const override; 127 bool supportsMultipleCopies() const override; 128 bool supportsCustomPageSizes() const override; 129 QSize minimumPhysicalPageSize() const override; 130 QSize maximumPhysicalPageSize() const override; 131 132 protected: 133 void loadPageSizes() const override; 134 void loadResolutions() const override; 135 void loadInputSlots() const override; 136 void loadOutputBins() const override; 137 void loadDuplexModes() const override; 138 void loadColorModes() const override; 139 void loadCopiesSupport() const; 140 void loadMinMaxPageSizes() const; 141 142 private: wcharId()143 LPCWSTR wcharId() const { return reinterpret_cast<LPCWSTR>(m_id.utf16()); } 144 145 HANDLE m_hPrinter; 146 mutable bool m_haveCopies; 147 mutable bool m_haveMinMaxPageSizes; 148 int m_infoIndex; 149 }; 150 151 QT_END_NAMESPACE 152 153 #endif // QWINDOWSPRINTDEVICE_H 154