From 0567114b09841f2ad8706caa33fe45c13284e49e Mon Sep 17 00:00:00 2001 From: Itay Cohen Date: Wed, 17 Oct 2018 10:30:56 +0300 Subject: [PATCH] Bye bye "General Settings", welcome "Appearance" (#837) * Bye bye "General Settings", welcome "Appearance" * Fix Windows header * fix typo --- src/Cutter.pro | 6 ++--- ...Widget.cpp => AppearanceOptionsWidget.cpp} | 26 +++++++++---------- ...ionsWidget.h => AppearanceOptionsWidget.h} | 14 +++++----- ...nsWidget.ui => AppearanceOptionsWidget.ui} | 6 ++--- src/dialogs/preferences/PreferencesDialog.cpp | 15 ++++++----- src/dialogs/preferences/PreferencesDialog.h | 2 +- 6 files changed, 35 insertions(+), 34 deletions(-) rename src/dialogs/preferences/{GeneralOptionsWidget.cpp => AppearanceOptionsWidget.cpp} (80%) rename src/dialogs/preferences/{GeneralOptionsWidget.h => AppearanceOptionsWidget.h} (61%) rename src/dialogs/preferences/{GeneralOptionsWidget.ui => AppearanceOptionsWidget.ui} (97%) diff --git a/src/Cutter.pro b/src/Cutter.pro index 738ab9e6..fefc79a1 100644 --- a/src/Cutter.pro +++ b/src/Cutter.pro @@ -155,7 +155,7 @@ SOURCES += \ widgets/VisualNavbar.cpp \ widgets/GraphView.cpp \ dialogs/preferences/PreferencesDialog.cpp \ - dialogs/preferences/GeneralOptionsWidget.cpp \ + dialogs/preferences/AppearanceOptionsWidget.cpp \ dialogs/preferences/GraphOptionsWidget.cpp \ dialogs/preferences/PreferenceCategory.cpp \ widgets/QuickFilterView.cpp \ @@ -250,7 +250,7 @@ HEADERS += \ widgets/VisualNavbar.h \ widgets/GraphView.h \ dialogs/preferences/PreferencesDialog.h \ - dialogs/preferences/GeneralOptionsWidget.h \ + dialogs/preferences/AppearanceOptionsWidget.h \ dialogs/preferences/PreferenceCategory.h \ dialogs/preferences/GraphOptionsWidget.h \ widgets/QuickFilterView.h \ @@ -327,7 +327,7 @@ FORMS += \ widgets/HexdumpWidget.ui \ dialogs/SaveProjectDialog.ui \ dialogs/preferences/PreferencesDialog.ui \ - dialogs/preferences/GeneralOptionsWidget.ui \ + dialogs/preferences/AppearanceOptionsWidget.ui \ dialogs/preferences/GraphOptionsWidget.ui \ widgets/QuickFilterView.ui \ widgets/PseudocodeWidget.ui \ diff --git a/src/dialogs/preferences/GeneralOptionsWidget.cpp b/src/dialogs/preferences/AppearanceOptionsWidget.cpp similarity index 80% rename from src/dialogs/preferences/GeneralOptionsWidget.cpp rename to src/dialogs/preferences/AppearanceOptionsWidget.cpp index 4c10bdbf..846bcdb4 100644 --- a/src/dialogs/preferences/GeneralOptionsWidget.cpp +++ b/src/dialogs/preferences/AppearanceOptionsWidget.cpp @@ -5,8 +5,8 @@ #include #include "PreferencesDialog.h" -#include "GeneralOptionsWidget.h" -#include "ui_GeneralOptionsWidget.h" +#include "AppearanceOptionsWidget.h" +#include "ui_AppearanceOptionsWidget.h" #include "utils/Helpers.h" #include "utils/Configuration.h" @@ -14,9 +14,9 @@ #include "utils/ColorSchemeFileSaver.h" #include "widgets/ColorSchemePrefWidget.h" -GeneralOptionsWidget::GeneralOptionsWidget(PreferencesDialog *dialog, QWidget *parent) +AppearanceOptionsWidget::AppearanceOptionsWidget(PreferencesDialog *dialog, QWidget *parent) : QDialog(parent), - ui(new Ui::GeneralOptionsWidget) + ui(new Ui::AppearanceOptionsWidget) { Q_UNUSED(dialog); ui->setupUi(this); @@ -24,7 +24,7 @@ GeneralOptionsWidget::GeneralOptionsWidget(PreferencesDialog *dialog, QWidget *p updateFontFromConfig(); updateThemeFromConfig(); - connect(Config(), &Configuration::fontsUpdated, this, &GeneralOptionsWidget::updateFontFromConfig); + connect(Config(), &Configuration::fontsUpdated, this, &AppearanceOptionsWidget::updateFontFromConfig); connect(ui.get()->colorComboBox, &QComboBox::currentTextChanged, [&](const QString & name) { static_cast(ui.get()->colorSchemePrefWidget)->setNewScheme(name); }); @@ -32,15 +32,15 @@ GeneralOptionsWidget::GeneralOptionsWidget(PreferencesDialog *dialog, QWidget *p (ui.get()->colorSchemePrefWidget)->setNewScheme(Config()->getCurrentTheme()); } -GeneralOptionsWidget::~GeneralOptionsWidget() {} +AppearanceOptionsWidget::~AppearanceOptionsWidget() {} -void GeneralOptionsWidget::updateFontFromConfig() +void AppearanceOptionsWidget::updateFontFromConfig() { QFont currentFont = Config()->getFont(); ui->fontSelectionLabel->setText(currentFont.toString()); } -void GeneralOptionsWidget::updateThemeFromConfig() +void AppearanceOptionsWidget::updateThemeFromConfig() { // Disconnect currentIndexChanged because clearing the comboxBox and refiling it causes its index to change. disconnect(ui->colorComboBox, SIGNAL(currentIndexChanged(int)), this, @@ -68,7 +68,7 @@ void GeneralOptionsWidget::updateThemeFromConfig() SLOT(on_colorComboBox_currentIndexChanged(int))); } -void GeneralOptionsWidget::on_fontSelectionButton_clicked() +void AppearanceOptionsWidget::on_fontSelectionButton_clicked() { QFont currentFont = Config()->getFont(); bool ok; @@ -79,20 +79,20 @@ void GeneralOptionsWidget::on_fontSelectionButton_clicked() } } -void GeneralOptionsWidget::on_themeComboBox_currentIndexChanged(int index) +void AppearanceOptionsWidget::on_themeComboBox_currentIndexChanged(int index) { //disconnect(Config(), SIGNAL(colorsUpdated()), this, SLOT(updateThemeFromConfig())); Config()->setTheme(index); //connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(updateThemeFromConfig())); } -void GeneralOptionsWidget::on_colorComboBox_currentIndexChanged(int index) +void AppearanceOptionsWidget::on_colorComboBox_currentIndexChanged(int index) { QString theme = ui->colorComboBox->itemText(index); Config()->setColorTheme(theme); } -void GeneralOptionsWidget::on_copyButton_clicked() +void AppearanceOptionsWidget::on_copyButton_clicked() { QString newSchemeName; do { @@ -110,7 +110,7 @@ void GeneralOptionsWidget::on_copyButton_clicked() ui.get()->colorComboBox->setCurrentIndex(ui.get()->colorComboBox->findText(newSchemeName)); } -void GeneralOptionsWidget::on_deleteButton_clicked() +void AppearanceOptionsWidget::on_deleteButton_clicked() { ColorSchemeFileWorker().deleteScheme(Config()->getCurrentTheme()); } diff --git a/src/dialogs/preferences/GeneralOptionsWidget.h b/src/dialogs/preferences/AppearanceOptionsWidget.h similarity index 61% rename from src/dialogs/preferences/GeneralOptionsWidget.h rename to src/dialogs/preferences/AppearanceOptionsWidget.h index 093d913e..5ecbd285 100644 --- a/src/dialogs/preferences/GeneralOptionsWidget.h +++ b/src/dialogs/preferences/AppearanceOptionsWidget.h @@ -1,6 +1,6 @@ -#ifndef GENERALOPTIONSWIDGET_H -#define GENERALOPTIONSWIDGET_H +#ifndef AppearanceOptionsWidget_H +#define AppearanceOptionsWidget_H #include #include @@ -11,19 +11,19 @@ class PreferencesDialog; namespace Ui { -class GeneralOptionsWidget; +class AppearanceOptionsWidget; } -class GeneralOptionsWidget : public QDialog +class AppearanceOptionsWidget : public QDialog { Q_OBJECT public: - explicit GeneralOptionsWidget(PreferencesDialog *dialog, QWidget *parent = nullptr); - ~GeneralOptionsWidget(); + explicit AppearanceOptionsWidget(PreferencesDialog *dialog, QWidget *parent = nullptr); + ~AppearanceOptionsWidget(); private: - std::unique_ptr ui; + std::unique_ptr ui; private slots: void updateFontFromConfig(); diff --git a/src/dialogs/preferences/GeneralOptionsWidget.ui b/src/dialogs/preferences/AppearanceOptionsWidget.ui similarity index 97% rename from src/dialogs/preferences/GeneralOptionsWidget.ui rename to src/dialogs/preferences/AppearanceOptionsWidget.ui index fd2fbf2f..e2b67fb2 100644 --- a/src/dialogs/preferences/GeneralOptionsWidget.ui +++ b/src/dialogs/preferences/AppearanceOptionsWidget.ui @@ -1,7 +1,7 @@ - GeneralOptionsWidget - + AppearanceOptionsWidget + 0 @@ -11,7 +11,7 @@ - General + Appearance diff --git a/src/dialogs/preferences/PreferencesDialog.cpp b/src/dialogs/preferences/PreferencesDialog.cpp index c2106b7e..a0d22fdf 100644 --- a/src/dialogs/preferences/PreferencesDialog.cpp +++ b/src/dialogs/preferences/PreferencesDialog.cpp @@ -3,7 +3,7 @@ #include "PreferencesDialog.h" #include "ui_PreferencesDialog.h" -#include "GeneralOptionsWidget.h" +#include "AppearanceOptionsWidget.h" #include "AsmOptionsWidget.h" #include "GraphOptionsWidget.h" #include "DebugOptionsWidget.h" @@ -22,11 +22,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent) ui->setupUi(this); QList prefs { - { - "General", - new GeneralOptionsWidget(this), - QIcon(":/img/icons/cog_light.svg") - }, + { "Assembly", new AsmOptionsWidget(this), @@ -43,6 +39,11 @@ PreferencesDialog::PreferencesDialog(QWidget *parent) "Debug", new DebugOptionsWidget(this), QIcon(":/img/icons/bug_light.svg") + }, + { + "Appearance", + new AppearanceOptionsWidget(this), + QIcon(":/img/icons/polar_light.svg") } }; @@ -68,7 +69,7 @@ void PreferencesDialog::showSection(PreferencesDialog::Section section) { QTreeWidgetItem *defitem; switch (section) { - case Section::General: + case Section::Appearance: ui->configPanel->setCurrentIndex(0); defitem = ui->configCategories->topLevelItem(0); ui->configCategories->setCurrentItem(defitem, 0); diff --git a/src/dialogs/preferences/PreferencesDialog.h b/src/dialogs/preferences/PreferencesDialog.h index f3408027..de39411d 100644 --- a/src/dialogs/preferences/PreferencesDialog.h +++ b/src/dialogs/preferences/PreferencesDialog.h @@ -18,7 +18,7 @@ class PreferencesDialog : public QDialog Q_OBJECT public: - enum class Section { General, Disassembly }; + enum class Section { Appearance, Disassembly }; explicit PreferencesDialog(QWidget *parent = nullptr); ~PreferencesDialog();