diff options
Diffstat (limited to 'src/printsupport/kernel')
27 files changed, 343 insertions, 1170 deletions
diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp index bf80b6a586..231b816499 100644 --- a/src/printsupport/kernel/qcups.cpp +++ b/src/printsupport/kernel/qcups.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 "qcups_p.h" @@ -44,6 +8,18 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + +QT_IMPL_METATYPE_EXTERN_TAGGED(QCUPSSupport::JobHoldUntil, + QCUPSSupport__JobHoldUntil) +QT_IMPL_METATYPE_EXTERN_TAGGED(QCUPSSupport::BannerPage, + QCUPSSupport__BannerPage) +QT_IMPL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PageSet, QCUPSSupport__PageSet) +QT_IMPL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PagesPerSheetLayout, + QCUPSSupport__PagesPerSheetLayout) +QT_IMPL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PagesPerSheet, + QCUPSSupport__PagesPerSheet) + static QStringList cupsOptionsList(QPrinter *printer) noexcept { return printer->printEngine()->property(PPK_CupsOptions).toStringList(); @@ -113,30 +89,29 @@ static inline QString jobHoldToString(const QCUPSSupport::JobHoldUntil jobHold, case QCUPSSupport::NoHold: return QString(); } - Q_UNREACHABLE(); - return QString(); + Q_UNREACHABLE_RETURN(QString()); } QCUPSSupport::JobHoldUntilWithTime QCUPSSupport::parseJobHoldUntil(const QString &jobHoldUntil) { - if (jobHoldUntil == QLatin1String("indefinite")) { + if (jobHoldUntil == "indefinite"_L1) { return { QCUPSSupport::Indefinite, QTime() }; - } else if (jobHoldUntil == QLatin1String("day-time")) { + } else if (jobHoldUntil == "day-time"_L1) { return { QCUPSSupport::DayTime, QTime() }; - } else if (jobHoldUntil == QLatin1String("night")) { + } else if (jobHoldUntil == "night"_L1) { return { QCUPSSupport::Night, QTime() }; - } else if (jobHoldUntil == QLatin1String("second-shift")) { + } else if (jobHoldUntil == "second-shift"_L1) { return { QCUPSSupport::SecondShift, QTime() }; - } else if (jobHoldUntil == QLatin1String("third-shift")) { + } else if (jobHoldUntil == "third-shift"_L1) { return { QCUPSSupport::ThirdShift, QTime() }; - } else if (jobHoldUntil == QLatin1String("weekend")) { + } else if (jobHoldUntil == "weekend"_L1) { return { QCUPSSupport::Weekend, QTime() }; } - QTime parsedTime = QTime::fromString(jobHoldUntil, QStringLiteral("h:m:s")); + QTime parsedTime = QTime::fromString(jobHoldUntil, u"h:m:s"); if (!parsedTime.isValid()) - parsedTime = QTime::fromString(jobHoldUntil, QStringLiteral("h:m")); + parsedTime = QTime::fromString(jobHoldUntil, u"h:m"); if (parsedTime.isValid()) { // CUPS time is in UTC, user expects local time, so get the equivalent QDateTime dateTimeUtc = QDateTime::currentDateTimeUtc(); @@ -200,19 +175,18 @@ static inline QString bannerPageToString(const QCUPSSupport::BannerPage bannerPa case QCUPSSupport::Secret: return QStringLiteral("secret"); case QCUPSSupport::TopSecret: return QStringLiteral("topsecret"); } - Q_UNREACHABLE(); - return QString(); + Q_UNREACHABLE_RETURN(QString()); } static inline QCUPSSupport::BannerPage stringToBannerPage(const QString &bannerPage) { - if (bannerPage == QLatin1String("none")) return QCUPSSupport::NoBanner; - else if (bannerPage == QLatin1String("standard")) return QCUPSSupport::Standard; - else if (bannerPage == QLatin1String("unclassified")) return QCUPSSupport::Unclassified; - else if (bannerPage == QLatin1String("confidential")) return QCUPSSupport::Confidential; - else if (bannerPage == QLatin1String("classified")) return QCUPSSupport::Classified; - else if (bannerPage == QLatin1String("secret")) return QCUPSSupport::Secret; - else if (bannerPage == QLatin1String("topsecret")) return QCUPSSupport::TopSecret; + if (bannerPage == "none"_L1) return QCUPSSupport::NoBanner; + else if (bannerPage == "standard"_L1) return QCUPSSupport::Standard; + else if (bannerPage == "unclassified"_L1) return QCUPSSupport::Unclassified; + else if (bannerPage == "confidential"_L1) return QCUPSSupport::Confidential; + else if (bannerPage == "classified"_L1) return QCUPSSupport::Classified; + else if (bannerPage == "secret"_L1) return QCUPSSupport::Secret; + else if (bannerPage == "topsecret"_L1) return QCUPSSupport::TopSecret; return QCUPSSupport::NoBanner; } @@ -221,8 +195,8 @@ QCUPSSupport::JobSheets QCUPSSupport::parseJobSheets(const QString &jobSheets) { JobSheets result; - const QStringList parts = jobSheets.split(QLatin1Char(',')); - if (parts.count() == 2) { + const QStringList parts = jobSheets.split(u','); + if (parts.size() == 2) { result.startBannerPage = stringToBannerPage(parts[0]); result.endBannerPage = stringToBannerPage(parts[1]); } @@ -235,7 +209,7 @@ void QCUPSSupport::setBannerPages(QPrinter *printer, const BannerPage startBanne const QString startBanner = bannerPageToString(startBannerPage); const QString endBanner = bannerPageToString(endBannerPage); - setCupsOption(printer, QStringLiteral("job-sheets"), startBanner + QLatin1Char(',') + endBanner); + setCupsOption(printer, QStringLiteral("job-sheets"), startBanner + u',' + endBanner); } void QCUPSSupport::setPageSet(QPrinter *printer, const PageSet pageSet) @@ -265,8 +239,8 @@ void QCUPSSupport::setPagesPerSheetLayout(QPrinter *printer, const PagesPerShee // WARNING: and it is the last one (before the "\0")! static const char pagesPerSheetData[][2] = { "1", "2", "4", "6", "9", {'1', '6'}, "\0" }; static const char pageLayoutData[][5] = {"lrtb", "lrbt", "rlbt", "rltb", "btlr", "btrl", "tblr", "tbrl"}; - setCupsOption(printer, QStringLiteral("number-up"), QLatin1String(pagesPerSheetData[pagesPerSheet])); - setCupsOption(printer, QStringLiteral("number-up-layout"), QLatin1String(pageLayoutData[pagesPerSheetLayout])); + setCupsOption(printer, QStringLiteral("number-up"), QLatin1StringView(pagesPerSheetData[pagesPerSheet])); + setCupsOption(printer, QStringLiteral("number-up-layout"), QLatin1StringView(pageLayoutData[pagesPerSheetLayout])); } void QCUPSSupport::setPageRange(QPrinter *printer, int pageFrom, int pageTo) diff --git a/src/printsupport/kernel/qcups_p.h b/src/printsupport/kernel/qcups_p.h index 4d72230b90..4570935ba1 100644 --- a/src/printsupport/kernel/qcups_p.h +++ b/src/printsupport/kernel/qcups_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 QCUPS_P_H #define QCUPS_P_H @@ -177,10 +141,14 @@ Q_DECLARE_TYPEINFO(QCUPSSupport::PagesPerSheet, Q_PRIMITIVE_TYPE); QT_END_NAMESPACE -Q_DECLARE_METATYPE(QCUPSSupport::JobHoldUntil) -Q_DECLARE_METATYPE(QCUPSSupport::BannerPage) -Q_DECLARE_METATYPE(QCUPSSupport::PageSet) -Q_DECLARE_METATYPE(QCUPSSupport::PagesPerSheetLayout) -Q_DECLARE_METATYPE(QCUPSSupport::PagesPerSheet) +QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::JobHoldUntil, + QCUPSSupport__JobHoldUntil, Q_PRINTSUPPORT_EXPORT) +QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::BannerPage, + QCUPSSupport__BannerPage, Q_PRINTSUPPORT_EXPORT) +QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PageSet, QCUPSSupport__PageSet, Q_PRINTSUPPORT_EXPORT) +QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PagesPerSheetLayout, + QCUPSSupport__PagesPerSheetLayout, Q_PRINTSUPPORT_EXPORT) +QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PagesPerSheet, + QCUPSSupport__PagesPerSheet, Q_PRINTSUPPORT_EXPORT) #endif diff --git a/src/printsupport/kernel/qpaintengine_alpha.cpp b/src/printsupport/kernel/qpaintengine_alpha.cpp index a394ca378d..4c34457570 100644 --- a/src/printsupport/kernel/qpaintengine_alpha.cpp +++ b/src/printsupport/kernel/qpaintengine_alpha.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 <qtprintsupportglobal.h> @@ -437,9 +401,9 @@ void QAlphaPaintEnginePrivate::addAlphaRect(const QRectF &rect) bool QAlphaPaintEnginePrivate::canSeeTroughBackground(bool somethingInRectHasAlpha, const QRectF &rect) const { if (somethingInRectHasAlpha) { - if (m_dirtyRects.count() != m_numberOfCachedRects) { - m_cachedDirtyRgn.setRects(m_dirtyRects.constData(), m_dirtyRects.count()); - m_numberOfCachedRects = m_dirtyRects.count(); + if (m_dirtyRects.size() != m_numberOfCachedRects) { + m_cachedDirtyRgn.setRects(m_dirtyRects.constData(), m_dirtyRects.size()); + m_numberOfCachedRects = m_dirtyRects.size(); } return m_cachedDirtyRgn.intersects(rect.toAlignedRect()); } diff --git a/src/printsupport/kernel/qpaintengine_alpha_p.h b/src/printsupport/kernel/qpaintengine_alpha_p.h index 5d64f8f586..221194d4ad 100644 --- a/src/printsupport/kernel/qpaintengine_alpha_p.h +++ b/src/printsupport/kernel/qpaintengine_alpha_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 QPAINTENGINE_ALPHA_P_H #define QPAINTENGINE_ALPHA_P_H diff --git a/src/printsupport/kernel/qpaintengine_preview.cpp b/src/printsupport/kernel/qpaintengine_preview.cpp index 7179249677..7e3a9f8c60 100644 --- a/src/printsupport/kernel/qpaintengine_preview.cpp +++ b/src/printsupport/kernel/qpaintengine_preview.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 <private/qpaintengine_preview_p.h> #include <private/qpainter_p.h> diff --git a/src/printsupport/kernel/qpaintengine_preview_p.h b/src/printsupport/kernel/qpaintengine_preview_p.h index 9203e40235..87692a0b92 100644 --- a/src/printsupport/kernel/qpaintengine_preview_p.h +++ b/src/printsupport/kernel/qpaintengine_preview_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 QPAINTENGINE_PREVIEW_P_H #define QPAINTENGINE_PREVIEW_P_H diff --git a/src/printsupport/kernel/qplatformprintdevice.cpp b/src/printsupport/kernel/qplatformprintdevice.cpp index 748ac50d86..a2ee51f887 100644 --- a/src/printsupport/kernel/qplatformprintdevice.cpp +++ b/src/printsupport/kernel/qplatformprintdevice.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 QtPrintSupport 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) 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 "qplatformprintdevice.h" @@ -111,6 +75,10 @@ bool QPlatformPrintDevice::isValidPageLayout(const QPageLayout &layout, int reso if (!supportedPageSize(layout.pageSize()).isValid()) return false; + // In fullpage mode, margins outside the printable area are valid + if (layout.mode() == QPageLayout::FullPageMode) + return true; + // Check the margins are valid QMarginsF pointMargins = layout.margins(QPageLayout::Point); QMarginsF printMargins = printableMargins(layout.pageSize(), layout.orientation(), resolution); @@ -163,7 +131,7 @@ QPageSize QPlatformPrintDevice::supportedPageSize(const QPageSize &pageSize) con // e.g. Windows defines DMPAPER_11X17 and DMPAPER_TABLOID with names "11x17" and "Tabloid", but both // map to QPageSize::Tabloid / PPD Key "Tabloid" / ANSI B Tabloid if (pageSize.id() != QPageSize::Custom) { - for (const QPageSize &ps : qAsConst(m_pageSizes)) { + for (const QPageSize &ps : std::as_const(m_pageSizes)) { if (ps.id() == pageSize.id() && ps.name() == pageSize.name()) return ps; } @@ -171,7 +139,7 @@ QPageSize QPlatformPrintDevice::supportedPageSize(const QPageSize &pageSize) con // Next try match on id only if not custom if (pageSize.id() != QPageSize::Custom) { - for (const QPageSize &ps : qAsConst(m_pageSizes)) { + for (const QPageSize &ps : std::as_const(m_pageSizes)) { if (ps.id() == pageSize.id()) return ps; } @@ -186,7 +154,7 @@ QPageSize QPlatformPrintDevice::supportedPageSize(QPageSize::PageSizeId pageSize if (!m_havePageSizes) loadPageSizes(); - for (const QPageSize &ps : qAsConst(m_pageSizes)) { + for (const QPageSize &ps : std::as_const(m_pageSizes)) { if (ps.id() == pageSizeId) return ps; } @@ -200,7 +168,7 @@ QPageSize QPlatformPrintDevice::supportedPageSize(const QString &pageName) const if (!m_havePageSizes) loadPageSizes(); - for (const QPageSize &ps : qAsConst(m_pageSizes)) { + for (const QPageSize &ps : std::as_const(m_pageSizes)) { if (ps.name() == pageName) return ps; } @@ -233,7 +201,7 @@ QPageSize QPlatformPrintDevice::supportedPageSizeMatch(const QPageSize &pageSize return pageSize; // Try to find a supported page size based on point size - for (const QPageSize &ps : qAsConst(m_pageSizes)) { + for (const QPageSize &ps : std::as_const(m_pageSizes)) { if (ps.sizePoints() == pageSize.sizePoints()) return ps; } diff --git a/src/printsupport/kernel/qplatformprintdevice.h b/src/printsupport/kernel/qplatformprintdevice.h index 827a11a576..a8d9c10f7f 100644 --- a/src/printsupport/kernel/qplatformprintdevice.h +++ b/src/printsupport/kernel/qplatformprintdevice.h @@ -1,42 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2014 John Layt <jlayt@kde.org> -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPrintSupport 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) 2014 John Layt <jlayt@kde.org> +// Copyright (C) 2018 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 QPLATFORMPRINTDEVICE_H #define QPLATFORMPRINTDEVICE_H diff --git a/src/printsupport/kernel/qplatformprintersupport.cpp b/src/printsupport/kernel/qplatformprintersupport.cpp index 31fe5b57af..f900de62c4 100644 --- a/src/printsupport/kernel/qplatformprintersupport.cpp +++ b/src/printsupport/kernel/qplatformprintersupport.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 "qplatformprintersupport.h" #include "qplatformprintdevice.h" diff --git a/src/printsupport/kernel/qplatformprintersupport.h b/src/printsupport/kernel/qplatformprintersupport.h index 413c1067c2..0aba2eab59 100644 --- a/src/printsupport/kernel/qplatformprintersupport.h +++ b/src/printsupport/kernel/qplatformprintersupport.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 QPLATFORMPRINTERSUPPORT_H #define QPLATFORMPRINTERSUPPORT_H diff --git a/src/printsupport/kernel/qplatformprintplugin.cpp b/src/printsupport/kernel/qplatformprintplugin.cpp index 6f470b835c..c48e5f65bf 100644 --- a/src/printsupport/kernel/qplatformprintplugin.cpp +++ b/src/printsupport/kernel/qplatformprintplugin.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 "qplatformprintplugin.h" #include "qplatformprintersupport.h" @@ -46,16 +10,18 @@ #ifndef QT_NO_PRINTER -QT_BEGIN_NAMESPACE - #if defined(Q_OS_MACOS) Q_IMPORT_PLUGIN(QCocoaPrinterSupportPlugin) #elif defined(Q_OS_WIN) Q_IMPORT_PLUGIN(QWindowsPrinterSupportPlugin) #endif +QT_BEGIN_NAMESPACE + +using namespace Qt::StringLiterals; + Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, - (QPlatformPrinterSupportFactoryInterface_iid, QLatin1String("/printsupport"), Qt::CaseInsensitive)) + (QPlatformPrinterSupportFactoryInterface_iid, "/printsupport"_L1, Qt::CaseInsensitive)) QPlatformPrinterSupportPlugin::QPlatformPrinterSupportPlugin(QObject *parent) : QObject(parent) @@ -105,4 +71,6 @@ QPlatformPrinterSupport *QPlatformPrinterSupportPlugin::get() QT_END_NAMESPACE +#include "moc_qplatformprintplugin.cpp" + #endif diff --git a/src/printsupport/kernel/qplatformprintplugin.h b/src/printsupport/kernel/qplatformprintplugin.h index db28da4dd3..0e7ec9cd9f 100644 --- a/src/printsupport/kernel/qplatformprintplugin.h +++ b/src/printsupport/kernel/qplatformprintplugin.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 QPLATFORMPRINTPLUGIN_H #define QPLATFORMPRINTPLUGIN_H diff --git a/src/printsupport/kernel/qprint.cpp b/src/printsupport/kernel/qprint.cpp new file mode 100644 index 0000000000..755da40a08 --- /dev/null +++ b/src/printsupport/kernel/qprint.cpp @@ -0,0 +1,159 @@ +// Copyright (C) 2022 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 "qprint_p.h" + +QT_BEGIN_NAMESPACE + +#ifndef QT_NO_PRINTER + +// Note: PPD standard does not define a standard set of InputSlot keywords, +// it is a free form text field left to the PPD writer to decide, +// but it does suggest some names for consistency with the Windows enum. +static const InputSlotMap inputSlotMap[] = { + { QPrint::Upper, DMBIN_UPPER, "Upper" }, + { QPrint::Lower, DMBIN_LOWER, "Lower" }, + { QPrint::Middle, DMBIN_MIDDLE, "Middle" }, + { QPrint::Manual, DMBIN_MANUAL, "Manual" }, + { QPrint::Envelope, DMBIN_ENVELOPE, "Envelope" }, + { QPrint::EnvelopeManual, DMBIN_ENVMANUAL, "EnvelopeManual" }, + { QPrint::Auto, DMBIN_AUTO, "Auto" }, + { QPrint::Tractor, DMBIN_TRACTOR, "Tractor" }, + { QPrint::SmallFormat, DMBIN_SMALLFMT, "AnySmallFormat" }, + { QPrint::LargeFormat, DMBIN_LARGEFMT, "AnyLargeFormat" }, + { QPrint::LargeCapacity, DMBIN_LARGECAPACITY, "LargeCapacity" }, + { QPrint::Cassette, DMBIN_CASSETTE, "Cassette" }, + { QPrint::FormSource, DMBIN_FORMSOURCE, "FormSource" }, + { QPrint::Manual, DMBIN_MANUAL, "ManualFeed" }, + { QPrint::OnlyOne, DMBIN_ONLYONE, "OnlyOne" }, // = QPrint::Upper + { QPrint::CustomInputSlot, DMBIN_USER, "" } // Must always be last row +}; + +static const OutputBinMap outputBinMap[] = { + { QPrint::AutoOutputBin, "" }, // Not a PPD defined value, internal use only + { QPrint::UpperBin, "Upper" }, + { QPrint::LowerBin, "Lower" }, + { QPrint::RearBin, "Rear" }, + { QPrint::CustomOutputBin, "" } // Must always be last row +}; + +namespace QPrintUtils { + +QPrint::InputSlotId inputSlotKeyToInputSlotId(const QByteArray &key) +{ + for (int i = 0; inputSlotMap[i].id != QPrint::CustomInputSlot; ++i) { + if (inputSlotMap[i].key == key) + return inputSlotMap[i].id; + } + return QPrint::CustomInputSlot; +} + +QByteArray inputSlotIdToInputSlotKey(QPrint::InputSlotId id) +{ + for (int i = 0; inputSlotMap[i].id != QPrint::CustomInputSlot; ++i) { + if (inputSlotMap[i].id == id) + return QByteArray(inputSlotMap[i].key); + } + return QByteArray(); +} + +int inputSlotIdToWindowsId(QPrint::InputSlotId id) +{ + for (int i = 0; inputSlotMap[i].id != QPrint::CustomInputSlot; ++i) { + if (inputSlotMap[i].id == id) + return inputSlotMap[i].windowsId; + } + return 0; +} + +QPrint::OutputBinId outputBinKeyToOutputBinId(const QByteArray &key) +{ + for (int i = 0; outputBinMap[i].id != QPrint::CustomOutputBin; ++i) { + if (outputBinMap[i].key == key) + return outputBinMap[i].id; + } + return QPrint::CustomOutputBin; +} + +QByteArray outputBinIdToOutputBinKey(QPrint::OutputBinId id) +{ + for (int i = 0; outputBinMap[i].id != QPrint::CustomOutputBin; ++i) { + if (outputBinMap[i].id == id) + return QByteArray(outputBinMap[i].key); + } + return QByteArray(); +} + +QPrint::InputSlot paperBinToInputSlot(int windowsId, const QString &name) +{ + QPrint::InputSlot slot; + slot.name = name; + int i; + for (i = 0; inputSlotMap[i].id != QPrint::CustomInputSlot; ++i) { + if (inputSlotMap[i].windowsId == windowsId) { + slot.key = inputSlotMap[i].key; + slot.id = inputSlotMap[i].id; + slot.windowsId = inputSlotMap[i].windowsId; + return slot; + } + } + slot.key = inputSlotMap[i].key; + slot.id = inputSlotMap[i].id; + slot.windowsId = windowsId; + return slot; +} + +#if (defined Q_OS_MACOS) || (defined Q_OS_UNIX && QT_CONFIG(cups)) + +// PPD utilities shared by CUPS and Mac plugins requiring CUPS headers +// May turn into a proper internal QPpd class if enough shared between Mac and CUPS, +// but where would it live? Not in base module as don't want to link to CUPS. +// May have to have two copies in plugins to keep in sync. + +QPrint::InputSlot ppdChoiceToInputSlot(const ppd_choice_t &choice) +{ + QPrint::InputSlot input; + input.key = choice.choice; + input.name = QString::fromUtf8(choice.text); + input.id = inputSlotKeyToInputSlotId(input.key); + input.windowsId = inputSlotMap[input.id].windowsId; + return input; +} + +QPrint::OutputBin ppdChoiceToOutputBin(const ppd_choice_t &choice) +{ + QPrint::OutputBin output; + output.key = choice.choice; + output.name = QString::fromUtf8(choice.text); + output.id = outputBinKeyToOutputBinId(output.key); + return output; +} + +int parsePpdResolution(const QByteArray &value) +{ + if (value.isEmpty()) + return -1; + // value can be in form 600dpi or 600x600dpi + QByteArray result = value.split('x').at(0); + if (result.endsWith("dpi")) + result.chop(3); + return result.toInt(); +} + +QPrint::DuplexMode ppdChoiceToDuplexMode(const QByteArray &choice) +{ + if (choice == "DuplexTumble") + return QPrint::DuplexShortSide; + else if (choice == "DuplexNoTumble") + return QPrint::DuplexLongSide; + else // None or SimplexTumble or SimplexNoTumble + return QPrint::DuplexNone; +} + +#endif // Mac and CUPS PPD Utilities + +} + +#endif // QT_NO_PRINTER + +QT_END_NAMESPACE diff --git a/src/printsupport/kernel/qprint_p.h b/src/printsupport/kernel/qprint_p.h index 4956775461..0a94aa8db3 100644 --- a/src/printsupport/kernel/qprint_p.h +++ b/src/printsupport/kernel/qprint_p.h @@ -1,41 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2014 John Layt <jlayt@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPrintSupport 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) 2022 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 QPRINT_P_H #define QPRINT_P_H @@ -59,6 +24,7 @@ #if (defined Q_OS_MACOS) || (defined Q_OS_UNIX && QT_CONFIG(cups)) #include <cups/ppd.h> // Use for type defs only, don't want to actually link in main module +// ### QT_DECL_METATYPE_EXTERN_TAGGED once there's a qprint.cpp TU Q_DECLARE_METATYPE(ppd_file_t *) #endif @@ -102,6 +68,7 @@ namespace QPrint { DuplexShortSide }; + // Note: Keep in sync with QPrinter::ColorMode enum ColorMode { GrayScale, Color @@ -159,142 +126,32 @@ struct InputSlotMap { const char *key; }; -// Note: PPD standard does not define a standard set of InputSlot keywords, -// it is a free form text field left to the PPD writer to decide, -// but it does suggest some names for consistency with the Windows enum. -static const InputSlotMap inputSlotMap[] = { - { QPrint::Upper, DMBIN_UPPER, "Upper" }, - { QPrint::Lower, DMBIN_LOWER, "Lower" }, - { QPrint::Middle, DMBIN_MIDDLE, "Middle" }, - { QPrint::Manual, DMBIN_MANUAL, "Manual" }, - { QPrint::Envelope, DMBIN_ENVELOPE, "Envelope" }, - { QPrint::EnvelopeManual, DMBIN_ENVMANUAL, "EnvelopeManual" }, - { QPrint::Auto, DMBIN_AUTO, "Auto" }, - { QPrint::Tractor, DMBIN_TRACTOR, "Tractor" }, - { QPrint::SmallFormat, DMBIN_SMALLFMT, "AnySmallFormat" }, - { QPrint::LargeFormat, DMBIN_LARGEFMT, "AnyLargeFormat" }, - { QPrint::LargeCapacity, DMBIN_LARGECAPACITY, "LargeCapacity" }, - { QPrint::Cassette, DMBIN_CASSETTE, "Cassette" }, - { QPrint::FormSource, DMBIN_FORMSOURCE, "FormSource" }, - { QPrint::Manual, DMBIN_MANUAL, "ManualFeed" }, - { QPrint::OnlyOne, DMBIN_ONLYONE, "OnlyOne" }, // = QPrint::Upper - { QPrint::CustomInputSlot, DMBIN_USER, "" } // Must always be last row -}; - struct OutputBinMap { QPrint::OutputBinId id; const char *key; }; -static const OutputBinMap outputBinMap[] = { - { QPrint::AutoOutputBin, "" }, // Not a PPD defined value, internal use only - { QPrint::UpperBin, "Upper" }, - { QPrint::LowerBin, "Lower" }, - { QPrint::RearBin, "Rear" }, - { QPrint::CustomOutputBin, "" } // Must always be last row -}; - // Print utilities shared by print plugins -class QPrintUtils -{ - -public: - - static QPrint::InputSlotId inputSlotKeyToInputSlotId(const QByteArray &key) - { - for (int i = 0; inputSlotMap[i].id != QPrint::CustomInputSlot; ++i) { - if (inputSlotMap[i].key == key) - return inputSlotMap[i].id; - } - return QPrint::CustomInputSlot; - } - - static QByteArray inputSlotIdToInputSlotKey(QPrint::InputSlotId id) - { - for (int i = 0; inputSlotMap[i].id != QPrint::CustomInputSlot; ++i) { - if (inputSlotMap[i].id == id) - return QByteArray(inputSlotMap[i].key); - } - return QByteArray(); - } - - static int inputSlotIdToWindowsId(QPrint::InputSlotId id) - { - for (int i = 0; inputSlotMap[i].id != QPrint::CustomInputSlot; ++i) { - if (inputSlotMap[i].id == id) - return inputSlotMap[i].windowsId; - } - return 0; - } - - static QPrint::OutputBinId outputBinKeyToOutputBinId(const QByteArray &key) - { - for (int i = 0; outputBinMap[i].id != QPrint::CustomOutputBin; ++i) { - if (outputBinMap[i].key == key) - return outputBinMap[i].id; - } - return QPrint::CustomOutputBin; - } - - static QByteArray outputBinIdToOutputBinKey(QPrint::OutputBinId id) - { - for (int i = 0; outputBinMap[i].id != QPrint::CustomOutputBin; ++i) { - if (outputBinMap[i].id == id) - return QByteArray(outputBinMap[i].key); - } - return QByteArray(); - } - -#if (defined Q_OS_MACOS) || (defined Q_OS_UNIX && QT_CONFIG(cups)) - - // PPD utilities shared by CUPS and Mac plugins requiring CUPS headers - // May turn into a proper internal QPpd class if enough shared between Mac and CUPS, - // but where would it live? Not in base module as don't want to link to CUPS. - // May have to have two copies in plugins to keep in sync. - - static QPrint::InputSlot ppdChoiceToInputSlot(const ppd_choice_t &choice) - { - QPrint::InputSlot input; - input.key = choice.choice; - input.name = QString::fromUtf8(choice.text); - input.id = inputSlotKeyToInputSlotId(input.key); - input.windowsId = inputSlotMap[input.id].windowsId; - return input; - } - - static QPrint::OutputBin ppdChoiceToOutputBin(const ppd_choice_t &choice) - { - QPrint::OutputBin output; - output.key = choice.choice; - output.name = QString::fromUtf8(choice.text); - output.id = outputBinKeyToOutputBinId(output.key); - return output; - } - - static int parsePpdResolution(const QByteArray &value) - { - if (value.isEmpty()) - return -1; - // value can be in form 600dpi or 600x600dpi - QByteArray result = value.split('x').at(0); - if (result.endsWith("dpi")) - result.chop(3); - return result.toInt(); - } - - static QPrint::DuplexMode ppdChoiceToDuplexMode(const QByteArray &choice) - { - if (choice == "DuplexTumble") - return QPrint::DuplexShortSide; - else if (choice == "DuplexNoTumble") - return QPrint::DuplexLongSide; - else // None or SimplexTumble or SimplexNoTumble - return QPrint::DuplexNone; - } - -#endif // Mac and CUPS PPD Utilities - +namespace QPrintUtils { + +Q_PRINTSUPPORT_EXPORT QPrint::InputSlotId inputSlotKeyToInputSlotId(const QByteArray &key); +Q_PRINTSUPPORT_EXPORT QByteArray inputSlotIdToInputSlotKey(QPrint::InputSlotId id); +Q_PRINTSUPPORT_EXPORT int inputSlotIdToWindowsId(QPrint::InputSlotId id); +Q_PRINTSUPPORT_EXPORT QPrint::OutputBinId outputBinKeyToOutputBinId(const QByteArray &key); +Q_PRINTSUPPORT_EXPORT QByteArray outputBinIdToOutputBinKey(QPrint::OutputBinId id); +Q_PRINTSUPPORT_EXPORT QPrint::InputSlot paperBinToInputSlot(int windowsId, const QString &name); + +# if (defined Q_OS_MACOS) || (defined Q_OS_UNIX && QT_CONFIG(cups)) +// PPD utilities shared by CUPS and Mac plugins requiring CUPS headers +// May turn into a proper internal QPpd class if enough shared between Mac and CUPS, +// but where would it live? Not in base module as don't want to link to CUPS. +// May have to have two copies in plugins to keep in sync. +Q_PRINTSUPPORT_EXPORT QPrint::InputSlot ppdChoiceToInputSlot(const ppd_choice_t &choice); +Q_PRINTSUPPORT_EXPORT QPrint::OutputBin ppdChoiceToOutputBin(const ppd_choice_t &choice); +Q_PRINTSUPPORT_EXPORT int parsePpdResolution(const QByteArray &value); +Q_PRINTSUPPORT_EXPORT QPrint::DuplexMode ppdChoiceToDuplexMode(const QByteArray &choice); +# endif // Mac and CUPS PPD Utilities }; #endif // QT_NO_PRINTER diff --git a/src/printsupport/kernel/qprintdevice.cpp b/src/printsupport/kernel/qprintdevice.cpp index f30cc30c21..acf6d0f329 100644 --- a/src/printsupport/kernel/qprintdevice.cpp +++ b/src/printsupport/kernel/qprintdevice.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 QtPrintSupport 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) 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 "qprintdevice_p.h" #include "qplatformprintdevice.h" diff --git a/src/printsupport/kernel/qprintdevice_p.h b/src/printsupport/kernel/qprintdevice_p.h index 7f172129cc..ec4b9c59fc 100644 --- a/src/printsupport/kernel/qprintdevice_p.h +++ b/src/printsupport/kernel/qprintdevice_p.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 QtPrintSupport 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) 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 QPRINTDEVICE_H #define QPRINTDEVICE_H diff --git a/src/printsupport/kernel/qprintengine.h b/src/printsupport/kernel/qprintengine.h index 698f7548cf..65d9ed9a06 100644 --- a/src/printsupport/kernel/qprintengine.h +++ b/src/printsupport/kernel/qprintengine.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 QPRINTENGINE_H #define QPRINTENGINE_H @@ -44,6 +8,7 @@ #include <QtCore/qvariant.h> #include <QtPrintSupport/qprinter.h> +// ### move to qmargins.h Q_DECLARE_METATYPE(QMarginsF) QT_BEGIN_NAMESPACE diff --git a/src/printsupport/kernel/qprintengine_pdf.cpp b/src/printsupport/kernel/qprintengine_pdf.cpp index 7f1c20916b..3e50247186 100644 --- a/src/printsupport/kernel/qprintengine_pdf.cpp +++ b/src/printsupport/kernel/qprintengine_pdf.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 "qprintengine_pdf_p.h" @@ -140,7 +104,14 @@ void QPdfPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va d->collate = value.toBool(); break; case PPK_ColorMode: - d->grayscale = (QPrinter::ColorMode(value.toInt()) == QPrinter::GrayScale); + switch (QPrinter::ColorMode(value.toInt())) { + case QPrinter::GrayScale: + d->colorModel = QPdfEngine::ColorModel::Grayscale; + break; + case QPrinter::Color: + d->colorModel = QPdfEngine::ColorModel::Auto; + break; + } break; case PPK_Creator: d->creator = value.toString(); @@ -213,7 +184,8 @@ void QPdfPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va Q_ASSERT(margins.size() == 4); d->m_pageLayout.setUnits(QPageLayout::Point); d->m_pageLayout.setMargins(QMarginsF(margins.at(0).toReal(), margins.at(1).toReal(), - margins.at(2).toReal(), margins.at(3).toReal())); + margins.at(2).toReal(), margins.at(3).toReal()), + QPageLayout::OutOfBoundsPolicy::Clamp); break; } case PPK_QPageSize: { @@ -225,7 +197,7 @@ void QPdfPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va case PPK_QPageMargins: { QPair<QMarginsF, QPageLayout::Unit> pair = qvariant_cast<QPair<QMarginsF, QPageLayout::Unit> >(value); d->m_pageLayout.setUnits(pair.second); - d->m_pageLayout.setMargins(pair.first); + d->m_pageLayout.setMargins(pair.first, QPageLayout::OutOfBoundsPolicy::Clamp); break; } case PPK_QPageLayout: { @@ -257,7 +229,7 @@ QVariant QPdfPrintEngine::property(PrintEnginePropertyKey key) const ret = d->collate; break; case PPK_ColorMode: - ret = d->grayscale ? QPrinter::GrayScale : QPrinter::Color; + ret = d->printerColorMode(); break; case PPK_Creator: ret = d->creator; @@ -403,6 +375,22 @@ QPdfPrintEnginePrivate::~QPdfPrintEnginePrivate() { } +QPrinter::ColorMode QPdfPrintEnginePrivate::printerColorMode() const +{ + switch (colorModel) { + case QPdfEngine::ColorModel::RGB: + case QPdfEngine::ColorModel::CMYK: + case QPdfEngine::ColorModel::Auto: + return QPrinter::Color; + case QPdfEngine::ColorModel::Grayscale: + return QPrinter::GrayScale; + } + + Q_UNREACHABLE(); + return QPrinter::Color; +} + + QT_END_NAMESPACE #endif // QT_NO_PRINTER diff --git a/src/printsupport/kernel/qprintengine_pdf_p.h b/src/printsupport/kernel/qprintengine_pdf_p.h index e0f5674eb7..dbf50080a4 100644 --- a/src/printsupport/kernel/qprintengine_pdf_p.h +++ b/src/printsupport/kernel/qprintengine_pdf_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 QPRINTENGINE_PDF_P_H #define QPRINTENGINE_PDF_P_H @@ -115,6 +79,8 @@ public: QPdfPrintEnginePrivate(QPrinter::PrinterMode m); ~QPdfPrintEnginePrivate(); + QPrinter::ColorMode printerColorMode() const; + virtual bool openPrintDevice(); virtual void closePrintDevice(); diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp index d320accad0..10c4c681ba 100644 --- a/src/printsupport/kernel/qprinter.cpp +++ b/src/printsupport/kernel/qprinter.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 "qprinter.h" #include "qprinter_p.h" @@ -61,6 +25,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #define ABORT_IF_ACTIVE(location) \ if (d->printEngine->printerState() == QPrinter::Active) { \ qWarning("%s: Cannot be changed while printer is active", location); \ @@ -163,6 +129,11 @@ QList<const QPicture *> QPrinterPrivate::previewPages() const return QList<const QPicture *>(); } +bool QPrinterPrivate::previewMode() const +{ + return (previewEngine != nullptr) && (previewEngine == printEngine); +} + void QPrinterPrivate::setPreviewMode(bool enable) { Q_Q(QPrinter); @@ -465,7 +436,7 @@ public: Note the difference between Point and DevicePixel. The Point unit is defined to be 1/72th of an inch, while the DevicePixel unit is - resolution dependant and is based on the actual pixels, or dots, on + resolution dependent and is based on the actual pixels, or dots, on the printer. */ @@ -749,7 +720,7 @@ void QPrinter::setOutputFileName(const QString &fileName) ABORT_IF_ACTIVE("QPrinter::setOutputFileName"); QFileInfo fi(fileName); - if (!fi.suffix().compare(QLatin1String("pdf"), Qt::CaseInsensitive)) + if (!fi.suffix().compare("pdf"_L1, Qt::CaseInsensitive)) setOutputFormat(QPrinter::PdfFormat); else if (fileName.isEmpty()) setOutputFormat(QPrinter::NativeFormat); @@ -1306,7 +1277,7 @@ QPrinter::PrinterState QPrinter::printerState() const return d->printEngine->printerState(); } -#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC) +#if defined(Q_OS_WIN) || defined(Q_QDOC) /*! Returns the supported paper sizes for this printer. @@ -1444,7 +1415,8 @@ int QPrinter::toPage() const void QPrinter::setFromTo(int from, int to) { d->pageRanges.clear(); - d->pageRanges.addRange(from, to); + if (from && to) + d->pageRanges.addRange(from, to); } /*! diff --git a/src/printsupport/kernel/qprinter.h b/src/printsupport/kernel/qprinter.h index 253460ce72..c60f0eea1f 100644 --- a/src/printsupport/kernel/qprinter.h +++ b/src/printsupport/kernel/qprinter.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 QPRINTER_H #define QPRINTER_H @@ -174,7 +138,7 @@ public: QList<int> supportedResolutions() const; -#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC) +#if defined(Q_OS_WIN) || defined(Q_QDOC) QList<PaperSource> supportedPaperSources() const; #endif diff --git a/src/printsupport/kernel/qprinter_p.h b/src/printsupport/kernel/qprinter_p.h index 4c42ed5717..77dd5fb4bc 100644 --- a/src/printsupport/kernel/qprinter_p.h +++ b/src/printsupport/kernel/qprinter_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 QPRINTER_P_H #define QPRINTER_P_H @@ -106,6 +70,7 @@ public: #if QT_CONFIG(printpreviewwidget) QList<const QPicture *> previewPages() const; void setPreviewMode(bool); + bool previewMode() const; #endif void setProperty(QPrintEngine::PrintEnginePropertyKey key, const QVariant &value); diff --git a/src/printsupport/kernel/qprinterinfo.cpp b/src/printsupport/kernel/qprinterinfo.cpp index c285f9afc5..59078b4df4 100644 --- a/src/printsupport/kernel/qprinterinfo.cpp +++ b/src/printsupport/kernel/qprinterinfo.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 "qprinterinfo.h" #include "qprinterinfo_p.h" @@ -57,7 +21,7 @@ class QPrinterInfoPrivateDeleter public: static inline void cleanup(QPrinterInfoPrivate *d) { - if (d != shared_null) + if (d != &*shared_null) delete d; } }; @@ -106,7 +70,7 @@ QPrinterInfo::QPrinterInfo() Constructs a copy of \a other. */ QPrinterInfo::QPrinterInfo(const QPrinterInfo &other) - : d_ptr((other.d_ptr.data() == shared_null) ? shared_null : new QPrinterInfoPrivate(*other.d_ptr)) + : d_ptr((other.d_ptr.data() == shared_null) ? &*shared_null : new QPrinterInfoPrivate(*other.d_ptr)) { } diff --git a/src/printsupport/kernel/qprinterinfo.h b/src/printsupport/kernel/qprinterinfo.h index f97b79b486..f1b16e7ccb 100644 --- a/src/printsupport/kernel/qprinterinfo.h +++ b/src/printsupport/kernel/qprinterinfo.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 QPRINTERINFO_H #define QPRINTERINFO_H @@ -44,7 +8,6 @@ #include <QtPrintSupport/qprinter.h> #include <QtCore/QList> -#include <QtCore/QPair> #include <QtGui/qpagesize.h> QT_BEGIN_NAMESPACE diff --git a/src/printsupport/kernel/qprinterinfo_p.h b/src/printsupport/kernel/qprinterinfo_p.h index 727457a959..ef6a814468 100644 --- a/src/printsupport/kernel/qprinterinfo_p.h +++ b/src/printsupport/kernel/qprinterinfo_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 QPRINTERINFO_P_H #define QPRINTERINFO_P_H diff --git a/src/printsupport/kernel/qtprintsupportglobal.h b/src/printsupport/kernel/qtprintsupportglobal.h index 5d958432ea..95f52d18f5 100644 --- a/src/printsupport/kernel/qtprintsupportglobal.h +++ b/src/printsupport/kernel/qtprintsupportglobal.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Intel Corporation. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore 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 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QTPRINTSUPPORTGLOBAL_H #define QTPRINTSUPPORTGLOBAL_H diff --git a/src/printsupport/kernel/qtprintsupportglobal_p.h b/src/printsupport/kernel/qtprintsupportglobal_p.h index 0623a08f1c..53afe86e56 100644 --- a/src/printsupport/kernel/qtprintsupportglobal_p.h +++ b/src/printsupport/kernel/qtprintsupportglobal_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 QtPrintSupport 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 QTPRINTSUPPORTGLOBAL_P_H #define QTPRINTSUPPORTGLOBAL_P_H |