1// Copyright (C) 2014 John Layt <jlayt@kde.org>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QPPDPRINTDEVICE_H
5#define QPPDPRINTDEVICE_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of internal files. This header file may change from version to version
13// without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <qpa/qplatformprintdevice.h>
19
20#include <QtCore/qbytearray.h>
21#include <QtCore/qhash.h>
22#include <QtCore/qmargins.h>
23
24#include <cups/cups.h>
25#include <cups/ppd.h>
26
27QT_BEGIN_NAMESPACE
28
29class QPpdPrintDevice : public QPlatformPrintDevice
30{
31public:
32 explicit QPpdPrintDevice(const QString &id);
33 virtual ~QPpdPrintDevice();
34
35 bool isValid() const override;
36 bool isDefault() const override;
37
38 QPrint::DeviceState state() const override;
39
40 QPageSize defaultPageSize() const override;
41
42 QMarginsF printableMargins(const QPageSize &pageSize, QPageLayout::Orientation orientation,
43 int resolution) const override;
44
45 int defaultResolution() const override;
46
47 QPrint::InputSlot defaultInputSlot() const override;
48
49 QPrint::OutputBin defaultOutputBin() const override;
50
51 QPrint::DuplexMode defaultDuplexMode() const override;
52
53 QPrint::ColorMode defaultColorMode() const override;
54
55 QVariant property(QPrintDevice::PrintDevicePropertyKey key) const override;
56 bool setProperty(QPrintDevice::PrintDevicePropertyKey key, const QVariant &value) override;
57 bool isFeatureAvailable(QPrintDevice::PrintDevicePropertyKey key, const QVariant &params) const override;
58
59protected:
60 void loadPageSizes() const override;
61 void loadResolutions() const override;
62 void loadInputSlots() const override;
63 void loadOutputBins() const override;
64 void loadDuplexModes() const override;
65 void loadColorModes() const override;
66#if QT_CONFIG(mimetype)
67 void loadMimeTypes() const override;
68#endif
69
70private:
71 QString printerOption(const QString &key) const;
72 cups_ptype_e printerTypeFlags() const;
73
74 cups_dest_t *m_cupsDest;
75 ppd_file_t *m_ppd;
76 QByteArray m_cupsName;
77 QByteArray m_cupsInstance;
78 QMarginsF m_customMargins;
79 mutable QHash<QString, QMarginsF> m_printableMargins;
80};
81
82QT_END_NAMESPACE
83
84#endif // QPPDPRINTDEVICE_H
85

source code of qtbase/src/plugins/printsupport/cups/qppdprintdevice.h