From b6427ded65cd8ec031547ae0aeaa7a31f3c6a4b1 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Fri, 5 Oct 2018 17:35:27 +0200 Subject: [PATCH] Printing: Expose default and supported color modes We had this information internally but there was no public API for it Fixes: QTBUG-4071 Change-Id: Ic7f855e32a6870129e7723a47d31a629e0ea1aca Reviewed-by: Alex Blasche Reviewed-by: Frederik Gladhorn --- src/printsupport/kernel/qprinterinfo.cpp | 29 ++++++++++++++++++++++++ src/printsupport/kernel/qprinterinfo.h | 3 +++ 2 files changed, 32 insertions(+) diff --git a/src/printsupport/kernel/qprinterinfo.cpp b/src/printsupport/kernel/qprinterinfo.cpp index 49a0c9ece4..2eec95d254 100644 --- a/src/printsupport/kernel/qprinterinfo.cpp +++ b/src/printsupport/kernel/qprinterinfo.cpp @@ -387,6 +387,35 @@ QList QPrinterInfo::supportedDuplexModes() const return list; } +/*! + Returns the default color mode of this printer. + + \since 5.13 +*/ + +QPrinter::ColorMode QPrinterInfo::defaultColorMode() const +{ + Q_D(const QPrinterInfo); + return QPrinter::ColorMode(d->m_printDevice.defaultColorMode()); +} + +/*! + Returns the supported color modes of this printer. + + \since 5.13 +*/ + +QList QPrinterInfo::supportedColorModes() const +{ + Q_D(const QPrinterInfo); + QList list; + const auto supportedColorModes = d->m_printDevice.supportedColorModes(); + list.reserve(supportedColorModes.size()); + for (QPrint::ColorMode mode : supportedColorModes) + list << QPrinter::ColorMode(mode); + return list; +} + /*! Returns a list of all the available Printer Names on this system. diff --git a/src/printsupport/kernel/qprinterinfo.h b/src/printsupport/kernel/qprinterinfo.h index 8bac395ab3..7195cb76b5 100644 --- a/src/printsupport/kernel/qprinterinfo.h +++ b/src/printsupport/kernel/qprinterinfo.h @@ -93,6 +93,9 @@ public: QPrinter::DuplexMode defaultDuplexMode() const; QList supportedDuplexModes() const; + QPrinter::ColorMode defaultColorMode() const; + QList supportedColorModes() const; + static QStringList availablePrinterNames(); static QList availablePrinters();