2017-12-14 13:42:24 +00:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QFontDialog>
|
|
|
|
|
|
|
|
#include "AsmOptionsWidget.h"
|
|
|
|
#include "ui_AsmOptionsWidget.h"
|
|
|
|
|
|
|
|
#include "PreferencesDialog.h"
|
|
|
|
|
|
|
|
#include "utils/Helpers.h"
|
|
|
|
#include "utils/Configuration.h"
|
|
|
|
|
2017-12-14 19:51:24 +00:00
|
|
|
AsmOptionsWidget::AsmOptionsWidget(PreferencesDialog */*dialog*/, QWidget *parent)
|
2018-03-21 20:32:32 +00:00
|
|
|
: QDialog(parent),
|
|
|
|
ui(new Ui::AsmOptionsWidget)
|
2017-12-14 13:42:24 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
ui->syntaxComboBox->blockSignals(true);
|
2018-03-21 20:32:32 +00:00
|
|
|
for (const auto &syntax : Core()->cmdList("e asm.syntax=?"))
|
2017-12-14 13:42:24 +00:00
|
|
|
ui->syntaxComboBox->addItem(syntax, syntax);
|
|
|
|
ui->syntaxComboBox->blockSignals(false);
|
|
|
|
|
|
|
|
updateAsmOptionsFromVars();
|
|
|
|
|
|
|
|
connect(Core(), SIGNAL(asmOptionsChanged()), this, SLOT(updateAsmOptionsFromVars()));
|
|
|
|
}
|
|
|
|
|
|
|
|
AsmOptionsWidget::~AsmOptionsWidget() {}
|
|
|
|
|
|
|
|
|
|
|
|
void AsmOptionsWidget::updateAsmOptionsFromVars()
|
|
|
|
{
|
2018-03-22 08:42:54 +00:00
|
|
|
qhelpers::setCheckedWithoutSignals(ui->esilCheckBox, Config()->getConfigBool("asm.esil"));
|
|
|
|
qhelpers::setCheckedWithoutSignals(ui->pseudoCheckBox, Config()->getConfigBool("asm.pseudo"));
|
|
|
|
qhelpers::setCheckedWithoutSignals(ui->offsetCheckBox, Config()->getConfigBool("asm.offset"));
|
|
|
|
qhelpers::setCheckedWithoutSignals(ui->describeCheckBox, Config()->getConfigBool("asm.describe"));
|
|
|
|
qhelpers::setCheckedWithoutSignals(ui->stackpointerCheckBox, Config()->getConfigBool("asm.stackptr"));
|
|
|
|
qhelpers::setCheckedWithoutSignals(ui->slowCheckBox, Config()->getConfigBool("asm.slow"));
|
|
|
|
qhelpers::setCheckedWithoutSignals(ui->linesCheckBox, Config()->getConfigBool("asm.lines"));
|
2018-05-24 06:21:12 +00:00
|
|
|
qhelpers::setCheckedWithoutSignals(ui->fcnlinesCheckBox, Config()->getConfigBool("asm.lines.fcn"));
|
|
|
|
qhelpers::setCheckedWithoutSignals(ui->flgoffCheckBox, Config()->getConfigBool("asm.flags.offset"));
|
2018-03-22 08:42:54 +00:00
|
|
|
qhelpers::setCheckedWithoutSignals(ui->emuCheckBox, Config()->getConfigBool("asm.emu"));
|
2018-05-24 06:21:12 +00:00
|
|
|
qhelpers::setCheckedWithoutSignals(ui->varsumCheckBox, Config()->getConfigBool("asm.var.summary"));
|
2018-03-22 08:42:54 +00:00
|
|
|
qhelpers::setCheckedWithoutSignals(ui->sizeCheckBox, Config()->getConfigBool("asm.size"));
|
|
|
|
|
2018-07-17 07:25:17 +00:00
|
|
|
bool cmtRightEnabled = Config()->getConfigBool("asm.cmt.right");
|
|
|
|
qhelpers::setCheckedWithoutSignals(ui->cmtrightCheckBox, cmtRightEnabled);
|
|
|
|
ui->cmtcolSpinBox->blockSignals(true);
|
|
|
|
ui->cmtcolSpinBox->setValue(Config()->getConfigInt("asm.cmt.col"));
|
|
|
|
ui->cmtcolSpinBox->blockSignals(false);
|
|
|
|
ui->cmtcolSpinBox->setEnabled(cmtRightEnabled);
|
|
|
|
|
2018-03-22 08:42:54 +00:00
|
|
|
bool bytesEnabled = Config()->getConfigBool("asm.bytes");
|
2017-12-14 13:42:24 +00:00
|
|
|
qhelpers::setCheckedWithoutSignals(ui->bytesCheckBox, bytesEnabled);
|
2018-03-22 08:42:54 +00:00
|
|
|
qhelpers::setCheckedWithoutSignals(ui->bytespaceCheckBox, Config()->getConfigBool("asm.bytespace"));
|
2017-12-14 13:42:24 +00:00
|
|
|
ui->bytespaceCheckBox->setEnabled(bytesEnabled);
|
2018-03-22 08:42:54 +00:00
|
|
|
qhelpers::setCheckedWithoutSignals(ui->lbytesCheckBox, Config()->getConfigBool("asm.lbytes"));
|
2017-12-14 13:42:24 +00:00
|
|
|
ui->lbytesCheckBox->setEnabled(bytesEnabled);
|
2018-02-01 09:01:09 +00:00
|
|
|
ui->nbytesSpinBox->blockSignals(true);
|
2018-03-22 08:42:54 +00:00
|
|
|
ui->nbytesSpinBox->setValue(Config()->getConfigInt("asm.nbytes"));
|
2018-02-01 09:01:09 +00:00
|
|
|
ui->nbytesSpinBox->blockSignals(false);
|
|
|
|
ui->nbytesLabel->setEnabled(bytesEnabled);
|
|
|
|
ui->nbytesSpinBox->setEnabled(bytesEnabled);
|
|
|
|
|
2017-12-14 13:42:24 +00:00
|
|
|
|
2018-03-22 08:42:54 +00:00
|
|
|
QString currentSyntax = Config()->getConfigString("asm.syntax");
|
2018-03-21 20:32:32 +00:00
|
|
|
for (int i = 0; i < ui->syntaxComboBox->count(); i++) {
|
|
|
|
if (ui->syntaxComboBox->itemData(i) == currentSyntax) {
|
2017-12-14 13:42:24 +00:00
|
|
|
ui->syntaxComboBox->blockSignals(true);
|
|
|
|
ui->syntaxComboBox->setCurrentIndex(i);
|
|
|
|
ui->syntaxComboBox->blockSignals(false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->caseComboBox->blockSignals(true);
|
2018-03-22 08:42:54 +00:00
|
|
|
if (Config()->getConfigBool("asm.ucase")) {
|
2017-12-14 13:42:24 +00:00
|
|
|
ui->caseComboBox->setCurrentIndex(1);
|
2018-03-22 08:42:54 +00:00
|
|
|
} else if (Config()->getConfigBool("asm.capitalize")) {
|
2017-12-14 13:42:24 +00:00
|
|
|
ui->caseComboBox->setCurrentIndex(2);
|
2018-03-21 20:32:32 +00:00
|
|
|
} else {
|
2017-12-14 13:42:24 +00:00
|
|
|
ui->caseComboBox->setCurrentIndex(0);
|
|
|
|
}
|
|
|
|
ui->caseComboBox->blockSignals(false);
|
|
|
|
|
2018-01-31 08:01:16 +00:00
|
|
|
ui->asmTabsSpinBox->blockSignals(true);
|
2018-03-22 08:42:54 +00:00
|
|
|
ui->asmTabsSpinBox->setValue(Config()->getConfigInt("asm.tabs"));
|
2018-01-31 08:01:16 +00:00
|
|
|
ui->asmTabsSpinBox->blockSignals(false);
|
|
|
|
|
2018-07-17 07:25:17 +00:00
|
|
|
ui->asmTabsOffSpinBox->blockSignals(true);
|
|
|
|
ui->asmTabsOffSpinBox->setValue(Config()->getConfigInt("asm.tabs.off"));
|
|
|
|
ui->asmTabsOffSpinBox->blockSignals(false);
|
|
|
|
|
2018-03-22 08:42:54 +00:00
|
|
|
qhelpers::setCheckedWithoutSignals(ui->bblineCheckBox, Config()->getConfigBool("asm.bbline"));
|
2017-12-14 13:42:24 +00:00
|
|
|
|
2018-03-22 08:42:54 +00:00
|
|
|
bool varsubEnabled = Config()->getConfigBool("asm.varsub");
|
2017-12-14 13:42:24 +00:00
|
|
|
qhelpers::setCheckedWithoutSignals(ui->varsubCheckBox, varsubEnabled);
|
2018-03-22 08:42:54 +00:00
|
|
|
qhelpers::setCheckedWithoutSignals(ui->varsubOnlyCheckBox, Config()->getConfigBool("asm.varsub_only"));
|
2017-12-14 13:42:24 +00:00
|
|
|
ui->varsubOnlyCheckBox->setEnabled(varsubEnabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AsmOptionsWidget::resetToDefault()
|
|
|
|
{
|
2018-03-22 08:42:54 +00:00
|
|
|
Config()->resetToDefaultAsmOptions();
|
2017-12-14 13:42:24 +00:00
|
|
|
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)
|
|
|
|
{
|
2018-03-22 08:42:54 +00:00
|
|
|
Config()->setConfig("asm.esil", checked);
|
2017-12-14 13:42:24 +00:00
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AsmOptionsWidget::on_pseudoCheckBox_toggled(bool checked)
|
|
|
|
{
|
2018-03-22 08:42:54 +00:00
|
|
|
Config()->setConfig("asm.pseudo", checked);
|
2017-12-14 13:42:24 +00:00
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AsmOptionsWidget::on_offsetCheckBox_toggled(bool checked)
|
|
|
|
{
|
2018-03-22 08:42:54 +00:00
|
|
|
Config()->setConfig("asm.offset", checked);
|
2017-12-14 13:42:24 +00:00
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AsmOptionsWidget::on_describeCheckBox_toggled(bool checked)
|
|
|
|
{
|
2018-03-22 08:42:54 +00:00
|
|
|
Config()->setConfig("asm.describe", checked);
|
2017-12-14 13:42:24 +00:00
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AsmOptionsWidget::on_stackpointerCheckBox_toggled(bool checked)
|
|
|
|
{
|
2018-03-22 08:42:54 +00:00
|
|
|
Config()->setConfig("asm.stackptr", checked);
|
2017-12-14 13:42:24 +00:00
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
2018-01-31 08:01:16 +00:00
|
|
|
void AsmOptionsWidget::on_slowCheckBox_toggled(bool checked)
|
|
|
|
{
|
2018-03-22 08:42:54 +00:00
|
|
|
Config()->setConfig("asm.slow", checked);
|
2018-01-31 08:01:16 +00:00
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
2018-01-28 22:28:25 +00:00
|
|
|
void AsmOptionsWidget::on_linesCheckBox_toggled(bool checked)
|
|
|
|
{
|
2018-03-22 08:42:54 +00:00
|
|
|
Config()->setConfig("asm.lines", checked);
|
2018-01-28 22:28:25 +00:00
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
2018-02-04 19:34:52 +00:00
|
|
|
void AsmOptionsWidget::on_fcnlinesCheckBox_toggled(bool checked)
|
|
|
|
{
|
2018-05-24 06:21:12 +00:00
|
|
|
Config()->setConfig("asm.lines.fcn", checked);
|
2018-03-22 08:42:54 +00:00
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AsmOptionsWidget::on_flgoffCheckBox_toggled(bool checked)
|
|
|
|
{
|
2018-05-24 06:21:12 +00:00
|
|
|
Config()->setConfig("asm.flags.off", checked);
|
2018-02-04 19:34:52 +00:00
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
2018-01-31 08:01:16 +00:00
|
|
|
void AsmOptionsWidget::on_emuCheckBox_toggled(bool checked)
|
|
|
|
{
|
2018-03-22 08:42:54 +00:00
|
|
|
Config()->setConfig("asm.emu", checked);
|
2018-01-31 08:01:16 +00:00
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AsmOptionsWidget::on_cmtrightCheckBox_toggled(bool checked)
|
|
|
|
{
|
2018-03-22 08:42:54 +00:00
|
|
|
Config()->setConfig("asm.cmt.right", checked);
|
2018-07-17 07:25:17 +00:00
|
|
|
ui->cmtcolSpinBox->setEnabled(checked);
|
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AsmOptionsWidget::on_cmtcolSpinBox_valueChanged(int value)
|
|
|
|
{
|
|
|
|
Config()->setConfig("asm.cmt.col", value);
|
2018-01-31 08:01:16 +00:00
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AsmOptionsWidget::on_varsumCheckBox_toggled(bool checked)
|
|
|
|
{
|
2018-05-24 06:21:12 +00:00
|
|
|
Config()->setConfig("asm.var.summary", checked);
|
2018-01-31 08:01:16 +00:00
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
2017-12-14 13:42:24 +00:00
|
|
|
void AsmOptionsWidget::on_bytesCheckBox_toggled(bool checked)
|
|
|
|
{
|
2018-03-22 08:42:54 +00:00
|
|
|
Config()->setConfig("asm.bytes", checked);
|
2017-12-14 13:42:24 +00:00
|
|
|
ui->bytespaceCheckBox->setEnabled(checked);
|
|
|
|
ui->lbytesCheckBox->setEnabled(checked);
|
2018-02-01 09:01:09 +00:00
|
|
|
ui->nbytesLabel->setEnabled(checked);
|
|
|
|
ui->nbytesSpinBox->setEnabled(checked);
|
2017-12-14 13:42:24 +00:00
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
2018-03-10 06:26:58 +00:00
|
|
|
void AsmOptionsWidget::on_sizeCheckBox_toggled(bool checked)
|
|
|
|
{
|
2018-03-22 08:42:54 +00:00
|
|
|
Config()->setConfig("asm.size", checked);
|
2018-03-10 06:26:58 +00:00
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
2017-12-14 13:42:24 +00:00
|
|
|
void AsmOptionsWidget::on_bytespaceCheckBox_toggled(bool checked)
|
|
|
|
{
|
2018-03-22 08:42:54 +00:00
|
|
|
Config()->setConfig("asm.bytespace", checked);
|
2017-12-14 13:42:24 +00:00
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AsmOptionsWidget::on_lbytesCheckBox_toggled(bool checked)
|
|
|
|
{
|
2018-03-22 08:42:54 +00:00
|
|
|
Config()->setConfig("asm.lbytes", checked);
|
2017-12-14 13:42:24 +00:00
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
2018-02-01 09:01:09 +00:00
|
|
|
void AsmOptionsWidget::on_nbytesSpinBox_valueChanged(int value)
|
|
|
|
{
|
2018-03-22 08:42:54 +00:00
|
|
|
Config()->setConfig("asm.nbytes", value);
|
2018-02-01 09:01:09 +00:00
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
2017-12-14 13:42:24 +00:00
|
|
|
void AsmOptionsWidget::on_syntaxComboBox_currentIndexChanged(int index)
|
|
|
|
{
|
2018-03-22 08:42:54 +00:00
|
|
|
Config()->setConfig("asm.syntax",
|
2018-03-21 20:32:32 +00:00
|
|
|
ui->syntaxComboBox->itemData(index).toString().toUtf8().constData());
|
2017-12-14 13:42:24 +00:00
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AsmOptionsWidget::on_caseComboBox_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
bool ucase;
|
|
|
|
bool capitalize;
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
switch (index) {
|
2017-12-14 13:42:24 +00:00
|
|
|
// lowercase
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
ucase = false;
|
|
|
|
capitalize = false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
// uppercase
|
|
|
|
case 1:
|
|
|
|
ucase = true;
|
|
|
|
capitalize = false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
ucase = false;
|
|
|
|
capitalize = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-03-22 08:42:54 +00:00
|
|
|
Config()->setConfig("asm.ucase", ucase);
|
|
|
|
Config()->setConfig("asm.capitalize", capitalize);
|
2017-12-14 13:42:24 +00:00
|
|
|
|
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
2018-01-31 08:01:16 +00:00
|
|
|
void AsmOptionsWidget::on_asmTabsSpinBox_valueChanged(int value)
|
|
|
|
{
|
2018-03-22 08:42:54 +00:00
|
|
|
Config()->setConfig("asm.tabs", value);
|
2018-01-31 08:01:16 +00:00
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
2018-07-17 07:25:17 +00:00
|
|
|
void AsmOptionsWidget::on_asmTabsOffSpinBox_valueChanged(int value)
|
|
|
|
{
|
|
|
|
Config()->setConfig("asm.tabs.off", value);
|
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
2017-12-14 13:42:24 +00:00
|
|
|
void AsmOptionsWidget::on_bblineCheckBox_toggled(bool checked)
|
|
|
|
{
|
2018-03-22 08:42:54 +00:00
|
|
|
Config()->setConfig("asm.bbline", checked);
|
2017-12-14 13:42:24 +00:00
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AsmOptionsWidget::on_varsubCheckBox_toggled(bool checked)
|
|
|
|
{
|
2018-05-24 06:21:12 +00:00
|
|
|
Config()->setConfig("asm.var.sub", checked);
|
2017-12-14 13:42:24 +00:00
|
|
|
ui->varsubOnlyCheckBox->setEnabled(checked);
|
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AsmOptionsWidget::on_varsubOnlyCheckBox_toggled(bool checked)
|
|
|
|
{
|
2018-05-24 06:21:12 +00:00
|
|
|
Config()->setConfig("asm.var.subonly", checked);
|
2017-12-14 13:42:24 +00:00
|
|
|
triggerAsmOptionsChanged();
|
|
|
|
}
|
|
|
|
|
2017-12-14 15:14:33 +00:00
|
|
|
|
|
|
|
void AsmOptionsWidget::on_buttonBox_clicked(QAbstractButton *button)
|
2017-12-14 13:42:24 +00:00
|
|
|
{
|
2018-03-21 20:32:32 +00:00
|
|
|
switch (ui->buttonBox->buttonRole(button)) {
|
|
|
|
case QDialogButtonBox::ButtonRole::ResetRole:
|
|
|
|
resetToDefault();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2017-12-14 13:42:24 +00:00
|
|
|
}
|
2018-01-28 22:28:25 +00:00
|
|
|
}
|