Skip to content

Commit

Permalink
Remember last tab selected in PropertyView
Browse files Browse the repository at this point in the history
  • Loading branch information
ianrrees committed Apr 14, 2015
1 parent 38ca534 commit f068e72
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Gui/PropertyView.cpp
Expand Up @@ -29,6 +29,7 @@
#endif

/// Here the FreeCAD includes sorted by Base,App,Gui......
#include <Base/Parameter.h>
#include <App/PropertyStandard.h>
#include <App/PropertyGeo.h>
#include <App/PropertyLinks.h>
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions src/Gui/PropertyView.h
Expand Up @@ -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);

Expand Down

0 comments on commit f068e72

Please sign in to comment.