mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-21 04:16:12 +00:00
Add PreferencesDialog and embed AsmOptions
This commit is contained in:
parent
911e4645d5
commit
94750ea15b
@ -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 <QComboBox>
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ private slots:
|
||||
|
||||
void on_actionRefresh_contents_triggered();
|
||||
|
||||
void on_actionAsmOptions_triggered();
|
||||
void on_actionPreferences_triggered();
|
||||
|
||||
void projectSaved(const QString &name);
|
||||
|
||||
|
@ -180,7 +180,7 @@ border-top: 0px;
|
||||
<rect>
|
||||
<x>367</x>
|
||||
<y>185</y>
|
||||
<width>156</width>
|
||||
<width>173</width>
|
||||
<height>206</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -219,7 +219,7 @@ border-top: 0px;
|
||||
<addaction name="actionLock"/>
|
||||
<addaction name="actionTabs_on_Top"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionAsmOptions"/>
|
||||
<addaction name="actionPreferences"/>
|
||||
<addaction name="menuTheme"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuHelp">
|
||||
@ -947,9 +947,9 @@ QToolButton:pressed {
|
||||
<string>Display offsets</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAsmOptions">
|
||||
<action name="actionPreferences">
|
||||
<property name="text">
|
||||
<string>Disassembly Options</string>
|
||||
<string>Preferences</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSaveAs">
|
||||
|
@ -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
|
||||
|
@ -1,244 +0,0 @@
|
||||
#include <QLabel>
|
||||
#include <QFontDialog>
|
||||
|
||||
#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);
|
||||
}
|
||||
}
|
231
src/dialogs/preferences/AsmOptionsWidget.cpp
Normal file
231
src/dialogs/preferences/AsmOptionsWidget.cpp
Normal file
@ -0,0 +1,231 @@
|
||||
#include <QLabel>
|
||||
#include <QFontDialog>
|
||||
|
||||
#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);
|
||||
}
|
||||
}
|
@ -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::AsmOptionsDialog> ui;
|
||||
|
||||
void saveAsDefault();
|
||||
void resetToDefault();
|
||||
std::unique_ptr<Ui::AsmOptionsWidget> 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();
|
||||
};
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AsmOptionsDialog</class>
|
||||
<widget class="QDialog" name="AsmOptionsDialog">
|
||||
<class>AsmOptionsWidget</class>
|
||||
<widget class="QWidget" name="AsmOptionsWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>476</width>
|
||||
<height>631</height>
|
||||
<width>461</width>
|
||||
<height>463</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -159,13 +159,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::RestoreDefaults</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<action name="actionSaveAsDefault">
|
||||
<property name="text">
|
52
src/dialogs/preferences/PreferencesDialog.cpp
Normal file
52
src/dialogs/preferences/PreferencesDialog.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
#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;
|
||||
}
|
||||
}
|
38
src/dialogs/preferences/PreferencesDialog.h
Normal file
38
src/dialogs/preferences/PreferencesDialog.h
Normal file
@ -0,0 +1,38 @@
|
||||
|
||||
#ifndef PREFERENCESDIALOG_H
|
||||
#define PREFERENCESDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QPushButton>
|
||||
#include <memory>
|
||||
|
||||
#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::PreferencesDialog> ui;
|
||||
|
||||
void on_buttonBox_clicked(QAbstractButton *button);
|
||||
};
|
||||
|
||||
#endif //PREFERENCESDIALOG_H
|
67
src/dialogs/preferences/PreferencesDialog.ui
Normal file
67
src/dialogs/preferences/PreferencesDialog.ui
Normal file
@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PreferencesDialog</class>
|
||||
<widget class="QDialog" name="PreferencesDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>683</width>
|
||||
<height>496</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Preferences</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::RestoreDefaults</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>PreferencesDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>PreferencesDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user