From 5b3841a038b175be96caf9bd031243d993597ff1 Mon Sep 17 00:00:00 2001 From: Opostol Date: Fri, 10 Aug 2018 18:02:29 +0300 Subject: [PATCH] DockWidgetClosable now prevents Floating Dock Windows from closing Also std::cout were replaced with common used qDebug() --- src/FloatingDockContainer.cpp | 25 ++++++++++++++++++++++--- src/FloatingDockContainer.h | 2 ++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/FloatingDockContainer.cpp b/src/FloatingDockContainer.cpp index 3d7ac45..49b54d4 100644 --- a/src/FloatingDockContainer.cpp +++ b/src/FloatingDockContainer.cpp @@ -300,16 +300,20 @@ void CFloatingDockContainer::moveEvent(QMoveEvent *event) //============================================================================ void CFloatingDockContainer::closeEvent(QCloseEvent *event) { - std::cout << "closeEvent" << std::endl; + qDebug() << "CFloatingDockContainer closeEvent"; d->setDraggingActive(false); - QWidget::closeEvent(event); + + if (isClosable()) + QWidget::closeEvent(event); + else + event->ignore(); } //============================================================================ void CFloatingDockContainer::hideEvent(QHideEvent *event) { - std::cout << "hideEvent" << std::endl; + qDebug() << "CFloatingDockContainer hideEvent"; QWidget::hideEvent(event); auto OpenDockAreas = d->DockContainer->openedDockAreas(); for (auto DockArea : OpenDockAreas) @@ -408,6 +412,21 @@ void CFloatingDockContainer::moveFloating() //============================================================================ +bool CFloatingDockContainer::isClosable() +{ + auto OpenDockAreas = d->DockContainer->openedDockAreas(); + for (auto DockArea : OpenDockAreas) + { + auto OpenDockWidgets = DockArea->openedDockWidgets(); + for (auto DockWidget : OpenDockWidgets) + { + if (!(DockWidget->features() & CDockWidget::DockWidgetClosable)) + return false; + } + } + return true; +} + void CFloatingDockContainer::onDockAreasAddedOrRemoved() { qDebug() << "CFloatingDockContainer::onDockAreasAddedOrRemoved()"; diff --git a/src/FloatingDockContainer.h b/src/FloatingDockContainer.h index 514913c..2c743d5 100644 --- a/src/FloatingDockContainer.h +++ b/src/FloatingDockContainer.h @@ -55,6 +55,8 @@ private: FloatingDockContainerPrivate* d; ///< private data (pimpl) friend struct FloatingDockContainerPrivate; + bool isClosable(); + private slots: void onDockAreasAddedOrRemoved(); void onDockAreaCurrentChanged(int Index);