summaryrefslogtreecommitdiffstats
path: root/src/plugins/printsupport/cups
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/printsupport/cups')
-rw-r--r--src/plugins/printsupport/cups/CMakeLists.txt28
-rw-r--r--src/plugins/printsupport/cups/cups.pro23
-rw-r--r--src/plugins/printsupport/cups/main.cpp44
-rw-r--r--src/plugins/printsupport/cups/qcupsprintengine.cpp83
-rw-r--r--src/plugins/printsupport/cups/qcupsprintengine_p.h41
-rw-r--r--src/plugins/printsupport/cups/qcupsprintersupport.cpp62
-rw-r--r--src/plugins/printsupport/cups/qcupsprintersupport_p.h42
-rw-r--r--src/plugins/printsupport/cups/qppdprintdevice.cpp56
-rw-r--r--src/plugins/printsupport/cups/qppdprintdevice.h40
9 files changed, 101 insertions, 318 deletions
diff --git a/src/plugins/printsupport/cups/CMakeLists.txt b/src/plugins/printsupport/cups/CMakeLists.txt
new file mode 100644
index 0000000000..b6400d2d36
--- /dev/null
+++ b/src/plugins/printsupport/cups/CMakeLists.txt
@@ -0,0 +1,28 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_find_package(Cups PROVIDED_TARGETS Cups::Cups)
+
+#####################################################################
+## QCupsPrinterSupportPlugin Plugin:
+#####################################################################
+
+qt_internal_add_plugin(QCupsPrinterSupportPlugin
+ OUTPUT_NAME cupsprintersupport
+ PLUGIN_TYPE printsupport
+ SOURCES
+ main.cpp
+ qcupsprintengine.cpp qcupsprintengine_p.h
+ qcupsprintersupport.cpp qcupsprintersupport_p.h
+ qppdprintdevice.cpp qppdprintdevice.h
+ INCLUDE_DIRECTORIES
+ ../../../printsupport/kernel
+ LIBRARIES
+ Cups::Cups
+ Qt::Core
+ Qt::CorePrivate
+ Qt::Gui
+ Qt::GuiPrivate
+ Qt::PrintSupport
+ Qt::PrintSupportPrivate
+)
diff --git a/src/plugins/printsupport/cups/cups.pro b/src/plugins/printsupport/cups/cups.pro
deleted file mode 100644
index 58bc11606b..0000000000
--- a/src/plugins/printsupport/cups/cups.pro
+++ /dev/null
@@ -1,23 +0,0 @@
-TARGET = cupsprintersupport
-MODULE = cupsprintersupport
-
-QT += core-private gui-private printsupport printsupport-private
-
-QMAKE_USE_PRIVATE += cups
-
-INCLUDEPATH += ../../../printsupport/kernel
-
-SOURCES += main.cpp \
- qppdprintdevice.cpp \
- qcupsprintersupport.cpp \
- qcupsprintengine.cpp
-
-HEADERS += qcupsprintersupport_p.h \
- qppdprintdevice.h \
- qcupsprintengine_p.h
-
-OTHER_FILES += cups.json
-
-PLUGIN_TYPE = printsupport
-PLUGIN_CLASS_NAME = QCupsPrinterSupportPlugin
-load(qt_plugin)
diff --git a/src/plugins/printsupport/cups/main.cpp b/src/plugins/printsupport/cups/main.cpp
index cf263a7f52..1d0ee5d8e5 100644
--- a/src/plugins/printsupport/cups/main.cpp
+++ b/src/plugins/printsupport/cups/main.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qcupsprintersupport_p.h"
@@ -45,6 +9,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
class QCupsPrinterSupportPlugin : public QPlatformPrinterSupportPlugin
{
Q_OBJECT
@@ -62,7 +28,7 @@ QStringList QCupsPrinterSupportPlugin::keys() const
QPlatformPrinterSupport *QCupsPrinterSupportPlugin::create(const QString &key)
{
- if (key.compare(key, QLatin1String("cupsprintersupport"), Qt::CaseInsensitive) == 0)
+ if (key.compare(key, "cupsprintersupport"_L1, Qt::CaseInsensitive) == 0)
return new QCupsPrinterSupport;
return 0;
}
diff --git a/src/plugins/printsupport/cups/qcupsprintengine.cpp b/src/plugins/printsupport/cups/qcupsprintengine.cpp
index c9683eb99d..6c50c11c0f 100644
--- a/src/plugins/printsupport/cups/qcupsprintengine.cpp
+++ b/src/plugins/printsupport/cups/qcupsprintengine.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qcupsprintengine_p.h"
@@ -89,8 +53,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
break;
case PPK_Duplex: {
QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
- if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
+ if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
d->duplex = mode;
+ d->duplexRequestedExplicitly = true;
+ }
break;
}
case PPK_PrinterName:
@@ -100,10 +66,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
d->cupsOptions = value.toStringList();
break;
case PPK_QPageSize:
- d->setPageSize(value.value<QPageSize>());
+ d->setPageSize(qvariant_cast<QPageSize>(value));
break;
case PPK_QPageLayout: {
- QPageLayout pageLayout = value.value<QPageLayout>();
+ QPageLayout pageLayout = qvariant_cast<QPageLayout>(value);
if (pageLayout.isValid() && (d->m_printDevice.isValidPageLayout(pageLayout, d->resolution)
|| d->m_printDevice.supportsCustomPageSizes()
|| d->m_printDevice.supportedPageSizes().isEmpty())) {
@@ -178,7 +144,20 @@ bool QCupsPrintEnginePrivate::openPrintDevice()
}
cupsTempFile = QString::fromLocal8Bit(filename);
outDevice = new QFile();
- static_cast<QFile *>(outDevice)->open(fd, QIODevice::WriteOnly);
+ if (!static_cast<QFile *>(outDevice)->open(fd, QIODevice::WriteOnly)) {
+ qWarning("QPdfPrinter: Could not open CUPS temporary file descriptor: %s",
+ qPrintable(outDevice->errorString()));
+ delete outDevice;
+ outDevice = nullptr;
+
+#if defined(Q_OS_WIN) && defined(Q_CC_MSVC)
+ ::_close(fd);
+#else
+ ::close(fd);
+#endif
+ fd = -1;
+ return false;
+ }
}
return true;
@@ -201,7 +180,7 @@ void QCupsPrintEnginePrivate::closePrintDevice()
// Set up print options.
QList<QPair<QByteArray, QByteArray> > options;
- QVector<cups_option_t> cupsOptStruct;
+ QList<cups_option_t> cupsOptStruct;
options.append(QPair<QByteArray, QByteArray>("media", m_pageLayout.pageSize().key().toLocal8Bit()));
@@ -249,7 +228,7 @@ void QCupsPrintEnginePrivate::closePrintDevice()
// Print the file
// Cups expect the printer original name without instance, the full name is used only to retrieve the configuration
- const auto parts = printerName.splitRef(QLatin1Char('/'));
+ const auto parts = QStringView{printerName}.split(u'/');
const auto printerOriginalName = parts.at(0);
cups_option_t* optPtr = cupsOptStruct.size() ? &cupsOptStruct.first() : 0;
cupsPrintFile(printerOriginalName.toLocal8Bit().constData(), tempFile.toLocal8Bit().constData(),
@@ -277,12 +256,18 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
m_printDevice.swap(printDevice);
printerName = m_printDevice.id();
- // Check if new printer supports current settings, otherwise us defaults
- if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
+ // in case a duplex value was explicitly set, check if new printer supports current value,
+ // otherwise use device default
+ if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
duplex = m_printDevice.defaultDuplexMode();
- QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
- if (!m_printDevice.supportedColorModes().contains(colorMode))
- grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+ duplexRequestedExplicitly = false;
+ }
+ QPrint::ColorMode colorMode = static_cast<QPrint::ColorMode>(printerColorMode());
+ if (!m_printDevice.supportedColorModes().contains(colorMode)) {
+ colorModel = (m_printDevice.defaultColorMode() == QPrint::GrayScale)
+ ? QPdfEngine::ColorModel::Grayscale
+ : QPdfEngine::ColorModel::RGB;
+ }
// Get the equivalent page size for this printer as supported names may be different
if (m_printDevice.supportedPageSize(m_pageLayout.pageSize()).isValid())
diff --git a/src/plugins/printsupport/cups/qcupsprintengine_p.h b/src/plugins/printsupport/cups/qcupsprintengine_p.h
index c021b0c643..d17b3aaedd 100644
--- a/src/plugins/printsupport/cups/qcupsprintengine_p.h
+++ b/src/plugins/printsupport/cups/qcupsprintengine_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QCUPSPRINTENGINE_P_H
#define QCUPSPRINTENGINE_P_H
@@ -100,6 +64,7 @@ private:
QStringList cupsOptions;
QString cupsTempFile;
QPrint::DuplexMode duplex;
+ bool duplexRequestedExplicitly = false;
};
QT_END_NAMESPACE
diff --git a/src/plugins/printsupport/cups/qcupsprintersupport.cpp b/src/plugins/printsupport/cups/qcupsprintersupport.cpp
index 42a7a821f2..6578d8a558 100644
--- a/src/plugins/printsupport/cups/qcupsprintersupport.cpp
+++ b/src/plugins/printsupport/cups/qcupsprintersupport.cpp
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2014 John Layt <jlayt@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// Copyright (C) 2014 John Layt <jlayt@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qcupsprintersupport_p.h"
@@ -47,14 +11,14 @@
#include <QtPrintSupport/QPrinterInfo>
-#if QT_CONFIG(dialogbuttonbox)
+#if QT_CONFIG(cupspassworddialog)
#include <QGuiApplication>
#include <QDialog>
#include <QDialogButtonBox>
#include <QFormLayout>
#include <QLabel>
#include <QLineEdit>
-#endif // QT_CONFIG(dialogbuttonbox)
+#endif // QT_CONFIG(cupspassworddialog)
#include <cups/ppd.h>
#ifndef QT_LINUXBASE // LSB merges everything into cups.h
@@ -63,7 +27,7 @@
QT_BEGIN_NAMESPACE
-#if QT_CONFIG(dialogbuttonbox)
+#if QT_CONFIG(cupspassworddialog)
static const char *getPasswordCB(const char */*prompt*/, http_t *http, const char */*method*/, const char *resource, void */*user_data*/)
{
// cups doesn't free the const char * we return so keep around
@@ -93,7 +57,7 @@ static const char *getPasswordCB(const char */*prompt*/, http_t *http, const cha
QString resourceString = QString::fromLocal8Bit(resource);
if (resourceString.startsWith(QStringLiteral("/printers/")))
- resourceString = resourceString.mid(QStringLiteral("/printers/").length());
+ resourceString = resourceString.mid(QStringLiteral("/printers/").size());
QLabel *label = new QLabel();
if (hostname == QStringLiteral("localhost")) {
@@ -125,16 +89,16 @@ static const char *getPasswordCB(const char */*prompt*/, http_t *http, const cha
return password.constData();
}
-#endif // QT_CONFIG(dialogbuttonbox)
+#endif // QT_CONFIG(cupspassworddialog)
QCupsPrinterSupport::QCupsPrinterSupport()
: QPlatformPrinterSupport()
{
-#if QT_CONFIG(dialogbuttonbox)
+#if QT_CONFIG(cupspassworddialog)
// Only show password dialog if GUI application
if (qobject_cast<QGuiApplication*>(QCoreApplication::instance()))
cupsSetPasswordCB2(getPasswordCB, nullptr /* user_data */ );
-#endif // QT_CONFIG(dialogbuttonbox)
+#endif // QT_CONFIG(cupspassworddialog)
}
QCupsPrinterSupport::~QCupsPrinterSupport()
@@ -148,7 +112,7 @@ QPrintEngine *QCupsPrinterSupport::createNativePrintEngine(QPrinter::PrinterMode
QPaintEngine *QCupsPrinterSupport::createPaintEngine(QPrintEngine *engine, QPrinter::PrinterMode printerMode)
{
- Q_UNUSED(printerMode)
+ Q_UNUSED(printerMode);
return static_cast<QCupsPrintEngine *>(engine);
}
@@ -166,7 +130,7 @@ QStringList QCupsPrinterSupport::availablePrintDeviceIds() const
for (int i = 0; i < count; ++i) {
QString printerId = QString::fromLocal8Bit(dests[i].name);
if (dests[i].instance)
- printerId += QLatin1Char('/') + QString::fromLocal8Bit(dests[i].instance);
+ printerId += u'/' + QString::fromLocal8Bit(dests[i].instance);
list.append(printerId);
}
cupsFreeDests(count, dests);
@@ -187,7 +151,7 @@ QString QCupsPrinterSupport::staticDefaultPrintDeviceId()
if (dests[i].is_default) {
printerId = QString::fromLocal8Bit(dests[i].name);
if (dests[i].instance) {
- printerId += QLatin1Char('/') + QString::fromLocal8Bit(dests[i].instance);
+ printerId += u'/' + QString::fromLocal8Bit(dests[i].instance);
break;
}
}
diff --git a/src/plugins/printsupport/cups/qcupsprintersupport_p.h b/src/plugins/printsupport/cups/qcupsprintersupport_p.h
index c2b4895c7f..bc70bae048 100644
--- a/src/plugins/printsupport/cups/qcupsprintersupport_p.h
+++ b/src/plugins/printsupport/cups/qcupsprintersupport_p.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2014 John Layt <jlayt@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// Copyright (C) 2014 John Layt <jlayt@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QCUPSPRINTERSUPPORT_H
#define QCUPSPRINTERSUPPORT_H
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.cpp b/src/plugins/printsupport/cups/qppdprintdevice.cpp
index 8bfa239dbe..95813c90fa 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.cpp
+++ b/src/plugins/printsupport/cups/qppdprintdevice.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 John Layt <jlayt@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2014 John Layt <jlayt@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qppdprintdevice.h"
@@ -52,6 +16,10 @@
QT_BEGIN_NAMESPACE
+// avoid all the warnings about using deprecated API from CUPS (as there is no real replacement)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+
QPpdPrintDevice::QPpdPrintDevice(const QString &id)
: QPlatformPrintDevice(id),
m_cupsDest(0),
@@ -60,7 +28,7 @@ QPpdPrintDevice::QPpdPrintDevice(const QString &id)
if (!id.isEmpty()) {
// TODO For now each dest is an individual device
- const auto parts = id.splitRef(QLatin1Char('/'));
+ const auto parts = QStringView{id}.split(u'/');
m_cupsName = parts.at(0).toUtf8();
if (parts.size() > 1)
m_cupsInstance = parts.at(1).toUtf8();
@@ -189,8 +157,8 @@ QMarginsF QPpdPrintDevice::printableMargins(const QPageSize &pageSize,
QPageLayout::Orientation orientation,
int resolution) const
{
- Q_UNUSED(orientation)
- Q_UNUSED(resolution)
+ Q_UNUSED(orientation);
+ Q_UNUSED(resolution);
if (!m_havePageSizes)
loadPageSizes();
// TODO Orientation?
@@ -460,7 +428,7 @@ bool QPpdPrintDevice::setProperty(QPrintDevice::PrintDevicePropertyKey key, cons
{
if (key == PDPK_PpdOption) {
const QStringList values = value.toStringList();
- if (values.count() == 2) {
+ if (values.size() == 2) {
ppdMarkOption(m_ppd, values[0].toLatin1(), values[1].toLatin1());
return true;
}
@@ -473,7 +441,7 @@ bool QPpdPrintDevice::isFeatureAvailable(QPrintDevice::PrintDevicePropertyKey ke
{
if (key == PDPK_PpdChoiceIsInstallableConflict) {
const QStringList values = params.toStringList();
- if (values.count() == 2)
+ if (values.size() == 2)
return ppdInstallableConflict(m_ppd, values[0].toLatin1(), values[1].toLatin1());
}
@@ -508,4 +476,6 @@ cups_ptype_e QPpdPrintDevice::printerTypeFlags() const
return static_cast<cups_ptype_e>(printerOption("printer-type").toUInt());
}
+QT_WARNING_POP
+
QT_END_NAMESPACE
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.h b/src/plugins/printsupport/cups/qppdprintdevice.h
index 3baf8b771b..ea8f5f2768 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.h
+++ b/src/plugins/printsupport/cups/qppdprintdevice.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 John Layt <jlayt@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2014 John Layt <jlayt@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPPDPRINTDEVICE_H
#define QPPDPRINTDEVICE_H