Gui: by default restore the last visited page in the preferences dialog
See also: https://forum.freecad.org/viewtopic.php?t=77071
This commit is contained in:
@@ -370,8 +370,19 @@ Action * StdCmdDlgPreferences::createAction()
|
||||
void StdCmdDlgPreferences::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
|
||||
static QString groupName{};
|
||||
static int index{};
|
||||
|
||||
Gui::Dialog::DlgPreferencesImp cDlg(getMainWindow());
|
||||
cDlg.exec();
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences");
|
||||
if (hGrp->GetBool("RestoreGroupPage", true)) {
|
||||
cDlg.activateGroupPage(groupName, index);
|
||||
}
|
||||
|
||||
if (cDlg.exec()) {
|
||||
cDlg.activeGroupPage(groupName, index);
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
@@ -305,13 +305,30 @@ void DlgPreferencesImp::activateGroupPage(const QString& group, int index)
|
||||
QListWidgetItem* item = ui->listBox->item(i);
|
||||
if (item->data(GroupNameRole).toString() == group) {
|
||||
ui->listBox->setCurrentItem(item);
|
||||
auto tabWidget = static_cast<QTabWidget*>(ui->tabWidgetStack->widget(i));
|
||||
tabWidget->setCurrentIndex(index);
|
||||
break;
|
||||
auto tabWidget = dynamic_cast<QTabWidget*>(ui->tabWidgetStack->widget(i));
|
||||
if (tabWidget) {
|
||||
tabWidget->setCurrentIndex(index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the group name \a group and position \a index of the active page.
|
||||
*/
|
||||
void DlgPreferencesImp::activeGroupPage(QString& group, int& index) const
|
||||
{
|
||||
int row = ui->listBox->currentRow();
|
||||
auto item = ui->listBox->item(row);
|
||||
auto tabWidget = dynamic_cast<QTabWidget*>(ui->tabWidgetStack->widget(row));
|
||||
|
||||
if (item && tabWidget) {
|
||||
group = item->data(GroupNameRole).toString();
|
||||
index = tabWidget->currentIndex();
|
||||
}
|
||||
}
|
||||
|
||||
void DlgPreferencesImp::accept()
|
||||
{
|
||||
this->invalidParameter = false;
|
||||
|
||||
@@ -123,7 +123,8 @@ public:
|
||||
|
||||
void accept() override;
|
||||
void reload();
|
||||
void activateGroupPage(const QString& group, int id);
|
||||
void activateGroupPage(const QString& group, int index);
|
||||
void activeGroupPage(QString& group, int& index) const;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
|
||||
Reference in New Issue
Block a user