6#include <qpa/qplatformprintplugin.h>
7#include <qpa/qplatformprintersupport.h>
13#include "private/qcups_p.h"
14#include <QtGui/qpagelayout.h>
18#include "private/qcore_unix_p.h"
28 d->changePrinter(deviceId);
52 d->setPageSize(
d->m_printDevice.supportedPageSize(
value.toString()));
56 if (
d->m_printDevice.supportedDuplexModes().contains(
mode)) {
58 d->duplexRequestedExplicitly =
true;
63 d->changePrinter(
value.toString());
66 d->cupsOptions =
value.toStringList();
69 d->setPageSize(qvariant_cast<QPageSize>(
value));
74 ||
d->m_printDevice.supportsCustomPageSizes()
75 ||
d->m_printDevice.supportedPageSizes().isEmpty())) {
103 ret =
d->cupsOptions;
118 , duplex(
QPrint::DuplexNone)
140 fd = cupsTempFd(filename, 512);
142 qWarning(
"QPdfPrinter: Could not open temporary file to print");
159 cupsTempFile.
clear();
162 if (printerName.isEmpty()) {
163 qWarning(
"Could not determine printer to print to");
177 if (copies > 1 && collate)
201 QStringList::const_iterator
it = cupsOptions.constBegin();
202 while (
it != cupsOptions.constEnd()) {
207 const int numOptions = options.
size();
208 cupsOptStruct.
reserve(numOptions);
209 for (
int c = 0;
c < numOptions; ++
c) {
212 opt.value = options[
c].second.
data();
219 const auto printerOriginalName = parts.
at(0);
220 cups_option_t* optPtr = cupsOptStruct.
size() ? &cupsOptStruct.
first() : 0;
221 cupsPrintFile(printerOriginalName.toLocal8Bit().constData(),
tempFile.toLocal8Bit().constData(),
228void QCupsPrintEnginePrivate::changePrinter(
const QString &newPrinter)
231 if (newPrinter == printerName)
243 m_printDevice.
swap(printDevice);
244 printerName = m_printDevice.
id();
250 duplexRequestedExplicitly =
false;
263void QCupsPrintEnginePrivate::setPageSize(
const QPageSize &pageSize)
268 QPageSize usePageSize = printerPageSize.
isValid() ? printerPageSize : pageSize;
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
~QCupsPrintEnginePrivate()
bool openPrintDevice() override
void closePrintDevice() override
QVariant property(PrintEnginePropertyKey key) const override
Returns the print engine's property specified by key.
virtual ~QCupsPrintEngine()
QCupsPrintEngine(QPrinter::PrinterMode m, const QString &deviceId)
void setProperty(PrintEnginePropertyKey key, const QVariant &value) override
Sets the print engine's property specified by key to the given value.
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
bool remove()
Removes the file specified by fileName().
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
void reserve(qsizetype size)
void append(parameter_type t)
Unit units() const
Returns the units the page layout is currently defined in.
bool isValid() const
Returns true if this page layout is valid.
Unit
This enum type is used to specify the measurement unit for page layout and margins.
Orientation orientation() const
Returns the page orientation of the page layout.
void setPageSize(const QPageSize &pageSize, const QMarginsF &minMargins=QMarginsF(0, 0, 0, 0))
Sets the page size of the page layout to pageSize.
QPageSize pageSize() const
Returns the page size of the page layout.
bool isValid() const
Returns true if this page size is valid.
QString key() const
Returns the unique key of the page size.
QSizeF size(Unit units) const
Returns the size of the page in the required units.
PageSizeId id() const
Returns the standard QPageSize::PageSizeId of the page, or QPageSize::Custom.
PageSizeId
This enum type lists the available page sizes as defined in the Postscript PPD standard.
QPageLayout pageLayout() const
friend class QCupsPrintEnginePrivate
virtual void closePrintDevice()
QPrinter::PrinterState state
virtual void setProperty(PrintEnginePropertyKey key, const QVariant &value) override
Sets the print engine's property specified by key to the given value.
virtual QVariant property(PrintEnginePropertyKey key) const override
Returns the print engine's property specified by key.
QPageSize supportedPageSize(const QPageSize &pageSize) const
void swap(QPrintDevice &other)
QList< QPrint::DuplexMode > supportedDuplexModes() const
QPrint::DuplexMode defaultDuplexMode() const
QList< QPrint::ColorMode > supportedColorModes() const
QPrint::ColorMode defaultColorMode() const
QMarginsF printableMargins(const QPageSize &pageSize, QPageLayout::Orientation orientation, int resolution) const
PrintEnginePropertyKey
This enum is used to communicate properties between the print engine and QPrinter.
@ PPK_SupportsMultipleCopies
PrinterMode
This enum describes the mode the printer should work in.
Q_CORE_EXPORT QList< QStringView > split(QStringView sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the view into substring views wherever sep occurs, and returns the list of those string views.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLocal8Bit(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void clear()
Clears the contents of the string and makes it null.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QByteArray toLocal8Bit() const &
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QSet< QString >::iterator it
Combined button and popup list for selecting options.
static QT_BEGIN_NAMESPACE const char tempFile[]
std::pair< T1, T2 > QPair
QT_BEGIN_NAMESPACE QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
Q_GUI_EXPORT QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits)
static char * toLocal8Bit(char *out, QStringView in, QStringConverter::State *state)
file open(QIODevice::ReadOnly)
bool contains(const AT &t) const noexcept