Add DockWidget::Option_NonDockable

A dock widget with this option will always be floating and not be
able to dock into anything. Other widgets can't dock into it either.
This commit is contained in:
Sergio Martins
2020-04-13 12:45:35 +01:00
parent 899ca6af6a
commit ab0fc1e328
11 changed files with 104 additions and 13 deletions

View File

@@ -150,6 +150,12 @@ void DockWidgetBase::addDockWidgetAsTab(DockWidgetBase *other, AddingOption addi
return;
}
if ((other->options() & DockWidgetBase::Option_NotDockable) ||
(options() & DockWidgetBase::Option_NotDockable)) {
qWarning() << Q_FUNC_INFO << "Refusing to dock non-dockable widget" << other;
return;
}
Frame *frame = this->frame();
if (frame) {
@@ -184,6 +190,12 @@ void DockWidgetBase::addDockWidgetToContainingWindow(DockWidgetBase *other, Loca
return;
}
if ((other->options() & DockWidgetBase::Option_NotDockable) ||
(options() & DockWidgetBase::Option_NotDockable)) {
qWarning() << Q_FUNC_INFO << "Refusing to dock non-dockable widget" << other;
return;
}
if (isWindow())
morphIntoFloatingWindow();
@@ -283,6 +295,11 @@ DockWidgetBase::Options DockWidgetBase::options() const
void DockWidgetBase::setOptions(Options options)
{
if ((d->options & Option_NotDockable) != (options & Option_NotDockable)) {
qWarning() << Q_FUNC_INFO << "Option_NotDockable not allowed to change. Pass via ctor only.";
return;
}
if (options != d->options) {
d->options = options;
Q_EMIT optionsChanged(options);