2
* Copyright (C) 2017 Canonical, Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
#include "backend/backend_pdf.h"
20
PrinterPdfBackend::PrinterPdfBackend(const QString &printerName,
22
: PrinterBackend(printerName, parent)
24
m_type = PrinterEnum::PrinterType::PdfType;
27
QVariant PrinterPdfBackend::printerGetOption(const QString &name,
28
const QString &option) const
30
auto res = printerGetOptions(name, QStringList({option}));
34
QMap<QString, QVariant> PrinterPdfBackend::printerGetOptions(
35
const QString &name, const QStringList &options) const
39
QMap<QString, QVariant> ret;
42
rgb.colorType = PrinterEnum::ColorModelType::ColorType;
44
rgb.text = __("Color");
47
quality.name = __("Normal");
49
Q_FOREACH(const QString &option, options) {
50
if (option == QLatin1String("DefaultColorModel")) {
51
ret[option] = QVariant::fromValue(rgb);
52
} else if (option == QLatin1String("DefaultPrintQuality")) {
53
ret[option] = QVariant::fromValue(quality);
54
} else if (option == QLatin1String("SupportedPrintQualities")) {
55
auto qualities = QList<PrintQuality>({quality});
56
ret[option] = QVariant::fromValue(qualities);
57
} else if (option == QLatin1String("SupportedColorModels")) {
58
auto models = QList<ColorModel>{rgb};
59
ret[option] = QVariant::fromValue(models);
60
} else if (option == QLatin1String("AcceptJobs")) {
63
throw std::invalid_argument("Invalid value for PDF printer: " + option.toStdString());
70
QString PrinterPdfBackend::printerName() const
75
PrinterEnum::State PrinterPdfBackend::state() const
77
return PrinterEnum::State::IdleState;
80
QList<QPageSize> PrinterPdfBackend::supportedPageSizes() const
82
return QList<QPageSize>{QPageSize(QPageSize::A4)};
85
QPageSize PrinterPdfBackend::defaultPageSize() const
87
return QPageSize(QPageSize::A4);
90
bool PrinterPdfBackend::supportsCustomPageSizes() const
95
QPageSize PrinterPdfBackend::minimumPhysicalPageSize() const
97
return QPageSize(QPageSize::A4);
100
QPageSize PrinterPdfBackend::maximumPhysicalPageSize() const
102
return QPageSize(QPageSize::A4);
105
QList<int> PrinterPdfBackend::supportedResolutions() const
110
PrinterEnum::DuplexMode PrinterPdfBackend::defaultDuplexMode() const
112
return PrinterEnum::DuplexMode::DuplexNone;
115
QList<PrinterEnum::DuplexMode> PrinterPdfBackend::supportedDuplexModes() const
117
return QList<PrinterEnum::DuplexMode>{PrinterEnum::DuplexMode::DuplexNone};