diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index aa31a97819..80e285d420 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -2818,6 +2818,42 @@ void CmdViewMeasureToggleAll::activated(int iMsg) group->SetBool("DimensionsVisible", true); } +//=========================================================================== +// Std_TreeHideInactiveDocs +//=========================================================================== + +DEF_STD_CMD_C(StdTreeHideInactiveDocs); + +StdTreeHideInactiveDocs::StdTreeHideInactiveDocs() + : Command("Std_TreeHideInactiveDocs") +{ + sGroup = QT_TR_NOOP("View"); + sMenuText = QT_TR_NOOP("Hide inactive documents in tree"); + sToolTipText = QT_TR_NOOP("Toggles hiding inactive documents in document tree"); + sWhatsThis = "Std_TreeHideInactiveDocs"; + sStatusTip = QT_TR_NOOP("Toggles hiding inactive documents in document tree"); + eType = 0; +} + +Action * StdTreeHideInactiveDocs::createAction(void) +{ + Action *pcAction = Command::createAction(); + pcAction->setCheckable(true); + ParameterGrp::handle group = App::GetApplication().GetUserParameter(). + GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("View"); + pcAction->setChecked(group->GetBool("TreeHideInactiveDocs", false)); + + return pcAction; +} + +void StdTreeHideInactiveDocs::activated(int iMsg) +{ + ParameterGrp::handle group = App::GetApplication().GetUserParameter(). + GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("View"); + group->SetBool("TreeHideInactiveDocs", iMsg != 0); + App::GetApplication().setActiveDocument(App::GetApplication().getActiveDocument()); +} + //=========================================================================== // Instantiation //=========================================================================== @@ -2886,6 +2922,7 @@ void CreateViewStdCommands(void) rcCmdMgr.addCommand(new StdCmdAxisCross()); rcCmdMgr.addCommand(new CmdViewMeasureClearAll()); rcCmdMgr.addCommand(new CmdViewMeasureToggleAll()); + rcCmdMgr.addCommand(new StdTreeHideInactiveDocs()); } } // namespace Gui diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 7b90ee4208..978278dfb3 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -706,12 +706,15 @@ void TreeWidget::slotActiveDocument(const Gui::Document& Doc) std::map::iterator jt = DocumentMap.find(&Doc); if (jt == DocumentMap.end()) return; // signal is emitted before the item gets created + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View"); + bool hideInactive = hGrp->GetBool("TreeHideInactiveDocs", false); for (std::map::iterator it = DocumentMap.begin(); it != DocumentMap.end(); ++it) { QFont f = it->second->font(0); f.setBold(it == jt); it->second->setFont(0,f); + it->second->setHidden(hideInactive && it != jt); } } diff --git a/src/Gui/Workbench.cpp b/src/Gui/Workbench.cpp index 587457e36d..e68c7ee32b 100644 --- a/src/Gui/Workbench.cpp +++ b/src/Gui/Workbench.cpp @@ -550,6 +550,7 @@ MenuItem* StdWorkbench::setupMenuBar() const << "Std_ToggleVisibility" << "Std_ToggleNavigation" << "Std_SetAppearance" << "Std_RandomColor" << "Separator" << "Std_Workbench" << "Std_ToolBarMenu" << "Std_DockViewMenu" << "Separator" + << "Std_TreeHideInactiveDocs" << "Std_ViewStatusBar"; // Tools