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