From 55f09f01069cdfbb4b366824916409b66ddc11f5 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Tue, 28 Jul 2015 21:55:23 +0200 Subject: [PATCH] Printing: don't save invalid colors When QColorDialog is closed with 'Cancel' button, it returns invalid color that must be discarded. So check if color is valid to prevent replacing the current color with black. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- qt-ui/templateedit.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp index 94ed276b5..95e7ebac7 100644 --- a/qt-ui/templateedit.cpp +++ b/qt-ui/templateedit.cpp @@ -168,24 +168,30 @@ void TemplateEdit::colorSelect(QAbstractButton *button) switch (btnGroup->id(button)) { case 1: color = QColorDialog::getColor(newTemplateOptions.color_palette.color1, this); - newTemplateOptions.color_palette.color1 = color; + if (color.isValid()) { + newTemplateOptions.color_palette.color1 = color; + } break; case 2: color = QColorDialog::getColor(newTemplateOptions.color_palette.color2, this); - newTemplateOptions.color_palette.color2 = color; - break; + if (color.isValid()) { + newTemplateOptions.color_palette.color2 = color; + } break; case 3: color = QColorDialog::getColor(newTemplateOptions.color_palette.color3, this); - newTemplateOptions.color_palette.color3 = color; - break; + if (color.isValid()) { + newTemplateOptions.color_palette.color3 = color; + } break; case 4: color = QColorDialog::getColor(newTemplateOptions.color_palette.color4, this); - newTemplateOptions.color_palette.color4 = color; - break; + if (color.isValid()) { + newTemplateOptions.color_palette.color4 = color; + } break; case 5: color = QColorDialog::getColor(newTemplateOptions.color_palette.color5, this); - newTemplateOptions.color_palette.color5 = color; - break; + if (color.isValid()) { + newTemplateOptions.color_palette.color5 = color; + } break; } newTemplateOptions.color_palette_index = CUSTOM; updatePreview();