From 03c33a0d859f06fbcdf2e523206ff8f7b57cf8c5 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Wed, 20 Dec 2017 08:15:33 -0300 Subject: 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 --- src/printsupport/dialogs/qprintdialog_unix.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/printsupport') 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(itm); const ppd_option_t *opt = static_cast(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)); } -- cgit v1.2.3