Don't allow to close/float/tab persistent central widget

Fixes corner cases with MainWindowOption_HasCentralWidget
This commit is contained in:
Sergio Martins
2021-09-02 10:30:34 +01:00
parent 77b5d1630d
commit 0cc0972eea

View File

@@ -83,6 +83,13 @@ void DockWidgetBase::addDockWidgetAsTab(DockWidgetBase *other, InitialOption opt
return;
}
if (isPersistentCentralDockWidget()) {
qWarning() << Q_FUNC_INFO << "Not supported with MainWindowOption_HasCentralWidget."
<< "MainWindowOption_HasCentralWidget can only have 1 widget in the center."
<< "Use MainWindowOption_HasCentralFrame instead, which is similar but supports tabbing.";
return;
}
Frame *frame = d->frame();
if (frame) {
@@ -182,6 +189,9 @@ bool DockWidgetBase::setFloating(bool floats)
return false;
}
if (floats && isPersistentCentralDockWidget())
return false;
if (floats) {
d->saveTabIndex();
if (isTabbed()) {
@@ -620,6 +630,9 @@ void DockWidgetBase::Private::close()
return;
}
if (m_isPersistentCentralDockWidget)
return;
// If it's overlayed and we're closing, we need to close the overlay
if (SideBar *sb = DockRegistry::self()->sideBarForDockWidget(q)) {
auto mainWindow = sb->mainWindow();