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>
This commit is contained in:
Gehad elrobey 2015-07-28 21:55:23 +02:00 committed by Lubomir I. Ivanov
parent 342479586d
commit 55f09f0106

View file

@ -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();