Skip to content

Commit

Permalink
Abort color change when user cancels the color dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenCWills committed Sep 14, 2024
1 parent a92f49f commit 5993d00
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 3 additions & 1 deletion source/dialogs/importdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ void ImportDialog::on_fontSymbolsEdit_textChanged(const QString &text)
void ImportDialog::on_fontColorButton_clicked()
{
QColor color = QColorDialog::getColor();
setRenderColor(color);

if (color.isValid())
setRenderColor(color);
}

void ImportDialog::on_importButton_clicked()
Expand Down
8 changes: 6 additions & 2 deletions source/dialogs/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ void SettingsDialog::initialize()
void SettingsDialog::on_defaultPaletteColorPushButton_clicked()
{
QColor color = QColorDialog::getColor();
this->ui->defaultPaletteColorLineEdit->setText(color.name());

if (color.isValid())
this->ui->defaultPaletteColorLineEdit->setText(color.name());
}

void SettingsDialog::on_paletteSelectionBorderColorPushButton_clicked()
{
QColor color = QColorDialog::getColor();
this->ui->paletteSelectionBorderColorLineEdit->setText(color.name());

if (color.isValid())
this->ui->paletteSelectionBorderColorLineEdit->setText(color.name());
}

void SettingsDialog::on_settingsOkButton_clicked()
Expand Down
5 changes: 5 additions & 0 deletions source/widgets/palettewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,11 +862,16 @@ void PaletteWidget::on_colorLineEdit_returnPressed()
void PaletteWidget::on_colorPickPushButton_clicked()
{
QColor color = QColorDialog::getColor();
if (!color.isValid())
return;

QColor colorEnd;
if (this->selectedFirstColorIndex == this->selectedLastColorIndex) {
colorEnd = color;
} else {
colorEnd = QColorDialog::getColor();
if (!colorEnd.isValid())
return;
}

// Build color editing command and connect it to the current palette widget
Expand Down

0 comments on commit 5993d00

Please sign in to comment.