From 1c3a7f0324ded37688156a08b236089b95a538a1 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 23 Jun 2017 17:03:53 +0200 Subject: [maingui] Properly support inverted meaning of HPColorAsGray Fixes #3163 --- src/maingui/printergui.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/maingui/printergui.cpp b/src/maingui/printergui.cpp index 7972a0d..8bc9133 100644 --- a/src/maingui/printergui.cpp +++ b/src/maingui/printergui.cpp @@ -8,7 +8,8 @@ #include #include -static QStringList knownColorOptions = QStringList() << "ColorModel" << "XRXColor" << "HPColorAsGray"; +static QStringList knownColorOptions = QStringList() << "ColorModel" << "XRXColor"; +static QStringList knownGrayscaleOptions = QStringList() << "HPColorAsGray"; static QStringList knownDuplexOptions = QStringList() << "Duplex"; static QStringList knownPageSizeOptions = QStringList() << "PageSize"; @@ -225,7 +226,7 @@ void PrinterGui::on_chkSecurePrint_stateChanged(int state) } } -static void enableOptionSelection(ppd_file_t *ppd, QStringList &nameList, QComboBox *combo, QLabel *label, bool forceDisabled) +static bool enableOptionSelection(ppd_file_t *ppd, QStringList &nameList, QComboBox *combo, QLabel *label, bool forceDisabled) { // Check for each option if it matches an QString matchedProperty; @@ -254,8 +255,10 @@ static void enableOptionSelection(ppd_file_t *ppd, QStringList &nameList, QCombo } } combo->setProperty("key", matchedProperty); - combo->setEnabled(!matchedProperty.isEmpty() && !forceDisabled); - label->setEnabled(!matchedProperty.isEmpty() && !forceDisabled); + const bool selectable = !matchedProperty.isEmpty() && !forceDisabled; + combo->setEnabled(selectable); + label->setEnabled(selectable); + return selectable; } // ____________________________________________________________________________ @@ -295,7 +298,11 @@ void PrinterGui::on_printerList_currentItemChanged(QTreeWidgetItem *current, QTr if (ppd != NULL) { // Check color capabilities //if (res & CUPS_PRINTER_COLOR) // No needed? Should just get disabled either way - enableOptionSelection(ppd, knownColorOptions, ui->comboBoxColor, ui->label_color, false); + if (enableOptionSelection(ppd, knownGrayscaleOptions, ui->comboBoxColor, ui->label_color, false)) { + ui->label_color->setText(trUtf8("Graustufen")); + } else if (enableOptionSelection(ppd, knownColorOptions, ui->comboBoxColor, ui->label_color, false)) { + ui->label_color->setText(trUtf8("Farbe")); + } enableOptionSelection(ppd, knownDuplexOptions, ui->comboBoxSides, ui->label_duplex, false); // TODO: Make it so this selection overrides what the document specifies enableOptionSelection(ppd, knownPageSizeOptions, ui->cboPaperSize, ui->lblPaperSize, true); -- cgit v1.2.3-55-g7522