Fix opening correct panel in the preferences dialog via the contextmenu (#583)

This commit is contained in:
fcasal 2018-07-18 08:27:29 +01:00 committed by xarkes
parent db682f6ef9
commit 662837e38e

View File

@ -20,8 +20,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent)
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this); ui->setupUi(this);
QList<PreferenceCategory> prefs QList<PreferenceCategory> prefs {
{
{ {
"General", "General",
new GeneralOptionsWidget(this), new GeneralOptionsWidget(this),
@ -45,8 +44,8 @@ PreferencesDialog::PreferencesDialog(QWidget *parent)
c.addItem(*ui->configCategories, *ui->configPanel); c.addItem(*ui->configCategories, *ui->configPanel);
connect(ui->configCategories, connect(ui->configCategories,
SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
this, SLOT(changePage(QTreeWidgetItem*, QTreeWidgetItem*))); this, SLOT(changePage(QTreeWidgetItem *, QTreeWidgetItem *)));
connect(ui->saveButtons, connect(ui->saveButtons,
SIGNAL(accepted()), SIGNAL(accepted()),
this, SLOT(close())); this, SLOT(close()));
@ -61,12 +60,17 @@ PreferencesDialog::~PreferencesDialog()
void PreferencesDialog::showSection(PreferencesDialog::Section section) void PreferencesDialog::showSection(PreferencesDialog::Section section)
{ {
QTreeWidgetItem *defitem;
switch (section) { switch (section) {
case Section::General: case Section::General:
ui->configPanel->setCurrentIndex(0); ui->configPanel->setCurrentIndex(0);
defitem = ui->configCategories->topLevelItem(0);
ui->configCategories->setCurrentItem(defitem, 0);
break; break;
case Section::Disassembly: case Section::Disassembly:
ui->configPanel->setCurrentIndex(1); ui->configPanel->setCurrentIndex(1);
defitem = ui->configCategories->topLevelItem(1);
ui->configCategories->setCurrentItem(defitem, 1);
break; break;
} }
} }
@ -79,5 +83,5 @@ void PreferencesDialog::changePage(QTreeWidgetItem *current, QTreeWidgetItem *pr
int index = current->data(0, Qt::UserRole).toInt(); int index = current->data(0, Qt::UserRole).toInt();
if (index) if (index)
ui->configPanel->setCurrentIndex(index-1); ui->configPanel->setCurrentIndex(index - 1);
} }