1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of the QtGui module of the Qt Toolkit. 7 ** 8 ** $QT_BEGIN_LICENSE:LGPL$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/contact-us. 16 ** 17 ** GNU Lesser General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU Lesser 19 ** General Public License version 3 as published by the Free Software 20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 21 ** packaging of this file. Please review the following information to 22 ** ensure the GNU Lesser General Public License version 3 requirements 23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 24 ** 25 ** GNU General Public License Usage 26 ** Alternatively, this file may be used under the terms of the GNU 27 ** General Public License version 2.0 or (at your option) the GNU General 28 ** Public license version 3 or any later version approved by the KDE Free 29 ** Qt Foundation. The licenses are as published by the Free Software 30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 31 ** included in the packaging of this file. Please review the following 32 ** information to ensure the GNU General Public License requirements will 33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and 34 ** https://www.gnu.org/licenses/gpl-3.0.html. 35 ** 36 ** $QT_END_LICENSE$ 37 ** 38 ****************************************************************************/ 39 40 #ifndef QCUPS_P_H 41 #define QCUPS_P_H 42 43 // 44 // W A R N I N G 45 // ------------- 46 // 47 // This file is not part of the Qt API. It exists purely as an 48 // implementation detail. This header file may change from version to 49 // version without notice, or even be removed. 50 // 51 // We mean it. 52 // 53 54 #include <QtPrintSupport/private/qtprintsupportglobal_p.h> 55 #include <QtPrintSupport/private/qprint_p.h> 56 #include "QtCore/qstring.h" 57 #include "QtCore/qstringlist.h" 58 #include "QtPrintSupport/qprinter.h" 59 #include "QtCore/qdatetime.h" 60 61 QT_REQUIRE_CONFIG(cups); 62 63 QT_BEGIN_NAMESPACE 64 65 class QPrintDevice; 66 67 // HACK! Define these here temporarily so they can be used in the dialogs 68 // without a circular reference to QCupsPrintEngine in the plugin. 69 // Move back to qcupsprintengine_p.h in the plugin once all usage 70 // removed from the dialogs. 71 #define PPK_CupsOptions QPrintEngine::PrintEnginePropertyKey(0xfe00) 72 73 #define PDPK_PpdFile QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase) 74 #define PDPK_PpdOption QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 1) 75 #define PDPK_CupsJobPriority QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 2) 76 #define PDPK_CupsJobSheets QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 3) 77 #define PDPK_CupsJobBilling QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 4) 78 #define PDPK_CupsJobHoldUntil QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 5) 79 #define PDPK_PpdChoiceIsInstallableConflict QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 6) 80 81 class Q_PRINTSUPPORT_EXPORT QCUPSSupport 82 { 83 public: 84 // Enum for values of job-hold-until option 85 enum JobHoldUntil { 86 NoHold = 0, //CUPS Default 87 Indefinite, 88 DayTime, 89 Night, 90 SecondShift, 91 ThirdShift, 92 Weekend, 93 SpecificTime 94 }; 95 96 // Enum for valid banner pages 97 enum BannerPage { 98 NoBanner = 0, //CUPS Default 'none' 99 Standard, 100 Unclassified, 101 Confidential, 102 Classified, 103 Secret, 104 TopSecret 105 }; 106 107 // Enum for valid page set 108 enum PageSet { 109 AllPages = 0, //CUPS Default 110 OddPages, 111 EvenPages 112 }; 113 114 // Enum for valid number of pages per sheet 115 enum PagesPerSheet { 116 OnePagePerSheet = 0, 117 TwoPagesPerSheet, 118 FourPagesPerSheet, 119 SixPagesPerSheet, 120 NinePagesPerSheet, 121 SixteenPagesPerSheet 122 }; 123 124 // Enum for valid layouts of pages per sheet 125 enum PagesPerSheetLayout { 126 LeftToRightTopToBottom = 0, 127 LeftToRightBottomToTop, 128 RightToLeftTopToBottom, 129 RightToLeftBottomToTop, 130 BottomToTopLeftToRight, 131 BottomToTopRightToLeft, 132 TopToBottomLeftToRight, 133 TopToBottomRightToLeft 134 }; 135 136 static void setCupsOption(QPrinter *printer, const QString &option, const QString &value); 137 static void clearCupsOption(QPrinter *printer, const QString &option); 138 static void clearCupsOptions(QPrinter *printer); 139 140 static void setJobHold(QPrinter *printer, const JobHoldUntil jobHold = NoHold, const QTime &holdUntilTime = QTime()); 141 static void setJobBilling(QPrinter *printer, const QString &jobBilling = QString()); 142 static void setJobPriority(QPrinter *printer, int priority = 50); 143 static void setBannerPages(QPrinter *printer, const BannerPage startBannerPage, const BannerPage endBannerPage); 144 static void setPageSet(QPrinter *printer, const PageSet pageSet); 145 static void setPagesPerSheetLayout(QPrinter *printer, const PagesPerSheet pagesPerSheet, 146 const PagesPerSheetLayout pagesPerSheetLayout); 147 static void setPageRange(QPrinter *printer, int pageFrom, int pageTo); 148 static void setPageRange(QPrinter *printer, const QString &pageRange); 149 150 struct JobSheets 151 { 152 JobSheets(BannerPage s = NoBanner, BannerPage e = NoBanner) startBannerPageJobSheets153 : startBannerPage(s), endBannerPage(e) {} 154 155 BannerPage startBannerPage; 156 BannerPage endBannerPage; 157 }; 158 static JobSheets parseJobSheets(const QString &jobSheets); 159 160 struct JobHoldUntilWithTime 161 { 162 JobHoldUntilWithTime(JobHoldUntil jh = NoHold, const QTime &t = QTime()) jobHoldJobHoldUntilWithTime163 : jobHold(jh), time(t) {} 164 165 JobHoldUntil jobHold; 166 QTime time; 167 }; 168 static JobHoldUntilWithTime parseJobHoldUntil(const QString &jobHoldUntil); 169 170 static ppd_option_t *findPpdOption(const char *optionName, QPrintDevice *printDevice); 171 }; 172 Q_DECLARE_TYPEINFO(QCUPSSupport::JobHoldUntil, Q_PRIMITIVE_TYPE); 173 Q_DECLARE_TYPEINFO(QCUPSSupport::BannerPage, Q_PRIMITIVE_TYPE); 174 Q_DECLARE_TYPEINFO(QCUPSSupport::PageSet, Q_PRIMITIVE_TYPE); 175 Q_DECLARE_TYPEINFO(QCUPSSupport::PagesPerSheetLayout, Q_PRIMITIVE_TYPE); 176 Q_DECLARE_TYPEINFO(QCUPSSupport::PagesPerSheet, Q_PRIMITIVE_TYPE); 177 178 QT_END_NAMESPACE 179 180 Q_DECLARE_METATYPE(QCUPSSupport::JobHoldUntil) 181 Q_DECLARE_METATYPE(QCUPSSupport::BannerPage) 182 Q_DECLARE_METATYPE(QCUPSSupport::PageSet) 183 Q_DECLARE_METATYPE(QCUPSSupport::PagesPerSheetLayout) 184 Q_DECLARE_METATYPE(QCUPSSupport::PagesPerSheet) 185 186 #endif 187