diff options
author | Simon Rettberg | 2017-06-23 17:03:53 +0200 |
---|---|---|
committer | Simon Rettberg | 2017-06-23 17:03:53 +0200 |
commit | 1c3a7f0324ded37688156a08b236089b95a538a1 (patch) | |
tree | d11f37180d6d815e1ce6196f9875183406289d8a | |
parent | [maingui] Added HPColorAsGray to color printer markers (diff) | |
download | printergui-1c3a7f0324ded37688156a08b236089b95a538a1.tar.gz printergui-1c3a7f0324ded37688156a08b236089b95a538a1.tar.xz printergui-1c3a7f0324ded37688156a08b236089b95a538a1.zip |
[maingui] Properly support inverted meaning of HPColorAsGray
Fixes #3163
-rw-r--r-- | src/maingui/printergui.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
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 <QFileInfo> #include <pwd.h> -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); |