diff --git a/NEWS.md b/NEWS.md index 7d254a95..b08f0d69 100644 --- a/NEWS.md +++ b/NEWS.md @@ -29,6 +29,7 @@ Red Panda C++ Version 2.24 - fix: Crash if close file while auto syntax checking. - enhancement: Support sdcc compiler. - enhancement: Autowrap tool output text. + - fix: Press up/down arrow key in the option dialog's left panel won't switch page. Red Panda C++ Version 2.23 diff --git a/RedPandaIDE/settingsdialog/settingsdialog.cpp b/RedPandaIDE/settingsdialog/settingsdialog.cpp index 7bac0908..00fa4e9b 100644 --- a/RedPandaIDE/settingsdialog/settingsdialog.cpp +++ b/RedPandaIDE/settingsdialog/settingsdialog.cpp @@ -78,6 +78,9 @@ SettingsDialog::SettingsDialog(QWidget *parent) : ui->widgetsView->setModel(&model); delete m; + connect(ui->widgetsView->selectionModel(), &QItemSelectionModel::currentChanged, + this, &SettingsDialog::onWidgetsViewCurrentChanged); + model.setHorizontalHeaderLabels(QStringList()); ui->btnApply->setEnabled(false); @@ -308,25 +311,7 @@ bool SettingsDialog::setCurrentWidget(const QString &widgetName, const QString & void SettingsDialog::on_widgetsView_clicked(const QModelIndex &index) { - if (!index.isValid()) - return; - int i = index.data(GetWidgetIndexRole).toInt(); - if (i>=0) { - saveCurrentPageSettings(true); - SettingsWidget* pWidget = mSettingWidgets[i]; - if (ui->scrollArea->widget()!=nullptr) { - QWidget* w = ui->scrollArea->takeWidget(); - w->setParent(nullptr); - } - ui->scrollArea->setWidget(pWidget); - ui->lblWidgetCaption->setText(QString("%1 > %2").arg(pWidget->group()).arg(pWidget->name())); - - ui->btnApply->setEnabled(false); - } else if (model.hasChildren(index)) { - ui->widgetsView->expand(index); - QModelIndex childIndex = this->model.index(0,0,index); - emit ui->widgetsView->clicked(childIndex); - } + showWidget(index); } void SettingsDialog::widget_settings_changed(bool value) @@ -334,6 +319,11 @@ void SettingsDialog::widget_settings_changed(bool value) ui->btnApply->setEnabled(value); } +void SettingsDialog::onWidgetsViewCurrentChanged(const QModelIndex &index, const QModelIndex &/*previous*/) +{ + showWidget(index); +} + void SettingsDialog::on_btnCancel_pressed() { this->close(); @@ -388,3 +378,26 @@ void SettingsDialog::closeAndQuit() mAppShouldQuit = true; close(); } + +void SettingsDialog::showWidget(const QModelIndex &index) +{ + if (!index.isValid()) + return; + int i = index.data(GetWidgetIndexRole).toInt(); + if (i>=0) { + saveCurrentPageSettings(true); + SettingsWidget* pWidget = mSettingWidgets[i]; + if (ui->scrollArea->widget()!=nullptr) { + QWidget* w = ui->scrollArea->takeWidget(); + w->setParent(nullptr); + } + ui->scrollArea->setWidget(pWidget); + ui->lblWidgetCaption->setText(QString("%1 > %2").arg(pWidget->group()).arg(pWidget->name())); + + ui->btnApply->setEnabled(false); + } else if (model.hasChildren(index)) { + ui->widgetsView->expand(index); + QModelIndex childIndex = this->model.index(0,0,index); + emit ui->widgetsView->clicked(childIndex); + } +} diff --git a/RedPandaIDE/settingsdialog/settingsdialog.h b/RedPandaIDE/settingsdialog/settingsdialog.h index df591fe1..735350e5 100644 --- a/RedPandaIDE/settingsdialog/settingsdialog.h +++ b/RedPandaIDE/settingsdialog/settingsdialog.h @@ -53,7 +53,11 @@ public: private slots: void closeAndQuit(); + void showWidget(const QModelIndex &index); + void widget_settings_changed(bool value); + + void onWidgetsViewCurrentChanged(const QModelIndex &index, const QModelIndex &previous); void on_widgetsView_clicked(const QModelIndex &index); void on_btnCancel_pressed();