summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Gehad elrobey <gehadelrobey@gmail.com>2015-07-28 21:55:23 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2015-08-15 15:01:58 +0300
commit55f09f01069cdfbb4b366824916409b66ddc11f5 (patch)
tree9915484c49d3c639e20875c00dfc68ab8c965c61
parent342479586d1f34a2b7f3d1d69037cb0d631489fa (diff)
downloadsubsurface-55f09f01069cdfbb4b366824916409b66ddc11f5.tar.gz
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 <neolit123@gmail.com> Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
-rw-r--r--qt-ui/templateedit.cpp24
1 files 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();