2017-12-14 13:42:24 +00:00
|
|
|
#include <QDialogButtonBox>
|
|
|
|
|
|
|
|
#include "PreferencesDialog.h"
|
|
|
|
#include "ui_PreferencesDialog.h"
|
|
|
|
|
2018-10-17 07:30:56 +00:00
|
|
|
#include "AppearanceOptionsWidget.h"
|
2017-12-14 13:42:24 +00:00
|
|
|
#include "AsmOptionsWidget.h"
|
2017-12-19 16:13:44 +00:00
|
|
|
#include "GraphOptionsWidget.h"
|
2018-06-14 11:49:22 +00:00
|
|
|
#include "DebugOptionsWidget.h"
|
2017-12-14 13:42:24 +00:00
|
|
|
|
2018-05-13 07:52:49 +00:00
|
|
|
#include "PreferenceCategory.h"
|
|
|
|
|
2018-10-17 07:55:53 +00:00
|
|
|
#include "common/Helpers.h"
|
|
|
|
#include "common/Configuration.h"
|
2017-12-14 13:42:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
PreferencesDialog::PreferencesDialog(QWidget *parent)
|
2018-03-21 20:32:32 +00:00
|
|
|
: QDialog(parent),
|
|
|
|
ui(new Ui::PreferencesDialog)
|
2017-12-14 13:42:24 +00:00
|
|
|
{
|
2018-02-27 13:08:39 +00:00
|
|
|
setAttribute(Qt::WA_DeleteOnClose);
|
2017-12-14 13:42:24 +00:00
|
|
|
ui->setupUi(this);
|
|
|
|
|
2018-07-18 07:27:29 +00:00
|
|
|
QList<PreferenceCategory> prefs {
|
2018-10-17 07:30:56 +00:00
|
|
|
|
2018-05-13 07:52:49 +00:00
|
|
|
{
|
|
|
|
"Assembly",
|
|
|
|
new AsmOptionsWidget(this),
|
2018-06-14 11:49:22 +00:00
|
|
|
QIcon(":/img/icons/disas_light.svg"),
|
2018-05-13 07:52:49 +00:00
|
|
|
{
|
|
|
|
{
|
|
|
|
"Graph",
|
|
|
|
new GraphOptionsWidget(this),
|
2018-06-14 11:49:22 +00:00
|
|
|
QIcon(":/img/icons/graph_light.svg")
|
2018-05-13 07:52:49 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
2018-06-14 11:49:22 +00:00
|
|
|
{
|
|
|
|
"Debug",
|
|
|
|
new DebugOptionsWidget(this),
|
|
|
|
QIcon(":/img/icons/bug_light.svg")
|
2018-10-17 07:30:56 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"Appearance",
|
|
|
|
new AppearanceOptionsWidget(this),
|
|
|
|
QIcon(":/img/icons/polar_light.svg")
|
2018-06-14 11:49:22 +00:00
|
|
|
}
|
2018-05-13 07:52:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
for (auto &c : prefs)
|
|
|
|
c.addItem(*ui->configCategories, *ui->configPanel);
|
|
|
|
|
|
|
|
connect(ui->configCategories,
|
2018-07-18 07:27:29 +00:00
|
|
|
SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
|
|
|
|
this, SLOT(changePage(QTreeWidgetItem *, QTreeWidgetItem *)));
|
2018-05-13 07:52:49 +00:00
|
|
|
connect(ui->saveButtons,
|
|
|
|
SIGNAL(accepted()),
|
|
|
|
this, SLOT(close()));
|
|
|
|
|
|
|
|
QTreeWidgetItem *defitem = ui->configCategories->topLevelItem(0);
|
|
|
|
ui->configCategories->setCurrentItem(defitem, 0);
|
2017-12-14 13:42:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PreferencesDialog::~PreferencesDialog()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreferencesDialog::showSection(PreferencesDialog::Section section)
|
|
|
|
{
|
2018-07-18 07:27:29 +00:00
|
|
|
QTreeWidgetItem *defitem;
|
2018-03-21 20:32:32 +00:00
|
|
|
switch (section) {
|
2018-10-17 07:30:56 +00:00
|
|
|
case Section::Appearance:
|
2018-05-13 07:52:49 +00:00
|
|
|
ui->configPanel->setCurrentIndex(0);
|
2018-07-18 07:27:29 +00:00
|
|
|
defitem = ui->configCategories->topLevelItem(0);
|
|
|
|
ui->configCategories->setCurrentItem(defitem, 0);
|
2018-03-21 20:32:32 +00:00
|
|
|
break;
|
|
|
|
case Section::Disassembly:
|
2018-05-13 07:52:49 +00:00
|
|
|
ui->configPanel->setCurrentIndex(1);
|
2018-07-18 07:27:29 +00:00
|
|
|
defitem = ui->configCategories->topLevelItem(1);
|
|
|
|
ui->configCategories->setCurrentItem(defitem, 1);
|
2018-03-21 20:32:32 +00:00
|
|
|
break;
|
2017-12-14 13:42:24 +00:00
|
|
|
}
|
|
|
|
}
|
2018-05-13 07:52:49 +00:00
|
|
|
|
|
|
|
void PreferencesDialog::changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
|
|
|
{
|
|
|
|
if (!current)
|
|
|
|
current = previous;
|
|
|
|
|
|
|
|
int index = current->data(0, Qt::UserRole).toInt();
|
|
|
|
|
|
|
|
if (index)
|
2018-07-18 07:27:29 +00:00
|
|
|
ui->configPanel->setCurrentIndex(index - 1);
|
2018-05-13 07:52:49 +00:00
|
|
|
}
|