From 8138a439239569a69afce1dbf992f80f929365ef Mon Sep 17 00:00:00 2001 From: optizone <42874998+optizone@users.noreply.github.com> Date: Fri, 21 Jun 2019 18:27:21 +0300 Subject: [PATCH] Disable modification buttons for builtin color themes (#1615) --- .../preferences/AppearanceOptionsWidget.cpp | 14 ++++++++++---- src/dialogs/preferences/AppearanceOptionsWidget.h | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/dialogs/preferences/AppearanceOptionsWidget.cpp b/src/dialogs/preferences/AppearanceOptionsWidget.cpp index ebf0d4c1..ff4d9cd8 100644 --- a/src/dialogs/preferences/AppearanceOptionsWidget.cpp +++ b/src/dialogs/preferences/AppearanceOptionsWidget.cpp @@ -61,9 +61,7 @@ AppearanceOptionsWidget::AppearanceOptionsWidget(PreferencesDialog *dialog) &AppearanceOptionsWidget::updateFontFromConfig); connect(ui->colorComboBox, &QComboBox::currentTextChanged, - this, [this](const QString &str) { - ui->editButton->setEnabled(ThemeWorker().isCustomTheme(str)); - }); + this, &AppearanceOptionsWidget::updateModificationButtons); } AppearanceOptionsWidget::~AppearanceOptionsWidget() {} @@ -90,7 +88,7 @@ void AppearanceOptionsWidget::updateThemeFromConfig(bool interfaceThemeChanged) } ui->themeComboBox->setCurrentIndex(currInterfaceThemeIndex); ui->colorComboBox->updateFromConfig(interfaceThemeChanged); - ui->editButton->setEnabled(ThemeWorker().isCustomTheme(ui->colorComboBox->currentText())); + updateModificationButtons(ui->colorComboBox->currentText()); } void AppearanceOptionsWidget::on_fontSelectionButton_clicked() @@ -245,6 +243,14 @@ void AppearanceOptionsWidget::onLanguageComboBoxCurrentIndexChanged(int index) qWarning() << tr("Cannot set language, not found in available ones"); } +void AppearanceOptionsWidget::updateModificationButtons(const QString& theme) +{ + bool editable = ThemeWorker().isCustomTheme(theme); + ui->editButton->setEnabled(editable); + ui->deleteButton->setEnabled(editable); + ui->renameButton->setEnabled(editable); +} + QIcon AppearanceOptionsWidget::getIconFromSvg(const QString& fileName, const QColor& after, const QColor& before) { QFile file(fileName); diff --git a/src/dialogs/preferences/AppearanceOptionsWidget.h b/src/dialogs/preferences/AppearanceOptionsWidget.h index d3d84845..8c1ed682 100644 --- a/src/dialogs/preferences/AppearanceOptionsWidget.h +++ b/src/dialogs/preferences/AppearanceOptionsWidget.h @@ -53,6 +53,8 @@ private slots: void on_editButton_clicked(); void onLanguageComboBoxCurrentIndexChanged(int index); + void updateModificationButtons(const QString& theme); + /** * @brief Changes all @a before colors in given @a fileName svg file to @a after