diff --git a/src/Gui/DockWindowManager.cpp b/src/Gui/DockWindowManager.cpp index 2e35a9c85c..45289b00be 100644 --- a/src/Gui/DockWindowManager.cpp +++ b/src/Gui/DockWindowManager.cpp @@ -381,6 +381,21 @@ void DockWindowManager::saveState() } } +void DockWindowManager::loadState() +{ + ParameterGrp::handle hPref = App::GetApplication().GetUserParameter().GetGroup("BaseApp") + ->GetGroup("MainWindow")->GetGroup("DockWindows"); + const QList& dockItems = d->_dockWindowItems.dockWidgets(); + for (QList::ConstIterator it = dockItems.begin(); it != dockItems.end(); ++it) { + QDockWidget* dw = findDockWidget(d->_dockedWindows, it->name); + if (dw) { + QByteArray dockName = it->name.toLatin1(); + bool visible = hPref->GetBool(dockName.constData(), it->visibility); + dw->setVisible(visible); + } + } +} + QDockWidget* DockWindowManager::findDockWidget(const QList& dw, const QString& name) const { for (QList::ConstIterator it = dw.begin(); it != dw.end(); ++it) { diff --git a/src/Gui/DockWindowManager.h b/src/Gui/DockWindowManager.h index a38d89a2b1..5e5825b83a 100644 --- a/src/Gui/DockWindowManager.h +++ b/src/Gui/DockWindowManager.h @@ -88,6 +88,7 @@ public: QList getDockWindows() const; void saveState(); + void loadState(); void retranslate(); private Q_SLOTS: diff --git a/src/Gui/PreferencePackManager.cpp b/src/Gui/PreferencePackManager.cpp index f692abad81..9bdecfee26 100644 --- a/src/Gui/PreferencePackManager.cpp +++ b/src/Gui/PreferencePackManager.cpp @@ -37,6 +37,7 @@ #include "Base/Parameter.h" #include "Base/Interpreter.h" #include "Base/Console.h" +#include "DockWindowManager.h" #include @@ -204,7 +205,14 @@ bool PreferencePackManager::apply(const std::string& preferencePackName) const std::lock_guard lock(_mutex); if (auto preferencePack = _preferencePacks.find(preferencePackName); preferencePack != _preferencePacks.end()) { BackupCurrentConfig(); - return preferencePack->second.apply(); + bool wasApplied = preferencePack->second.apply(); + if (wasApplied) { + // If the visibility state of the dock windows was changed we have to manually reload their state + Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance(); + pDockMgr->loadState(); + + // TODO: Are there other things that have to be manually triggered? + } } else { throw std::runtime_error("No such Preference Pack: " + preferencePackName); @@ -215,9 +223,14 @@ void copyTemplateParameters(Base::Reference templateGroup, const s { auto userParameterHandle = App::GetApplication().GetParameterGroupByPath(path.c_str()); + // Ensure that the DockWindowManager has saved its current state: + Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance(); + pDockMgr->saveState(); + auto boolMap = templateGroup->GetBoolMap(); for (const auto& kv : boolMap) { auto currentValue = userParameterHandle->GetBool(kv.first.c_str(), kv.second); + Base::Console().Message("Parameter %s = %d\n", kv.first.c_str(), currentValue); outputGroup->SetBool(kv.first.c_str(), currentValue); }