diff options
author | Renato Araujo Oliveira Filho <renato.araujo@kdab.com> | 2017-12-20 08:15:33 -0300 |
---|---|---|
committer | Albert Astals Cid <albert.astals.cid@kdab.com> | 2018-01-16 17:01:39 +0000 |
commit | 03c33a0d859f06fbcdf2e523206ff8f7b57cf8c5 (patch) | |
tree | 0efe1c31c84f7221e7d1abf58c1185b1a50e618b /src/printsupport | |
parent | 41a6877fe8ac8afde28f96e75e033f53f22939d4 (diff) |
Move color/grayscale option to cups advanced panel
CUPS has a complex way to configure colors for printers, and this can not
be represented only by radio buttons.
Because of that all colors related options will be available only in
the advanced panel.
The color/grayscale option will still be available when printing to a file.
Change-Id: I1592e779009bd80b6dfc18dde760db4154e46439
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'src/printsupport')
-rw-r--r-- | src/printsupport/dialogs/qprintdialog_unix.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp index 22d7dd1eca..3cf78381c0 100644 --- a/src/printsupport/dialogs/qprintdialog_unix.cpp +++ b/src/printsupport/dialogs/qprintdialog_unix.cpp @@ -409,6 +409,9 @@ void QPrintPropertiesDialog::setupPrinter() const #endif #if QT_CONFIG(cups) + // Set Color by default, that will change if the "ColorModel" property is available + m_printer->setColorMode(QPrinter::Color); + m_cupsOptionsModel->setCupsOptionsFromItems(m_printer); #endif } @@ -567,6 +570,11 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma options.pageSetCombo->setEnabled(false); else options.pageSetCombo->setEnabled(true); + +#if QT_CONFIG(cups) + // Disable color options on main dialog if not printing to file, it will be handled by CUPS advanced dialog + options.colorMode->setVisible(outputFormat == QPrinter::PdfFormat); +#endif } #if QT_CONFIG(cups) @@ -668,7 +676,12 @@ void QPrintDialogPrivate::setupPrinter() p->setDuplex(QPrinter::DuplexShortSide); } - p->setColorMode(options.color->isChecked() ? QPrinter::Color : QPrinter::GrayScale); +#if QT_CONFIG(cups) + // When printing to a device the colorMode will be set by the advanced panel + if (p->outputFormat() == QPrinter::PdfFormat) +#endif + p->setColorMode(options.color->isChecked() ? QPrinter::Color : QPrinter::GrayScale); + p->setPageOrder(options.reverse->isChecked() ? QPrinter::LastPageFirst : QPrinter::FirstPageFirst); // print range @@ -1417,6 +1430,10 @@ void QPPDOptionsModel::setCupsOptionsFromItems(QPrinter *printer, QOptionTreeIte if (itm->type == QOptionTreeItem::Option) { QOptionTreeItemOption *itmOption = static_cast<QOptionTreeItemOption *>(itm); const ppd_option_t *opt = static_cast<const ppd_option_t*>(itm->ptr); + + if (qstrcmp(opt->keyword, "ColorModel") == 0) + printer->setColorMode(qstrcmp(opt->choices[itmOption->selected].choice, "Gray") == 0 ? QPrinter::GrayScale : QPrinter::Color); + if (qstrcmp(opt->defchoice, opt->choices[itmOption->selected].choice) != 0) { QCUPSSupport::setCupsOption(printer, QString::fromLatin1(opt->keyword), QString::fromLatin1(opt->choices[itmOption->selected].choice)); } |