Add loadState() function to DockWindowManager

Just changing the preference for hiding or showing a dock window does
not actually trigger a state change. To enable that, the preferences
pack manager must manually instruct the DockWindowManager to save its
state into the preferences before storing a preference pack, and must
instruct the DockWindowManager to load its new state from the
preferences after loading a pack.
This commit is contained in:
Chris Hennes
2021-08-23 11:30:13 -05:00
parent 76d666779d
commit b49da2467c
3 changed files with 30 additions and 1 deletions

View File

@@ -381,6 +381,21 @@ void DockWindowManager::saveState()
}
}
void DockWindowManager::loadState()
{
ParameterGrp::handle hPref = App::GetApplication().GetUserParameter().GetGroup("BaseApp")
->GetGroup("MainWindow")->GetGroup("DockWindows");
const QList<DockWindowItem>& dockItems = d->_dockWindowItems.dockWidgets();
for (QList<DockWindowItem>::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<QDockWidget*>& dw, const QString& name) const
{
for (QList<QDockWidget*>::ConstIterator it = dw.begin(); it != dw.end(); ++it) {