mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-12 16:20:25 +08:00
Fixed CustomCloseHandling for floating widgets
This commit is contained in:
parent
df74686287
commit
a0f0640c9f
@ -458,7 +458,21 @@ void MainWindowPrivate::createContent()
|
|||||||
DockManager->addDockWidget(ads::TopDockWidgetArea, createLongTextLabelDockWidget(), RighDockArea);
|
DockManager->addDockWidget(ads::TopDockWidgetArea, createLongTextLabelDockWidget(), RighDockArea);
|
||||||
auto BottomDockArea = DockManager->addDockWidget(ads::BottomDockWidgetArea, createLongTextLabelDockWidget(), RighDockArea);
|
auto BottomDockArea = DockManager->addDockWidget(ads::BottomDockWidgetArea, createLongTextLabelDockWidget(), RighDockArea);
|
||||||
DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(), RighDockArea);
|
DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(), RighDockArea);
|
||||||
DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(), BottomDockArea);
|
auto LabelDockWidget = createLongTextLabelDockWidget();
|
||||||
|
std::cout << "DockWidget " << LabelDockWidget->objectName().toStdString() << std::endl;
|
||||||
|
DockManager->addDockWidget(ads::CenterDockWidgetArea, LabelDockWidget, BottomDockArea);
|
||||||
|
|
||||||
|
// Tests CustomCloseHandling without DeleteOnClose
|
||||||
|
LabelDockWidget->setFeature(ads::CDockWidget::CustomCloseHandling, true);
|
||||||
|
QObject::connect(LabelDockWidget, &ads::CDockWidget::closeRequested, [LabelDockWidget, this]()
|
||||||
|
{
|
||||||
|
int Result = QMessageBox::question(_this, "Custom Close Request",
|
||||||
|
"Do you really want to close this dock widget?");
|
||||||
|
if (QMessageBox::Yes == Result)
|
||||||
|
{
|
||||||
|
LabelDockWidget->closeDockWidget();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Action = ui.menuTests->addAction(QString("Set %1 Floating").arg(DockWidget->windowTitle()));
|
Action = ui.menuTests->addAction(QString("Set %1 Floating").arg(DockWidget->windowTitle()));
|
||||||
DockWidget->connect(Action, SIGNAL(triggered()), SLOT(setFloating()));
|
DockWidget->connect(Action, SIGNAL(triggered()), SLOT(setFloating()));
|
||||||
|
@ -807,11 +807,16 @@ void CFloatingDockContainer::closeEvent(QCloseEvent *event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HasOpenDockWidgets = false;
|
||||||
for (auto DockWidget : d->DockContainer->openedDockWidgets())
|
for (auto DockWidget : d->DockContainer->openedDockWidgets())
|
||||||
{
|
{
|
||||||
if (DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose) || DockWidget->features().testFlag(CDockWidget::CustomCloseHandling))
|
if (DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose) || DockWidget->features().testFlag(CDockWidget::CustomCloseHandling))
|
||||||
{
|
{
|
||||||
DockWidget->closeDockWidgetInternal();
|
bool Closed = DockWidget->closeDockWidgetInternal();
|
||||||
|
if (!Closed)
|
||||||
|
{
|
||||||
|
HasOpenDockWidgets = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -819,6 +824,11 @@ void CFloatingDockContainer::closeEvent(QCloseEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (HasOpenDockWidgets)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// In Qt version after 5.9.2 there seems to be a bug that causes the
|
// In Qt version after 5.9.2 there seems to be a bug that causes the
|
||||||
// QWidget::event() function to not receive any NonClientArea mouse
|
// QWidget::event() function to not receive any NonClientArea mouse
|
||||||
// events anymore after a close/show cycle. The bug is reported here:
|
// events anymore after a close/show cycle. The bug is reported here:
|
||||||
|
Loading…
Reference in New Issue
Block a user