diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 85908b91..3e6e22e1 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -3,7 +3,7 @@ #include "dialogs/CommentsDialog.h" #include "dialogs/AboutDialog.h" #include "dialogs/RenameDialog.h" -#include "dialogs/AsmOptionsDialog.h" +#include "dialogs/preferences/PreferencesDialog.h" #include "utils/Helpers.h" #include @@ -890,9 +890,9 @@ void MainWindow::on_actionRefresh_contents_triggered() refreshAll(); } -void MainWindow::on_actionAsmOptions_triggered() +void MainWindow::on_actionPreferences_triggered() { - auto dialog = new AsmOptionsDialog(this); + auto dialog = new PreferencesDialog(this); dialog->show(); } diff --git a/src/MainWindow.h b/src/MainWindow.h index a700f9fa..21626d44 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -155,7 +155,7 @@ private slots: void on_actionRefresh_contents_triggered(); - void on_actionAsmOptions_triggered(); + void on_actionPreferences_triggered(); void projectSaved(const QString &name); diff --git a/src/MainWindow.ui b/src/MainWindow.ui index b45a609d..b3ad5384 100644 --- a/src/MainWindow.ui +++ b/src/MainWindow.ui @@ -180,7 +180,7 @@ border-top: 0px; 367 185 - 156 + 173 206 @@ -219,7 +219,7 @@ border-top: 0px; - + @@ -947,9 +947,9 @@ QToolButton:pressed { Display offsets - + - Disassembly Options + Preferences diff --git a/src/cutter.pro b/src/cutter.pro index 9cf6f939..a3fd6ca2 100644 --- a/src/cutter.pro +++ b/src/cutter.pro @@ -48,7 +48,7 @@ SOURCES += \ utils/HexHighlighter.cpp \ utils/Highlighter.cpp \ utils/MdHighlighter.cpp \ - dialogs/AsmOptionsDialog.cpp \ + dialogs/preferences/AsmOptionsWidget.cpp \ dialogs/NewFileDialog.cpp \ AnalThread.cpp \ widgets/CommentsWidget.cpp \ @@ -80,7 +80,8 @@ SOURCES += \ utils/SvgIconEngine.cpp \ widgets/PseudocodeWidget.cpp \ widgets/VisualNavbar.cpp \ - widgets/GraphView.cpp + widgets/GraphView.cpp \ + dialogs/preferences/PreferencesDialog.cpp HEADERS += \ cutter.h \ @@ -88,7 +89,7 @@ HEADERS += \ utils/RichTextPainter.h \ utils/CachedFontMetrics.h \ dialogs/AboutDialog.h \ - dialogs/AsmOptionsDialog.h \ + dialogs/preferences/AsmOptionsWidget.h \ dialogs/CommentsDialog.h \ dialogs/FlagDialog.h \ dialogs/RenameDialog.h \ @@ -131,11 +132,12 @@ HEADERS += \ utils/SvgIconEngine.h \ widgets/PseudocodeWidget.h \ widgets/VisualNavbar.h \ - widgets/GraphView.h + widgets/GraphView.h \ + dialogs/preferences/PreferencesDialog.h FORMS += \ dialogs/AboutDialog.ui \ - dialogs/AsmOptionsDialog.ui \ + dialogs/preferences/AsmOptionsWidget.ui \ dialogs/CommentsDialog.ui \ dialogs/FlagDialog.ui \ dialogs/RenameDialog.ui \ @@ -161,7 +163,8 @@ FORMS += \ widgets/SidebarWidget.ui \ widgets/HexdumpWidget.ui \ dialogs/SaveProjectDialog.ui \ - widgets/PseudocodeWidget.ui + widgets/PseudocodeWidget.ui \ + dialogs/preferences/PreferencesDialog.ui RESOURCES += \ resources.qrc diff --git a/src/dialogs/AsmOptionsDialog.cpp b/src/dialogs/AsmOptionsDialog.cpp deleted file mode 100644 index afac8314..00000000 --- a/src/dialogs/AsmOptionsDialog.cpp +++ /dev/null @@ -1,244 +0,0 @@ -#include -#include - -#include "AsmOptionsDialog.h" -#include "ui_AsmOptionsDialog.h" - -#include "utils/Helpers.h" -#include "utils/Configuration.h" - -AsmOptionsDialog::AsmOptionsDialog(QWidget *parent) - : QDialog(parent), - core(CutterCore::getInstance()), - ui(new Ui::AsmOptionsDialog) -{ - ui->setupUi(this); - - ui->buttonBox->addButton(tr("Save as Defaults"), QDialogButtonBox::ButtonRole::ApplyRole); - - ui->syntaxComboBox->blockSignals(true); - for(const auto &syntax : core->cmdList("e asm.syntax=?")) - ui->syntaxComboBox->addItem(syntax, syntax); - ui->syntaxComboBox->blockSignals(false); - - // asm.offset=false would break reading the offset in DisassemblyWidget - // TODO: remove this when DisassemblyWidget::readDisassemblyOffset() allows it - ui->offsetCheckBox->setVisible(false); - - updateAsmOptionsFromVars(); - updateFontFromConfig(); - - connect(core, SIGNAL(asmOptionsChanged()), this, SLOT(updateAsmOptionsFromVars())); - connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(updateFontFromConfig())); -} - -AsmOptionsDialog::~AsmOptionsDialog() {} - -void AsmOptionsDialog::updateFontFromConfig() -{ - QFont currentFont = Config()->getFont(); - ui->fontSelectionLabel->setText(currentFont.toString()); -} - -void AsmOptionsDialog::updateAsmOptionsFromVars() -{ - qhelpers::setCheckedWithoutSignals(ui->esilCheckBox, core->getConfigb("asm.esil")); - qhelpers::setCheckedWithoutSignals(ui->pseudoCheckBox, core->getConfigb("asm.pseudo")); - qhelpers::setCheckedWithoutSignals(ui->offsetCheckBox, core->getConfigb("asm.offset")); - qhelpers::setCheckedWithoutSignals(ui->describeCheckBox, core->getConfigb("asm.describe")); - qhelpers::setCheckedWithoutSignals(ui->stackpointerCheckBox, core->getConfigb("asm.stackptr")); - - bool bytesEnabled = core->getConfigb("asm.bytes"); - qhelpers::setCheckedWithoutSignals(ui->bytesCheckBox, bytesEnabled); - qhelpers::setCheckedWithoutSignals(ui->bytespaceCheckBox, core->getConfigb("asm.bytespace")); - ui->bytespaceCheckBox->setEnabled(bytesEnabled); - qhelpers::setCheckedWithoutSignals(ui->lbytesCheckBox, core->getConfigb("asm.lbytes")); - ui->lbytesCheckBox->setEnabled(bytesEnabled); - - QString currentSyntax = core->getConfig("asm.syntax"); - for (int i = 0; i < ui->syntaxComboBox->count(); i++) - { - if (ui->syntaxComboBox->itemData(i) == currentSyntax) - { - ui->syntaxComboBox->blockSignals(true); - ui->syntaxComboBox->setCurrentIndex(i); - ui->syntaxComboBox->blockSignals(false); - break; - } - } - - ui->caseComboBox->blockSignals(true); - if (core->getConfigb("asm.ucase")) - { - ui->caseComboBox->setCurrentIndex(1); - } - else if(core->getConfigb("asm.capitalize")) - { - ui->caseComboBox->setCurrentIndex(2); - } - else - { - ui->caseComboBox->setCurrentIndex(0); - } - ui->caseComboBox->blockSignals(false); - - qhelpers::setCheckedWithoutSignals(ui->bblineCheckBox, core->getConfigb("asm.bbline")); - - bool varsubEnabled = core->getConfigb("asm.varsub"); - qhelpers::setCheckedWithoutSignals(ui->varsubCheckBox, varsubEnabled); - qhelpers::setCheckedWithoutSignals(ui->varsubOnlyCheckBox, core->getConfigb("asm.varsub_only")); - ui->varsubOnlyCheckBox->setEnabled(varsubEnabled); -} - - -void AsmOptionsDialog::saveAsDefault() -{ - core->saveDefaultAsmOptions(); -} - -void AsmOptionsDialog::resetToDefault() -{ - core->resetDefaultAsmOptions(); - updateAsmOptionsFromVars(); - triggerAsmOptionsChanged(); -} - -void AsmOptionsDialog::triggerAsmOptionsChanged() -{ - disconnect(core, SIGNAL(asmOptionsChanged()), this, SLOT(updateAsmOptionsFromVars())); - core->triggerAsmOptionsChanged(); - connect(core, SIGNAL(asmOptionsChanged()), this, SLOT(updateAsmOptionsFromVars())); -} - - -void AsmOptionsDialog::on_esilCheckBox_toggled(bool checked) -{ - core->setConfig("asm.esil", checked); - triggerAsmOptionsChanged(); -} - -void AsmOptionsDialog::on_pseudoCheckBox_toggled(bool checked) -{ - core->setConfig("asm.pseudo", checked); - triggerAsmOptionsChanged(); -} - -void AsmOptionsDialog::on_offsetCheckBox_toggled(bool checked) -{ - core->setConfig("asm.offset", checked); - triggerAsmOptionsChanged(); -} - -void AsmOptionsDialog::on_describeCheckBox_toggled(bool checked) -{ - core->setConfig("asm.describe", checked); - triggerAsmOptionsChanged(); -} - -void AsmOptionsDialog::on_stackpointerCheckBox_toggled(bool checked) -{ - core->setConfig("asm.stackptr", checked); - triggerAsmOptionsChanged(); -} - -void AsmOptionsDialog::on_bytesCheckBox_toggled(bool checked) -{ - core->setConfig("asm.bytes", checked); - ui->bytespaceCheckBox->setEnabled(checked); - ui->lbytesCheckBox->setEnabled(checked); - triggerAsmOptionsChanged(); -} - -void AsmOptionsDialog::on_bytespaceCheckBox_toggled(bool checked) -{ - core->setConfig("asm.bytespace", checked); - triggerAsmOptionsChanged(); -} - -void AsmOptionsDialog::on_lbytesCheckBox_toggled(bool checked) -{ - core->setConfig("asm.lbytes", checked); - triggerAsmOptionsChanged(); -} - -void AsmOptionsDialog::on_syntaxComboBox_currentIndexChanged(int index) -{ - core->setConfig("asm.syntax", ui->syntaxComboBox->itemData(index).toString().toUtf8().constData()); - triggerAsmOptionsChanged(); -} - -void AsmOptionsDialog::on_caseComboBox_currentIndexChanged(int index) -{ - bool ucase; - bool capitalize; - - switch (index) - { - // lowercase - case 0: - default: - ucase = false; - capitalize = false; - break; - - // uppercase - case 1: - ucase = true; - capitalize = false; - break; - - case 2: - ucase = false; - capitalize = true; - break; - } - - core->setConfig("asm.ucase", ucase); - core->setConfig("asm.capitalize", capitalize); - - triggerAsmOptionsChanged(); -} - -void AsmOptionsDialog::on_bblineCheckBox_toggled(bool checked) -{ - core->setConfig("asm.bbline", checked); - triggerAsmOptionsChanged(); -} - -void AsmOptionsDialog::on_varsubCheckBox_toggled(bool checked) -{ - core->setConfig("asm.varsub", checked); - ui->varsubOnlyCheckBox->setEnabled(checked); - triggerAsmOptionsChanged(); -} - -void AsmOptionsDialog::on_varsubOnlyCheckBox_toggled(bool checked) -{ - core->setConfig("asm.varsub_only", checked); - triggerAsmOptionsChanged(); -} - -void AsmOptionsDialog::on_buttonBox_clicked(QAbstractButton *button) -{ - switch (ui->buttonBox->buttonRole(button)) - { - case QDialogButtonBox::ButtonRole::ApplyRole: - saveAsDefault(); - break; - case QDialogButtonBox::ButtonRole::ResetRole: - resetToDefault(); - break; - default: - break; - } -} - -void AsmOptionsDialog::on_fontSelectionButton_clicked() -{ - QFont currentFont = Config()->getFont(); - bool ok; - QFont newFont = QFontDialog::getFont(&ok, currentFont, this); - if (ok) { - Config()->setFont(newFont); - } -} diff --git a/src/dialogs/preferences/AsmOptionsWidget.cpp b/src/dialogs/preferences/AsmOptionsWidget.cpp new file mode 100644 index 00000000..9f0c9d46 --- /dev/null +++ b/src/dialogs/preferences/AsmOptionsWidget.cpp @@ -0,0 +1,231 @@ +#include +#include + +#include "AsmOptionsWidget.h" +#include "ui_AsmOptionsWidget.h" + +#include "PreferencesDialog.h" + +#include "utils/Helpers.h" +#include "utils/Configuration.h" + +AsmOptionsWidget::AsmOptionsWidget(PreferencesDialog *dialog, QWidget *parent) + : QDialog(parent), + ui(new Ui::AsmOptionsWidget) +{ + ui->setupUi(this); + + ui->syntaxComboBox->blockSignals(true); + for(const auto &syntax : Core()->cmdList("e asm.syntax=?")) + ui->syntaxComboBox->addItem(syntax, syntax); + ui->syntaxComboBox->blockSignals(false); + + // asm.offset=false would break reading the offset in DisassemblyWidget + // TODO: remove this when DisassemblyWidget::readDisassemblyOffset() allows it + ui->offsetCheckBox->setVisible(false); + + updateAsmOptionsFromVars(); + updateFontFromConfig(); + + connect(Core(), SIGNAL(asmOptionsChanged()), this, SLOT(updateAsmOptionsFromVars())); + connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(updateFontFromConfig())); + + connect(dialog, SIGNAL(saveAsDefault()), this, SLOT(saveAsDefault())); + connect(dialog, SIGNAL(resetToDefault()), this, SLOT(resetToDefault())); +} + +AsmOptionsWidget::~AsmOptionsWidget() {} + +void AsmOptionsWidget::updateFontFromConfig() +{ + QFont currentFont = Config()->getFont(); + ui->fontSelectionLabel->setText(currentFont.toString()); +} + +void AsmOptionsWidget::updateAsmOptionsFromVars() +{ + qhelpers::setCheckedWithoutSignals(ui->esilCheckBox, Core()->getConfigb("asm.esil")); + qhelpers::setCheckedWithoutSignals(ui->pseudoCheckBox, Core()->getConfigb("asm.pseudo")); + qhelpers::setCheckedWithoutSignals(ui->offsetCheckBox, Core()->getConfigb("asm.offset")); + qhelpers::setCheckedWithoutSignals(ui->describeCheckBox, Core()->getConfigb("asm.describe")); + qhelpers::setCheckedWithoutSignals(ui->stackpointerCheckBox, Core()->getConfigb("asm.stackptr")); + + bool bytesEnabled = Core()->getConfigb("asm.bytes"); + qhelpers::setCheckedWithoutSignals(ui->bytesCheckBox, bytesEnabled); + qhelpers::setCheckedWithoutSignals(ui->bytespaceCheckBox, Core()->getConfigb("asm.bytespace")); + ui->bytespaceCheckBox->setEnabled(bytesEnabled); + qhelpers::setCheckedWithoutSignals(ui->lbytesCheckBox, Core()->getConfigb("asm.lbytes")); + ui->lbytesCheckBox->setEnabled(bytesEnabled); + + QString currentSyntax = Core()->getConfig("asm.syntax"); + for (int i = 0; i < ui->syntaxComboBox->count(); i++) + { + if (ui->syntaxComboBox->itemData(i) == currentSyntax) + { + ui->syntaxComboBox->blockSignals(true); + ui->syntaxComboBox->setCurrentIndex(i); + ui->syntaxComboBox->blockSignals(false); + break; + } + } + + ui->caseComboBox->blockSignals(true); + if (Core()->getConfigb("asm.ucase")) + { + ui->caseComboBox->setCurrentIndex(1); + } + else if(Core()->getConfigb("asm.capitalize")) + { + ui->caseComboBox->setCurrentIndex(2); + } + else + { + ui->caseComboBox->setCurrentIndex(0); + } + ui->caseComboBox->blockSignals(false); + + qhelpers::setCheckedWithoutSignals(ui->bblineCheckBox, Core()->getConfigb("asm.bbline")); + + bool varsubEnabled = Core()->getConfigb("asm.varsub"); + qhelpers::setCheckedWithoutSignals(ui->varsubCheckBox, varsubEnabled); + qhelpers::setCheckedWithoutSignals(ui->varsubOnlyCheckBox, Core()->getConfigb("asm.varsub_only")); + ui->varsubOnlyCheckBox->setEnabled(varsubEnabled); +} + + +void AsmOptionsWidget::saveAsDefault() +{ + Core()->saveDefaultAsmOptions(); +} + +void AsmOptionsWidget::resetToDefault() +{ + Core()->resetDefaultAsmOptions(); + updateAsmOptionsFromVars(); + triggerAsmOptionsChanged(); +} + +void AsmOptionsWidget::triggerAsmOptionsChanged() +{ + disconnect(Core(), SIGNAL(asmOptionsChanged()), this, SLOT(updateAsmOptionsFromVars())); + Core()->triggerAsmOptionsChanged(); + connect(Core(), SIGNAL(asmOptionsChanged()), this, SLOT(updateAsmOptionsFromVars())); +} + + +void AsmOptionsWidget::on_esilCheckBox_toggled(bool checked) +{ + Core()->setConfig("asm.esil", checked); + triggerAsmOptionsChanged(); +} + +void AsmOptionsWidget::on_pseudoCheckBox_toggled(bool checked) +{ + Core()->setConfig("asm.pseudo", checked); + triggerAsmOptionsChanged(); +} + +void AsmOptionsWidget::on_offsetCheckBox_toggled(bool checked) +{ + Core()->setConfig("asm.offset", checked); + triggerAsmOptionsChanged(); +} + +void AsmOptionsWidget::on_describeCheckBox_toggled(bool checked) +{ + Core()->setConfig("asm.describe", checked); + triggerAsmOptionsChanged(); +} + +void AsmOptionsWidget::on_stackpointerCheckBox_toggled(bool checked) +{ + Core()->setConfig("asm.stackptr", checked); + triggerAsmOptionsChanged(); +} + +void AsmOptionsWidget::on_bytesCheckBox_toggled(bool checked) +{ + Core()->setConfig("asm.bytes", checked); + ui->bytespaceCheckBox->setEnabled(checked); + ui->lbytesCheckBox->setEnabled(checked); + triggerAsmOptionsChanged(); +} + +void AsmOptionsWidget::on_bytespaceCheckBox_toggled(bool checked) +{ + Core()->setConfig("asm.bytespace", checked); + triggerAsmOptionsChanged(); +} + +void AsmOptionsWidget::on_lbytesCheckBox_toggled(bool checked) +{ + Core()->setConfig("asm.lbytes", checked); + triggerAsmOptionsChanged(); +} + +void AsmOptionsWidget::on_syntaxComboBox_currentIndexChanged(int index) +{ + Core()->setConfig("asm.syntax", ui->syntaxComboBox->itemData(index).toString().toUtf8().constData()); + triggerAsmOptionsChanged(); +} + +void AsmOptionsWidget::on_caseComboBox_currentIndexChanged(int index) +{ + bool ucase; + bool capitalize; + + switch (index) + { + // lowercase + case 0: + default: + ucase = false; + capitalize = false; + break; + + // uppercase + case 1: + ucase = true; + capitalize = false; + break; + + case 2: + ucase = false; + capitalize = true; + break; + } + + Core()->setConfig("asm.ucase", ucase); + Core()->setConfig("asm.capitalize", capitalize); + + triggerAsmOptionsChanged(); +} + +void AsmOptionsWidget::on_bblineCheckBox_toggled(bool checked) +{ + Core()->setConfig("asm.bbline", checked); + triggerAsmOptionsChanged(); +} + +void AsmOptionsWidget::on_varsubCheckBox_toggled(bool checked) +{ + Core()->setConfig("asm.varsub", checked); + ui->varsubOnlyCheckBox->setEnabled(checked); + triggerAsmOptionsChanged(); +} + +void AsmOptionsWidget::on_varsubOnlyCheckBox_toggled(bool checked) +{ + Core()->setConfig("asm.varsub_only", checked); + triggerAsmOptionsChanged(); +} + +void AsmOptionsWidget::on_fontSelectionButton_clicked() +{ + QFont currentFont = Config()->getFont(); + bool ok; + QFont newFont = QFontDialog::getFont(&ok, currentFont, this); + if (ok) { + Config()->setFont(newFont); + } +} diff --git a/src/dialogs/AsmOptionsDialog.h b/src/dialogs/preferences/AsmOptionsWidget.h similarity index 80% rename from src/dialogs/AsmOptionsDialog.h rename to src/dialogs/preferences/AsmOptionsWidget.h index 21323e36..9929e6af 100644 --- a/src/dialogs/AsmOptionsDialog.h +++ b/src/dialogs/preferences/AsmOptionsWidget.h @@ -8,29 +8,30 @@ #include "cutter.h" +class PreferencesDialog; + namespace Ui { - class AsmOptionsDialog; + class AsmOptionsWidget; } -class AsmOptionsDialog : public QDialog +class AsmOptionsWidget : public QDialog { Q_OBJECT public: - explicit AsmOptionsDialog(QWidget *parent = nullptr); - ~AsmOptionsDialog(); + explicit AsmOptionsWidget(PreferencesDialog *dialog, QWidget *parent = nullptr); + ~AsmOptionsWidget(); private: - CutterCore *core; - std::unique_ptr ui; - - void saveAsDefault(); - void resetToDefault(); + std::unique_ptr ui; void triggerAsmOptionsChanged(); private slots: + void saveAsDefault(); + void resetToDefault(); + void updateFontFromConfig(); void updateAsmOptionsFromVars(); @@ -47,7 +48,6 @@ private slots: void on_bblineCheckBox_toggled(bool checked); void on_varsubCheckBox_toggled(bool checked); void on_varsubOnlyCheckBox_toggled(bool checked); - void on_buttonBox_clicked(QAbstractButton *button); void on_fontSelectionButton_clicked(); }; diff --git a/src/dialogs/AsmOptionsDialog.ui b/src/dialogs/preferences/AsmOptionsWidget.ui similarity index 93% rename from src/dialogs/AsmOptionsDialog.ui rename to src/dialogs/preferences/AsmOptionsWidget.ui index daf1b35e..b208145d 100644 --- a/src/dialogs/AsmOptionsDialog.ui +++ b/src/dialogs/preferences/AsmOptionsWidget.ui @@ -1,13 +1,13 @@ - AsmOptionsDialog - + AsmOptionsWidget + 0 0 - 476 - 631 + 461 + 463 @@ -159,13 +159,6 @@ - - - - QDialogButtonBox::RestoreDefaults - - - diff --git a/src/dialogs/preferences/PreferencesDialog.cpp b/src/dialogs/preferences/PreferencesDialog.cpp new file mode 100644 index 00000000..02089f55 --- /dev/null +++ b/src/dialogs/preferences/PreferencesDialog.cpp @@ -0,0 +1,52 @@ + +#include + +#include "PreferencesDialog.h" +#include "ui_PreferencesDialog.h" + +#include "AsmOptionsWidget.h" + +#include "utils/Helpers.h" +#include "utils/Configuration.h" + + +PreferencesDialog::PreferencesDialog(QWidget *parent) + : QDialog(parent), + ui(new Ui::PreferencesDialog) +{ + ui->setupUi(this); + + ui->buttonBox->addButton(tr("Save as Defaults"), QDialogButtonBox::ButtonRole::ApplyRole); + + auto asmOptionsWidget = new AsmOptionsWidget(this); + ui->tabWidget->addTab(asmOptionsWidget, tr("Disassembly")); +} + +PreferencesDialog::~PreferencesDialog() +{ +} + +void PreferencesDialog::showSection(PreferencesDialog::Section section) +{ + switch(section) + { + case Section::Disassembly: + ui->tabWidget->setCurrentIndex(0); + break; + } +} + +void PreferencesDialog::on_buttonBox_clicked(QAbstractButton *button) +{ + switch (ui->buttonBox->buttonRole(button)) + { + case QDialogButtonBox::ButtonRole::ApplyRole: + emit saveAsDefault(); + break; + case QDialogButtonBox::ButtonRole::ResetRole: + emit resetToDefault(); + break; + default: + break; + } +} diff --git a/src/dialogs/preferences/PreferencesDialog.h b/src/dialogs/preferences/PreferencesDialog.h new file mode 100644 index 00000000..61279adb --- /dev/null +++ b/src/dialogs/preferences/PreferencesDialog.h @@ -0,0 +1,38 @@ + +#ifndef PREFERENCESDIALOG_H +#define PREFERENCESDIALOG_H + +#include +#include +#include + +#include "cutter.h" + +namespace Ui +{ + class PreferencesDialog; +} + +class PreferencesDialog : public QDialog +{ +Q_OBJECT + +public: + enum class Section { Disassembly }; + + explicit PreferencesDialog(QWidget *parent = nullptr); + ~PreferencesDialog(); + + void showSection(Section section); + +signals: + void saveAsDefault(); + void resetToDefault(); + +private: + std::unique_ptr ui; + + void on_buttonBox_clicked(QAbstractButton *button); +}; + +#endif //PREFERENCESDIALOG_H diff --git a/src/dialogs/preferences/PreferencesDialog.ui b/src/dialogs/preferences/PreferencesDialog.ui new file mode 100644 index 00000000..a2b520e6 --- /dev/null +++ b/src/dialogs/preferences/PreferencesDialog.ui @@ -0,0 +1,67 @@ + + + PreferencesDialog + + + + 0 + 0 + 683 + 496 + + + + Preferences + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::RestoreDefaults + + + + + + + + + buttonBox + accepted() + PreferencesDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + PreferencesDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/menus/DisassemblyContextMenu.cpp b/src/menus/DisassemblyContextMenu.cpp index b91528ba..ef61a200 100644 --- a/src/menus/DisassemblyContextMenu.cpp +++ b/src/menus/DisassemblyContextMenu.cpp @@ -1,5 +1,5 @@ #include "DisassemblyContextMenu.h" -#include "dialogs/AsmOptionsDialog.h" +#include "dialogs/preferences/PreferencesDialog.h" #include "dialogs/CommentsDialog.h" #include "dialogs/FlagDialog.h" #include "dialogs/RenameDialog.h" @@ -351,7 +351,8 @@ void DisassemblyContextMenu::on_actionXRefs_triggered() void DisassemblyContextMenu::on_actionDisplayOptions_triggered() { - AsmOptionsDialog *dialog = new AsmOptionsDialog(this->parentWidget()); + auto *dialog = new PreferencesDialog(this->window()); + dialog->showSection(PreferencesDialog::Section::Disassembly); dialog->show(); }