From f068e723eaf9ab9588a0196efbd25c0dbdd636c9 Mon Sep 17 00:00:00 2001 From: Ian Rees Date: Sat, 11 Apr 2015 12:45:58 +1200 Subject: [PATCH] Remember last tab selected in PropertyView --- src/Gui/PropertyView.cpp | 23 +++++++++++++++++++++++ src/Gui/PropertyView.h | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/src/Gui/PropertyView.cpp b/src/Gui/PropertyView.cpp index 461d68edc4ab..776da73f253e 100644 --- a/src/Gui/PropertyView.cpp +++ b/src/Gui/PropertyView.cpp @@ -29,6 +29,7 @@ #endif /// Here the FreeCAD includes sorted by Base,App,Gui...... +#include #include #include #include @@ -73,9 +74,22 @@ PropertyView::PropertyView(QWidget *parent) propertyEditorView = new Gui::PropertyEditor::PropertyEditor(); propertyEditorView->setAutomaticDocumentUpdate(false); tabs->addTab(propertyEditorView, tr("View")); + propertyEditorData = new Gui::PropertyEditor::PropertyEditor(); propertyEditorData->setAutomaticDocumentUpdate(true); tabs->addTab(propertyEditorData, tr("Data")); + + ParameterGrp::handle hGrp = App::GetApplication().GetUserParameter(). + GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("PropertyView"); + if ( hGrp ) { + int preferredTab = hGrp->GetInt("LastTabIndex", 1); + + if ( preferredTab > 0 && preferredTab < tabs->count() ) + tabs->setCurrentIndex(preferredTab); + } + + // connect after adding all tabs, so adding doesn't thrash the parameter + connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int))); } PropertyView::~PropertyView() @@ -192,6 +206,15 @@ void PropertyView::onSelectionChanged(const SelectionChanges& msg) propertyEditorView->buildUp(viewProps); } +void PropertyView::tabChanged(int index) +{ + ParameterGrp::handle hGrp = App::GetApplication().GetUserParameter(). + GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("PropertyView"); + if (hGrp) { + hGrp->SetInt("LastTabIndex", index); + } +} + void PropertyView::changeEvent(QEvent *e) { if (e->type() == QEvent::LanguageChange) { diff --git a/src/Gui/PropertyView.h b/src/Gui/PropertyView.h index 532ef0fc9d2c..a1b59c105d51 100644 --- a/src/Gui/PropertyView.h +++ b/src/Gui/PropertyView.h @@ -62,6 +62,10 @@ class PropertyView : public QWidget, public Gui::SelectionObserver Gui::PropertyEditor::PropertyEditor* propertyEditorView; Gui::PropertyEditor::PropertyEditor* propertyEditorData; +public Q_SLOTS: + /// Stores a preference for the last tab selected + void tabChanged(int index); + protected: void changeEvent(QEvent *e);