refactoring: Move the dockWidgetFactoryFunc() call

It's now an impl-detail of DockRegistry::dockByName().
Just pass DockByNameFlag::CreateIfNotFound.

Allows this functionality to be used in other places
This commit is contained in:
Sergio Martins
2021-04-29 21:29:58 +01:00
parent 580e3a6a2c
commit d5b2336b69
3 changed files with 25 additions and 29 deletions

View File

@@ -785,20 +785,7 @@ void DockWidgetBase::onCloseEvent(QCloseEvent *e)
DockWidgetBase *DockWidgetBase::deserialize(const LayoutSaver::DockWidget::Ptr &saved)
{
auto dr = DockRegistry::self();
DockWidgetBase *dw = dr->dockByName(saved->uniqueName);
if (!dw) {
// DockWidget doesn't exist, ask to create it
if (auto factoryFunc = Config::self().dockWidgetFactoryFunc()) {
dw = factoryFunc(saved->uniqueName);
if (dw && dw->uniqueName() != saved->uniqueName) {
// Very special case
// The user's factory function returned a dock widget with a different ID.
// We support it. Save the mapping though.
dr->dockWidgetIdRemapping().insert(saved->uniqueName, dw->uniqueName());
}
}
}
DockWidgetBase *dw = dr->dockByName(saved->uniqueName, DockRegistry::DockByNameFlag::CreateIfNotFound);
if (dw) {
if (QWidgetOrQuick *w = dw->widget())
w->setVisible(true);