DockWidgetClosable now prevents Floating Dock Windows from closing

Also std::cout were replaced with common used qDebug()
This commit is contained in:
Opostol 2018-08-10 18:02:29 +03:00
parent b470dd5f99
commit 5b3841a038
2 changed files with 24 additions and 3 deletions

View File

@ -300,16 +300,20 @@ void CFloatingDockContainer::moveEvent(QMoveEvent *event)
//============================================================================ //============================================================================
void CFloatingDockContainer::closeEvent(QCloseEvent *event) void CFloatingDockContainer::closeEvent(QCloseEvent *event)
{ {
std::cout << "closeEvent" << std::endl; qDebug() << "CFloatingDockContainer closeEvent";
d->setDraggingActive(false); d->setDraggingActive(false);
QWidget::closeEvent(event);
if (isClosable())
QWidget::closeEvent(event);
else
event->ignore();
} }
//============================================================================ //============================================================================
void CFloatingDockContainer::hideEvent(QHideEvent *event) void CFloatingDockContainer::hideEvent(QHideEvent *event)
{ {
std::cout << "hideEvent" << std::endl; qDebug() << "CFloatingDockContainer hideEvent";
QWidget::hideEvent(event); QWidget::hideEvent(event);
auto OpenDockAreas = d->DockContainer->openedDockAreas(); auto OpenDockAreas = d->DockContainer->openedDockAreas();
for (auto DockArea : OpenDockAreas) 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() void CFloatingDockContainer::onDockAreasAddedOrRemoved()
{ {
qDebug() << "CFloatingDockContainer::onDockAreasAddedOrRemoved()"; qDebug() << "CFloatingDockContainer::onDockAreasAddedOrRemoved()";

View File

@ -55,6 +55,8 @@ private:
FloatingDockContainerPrivate* d; ///< private data (pimpl) FloatingDockContainerPrivate* d; ///< private data (pimpl)
friend struct FloatingDockContainerPrivate; friend struct FloatingDockContainerPrivate;
bool isClosable();
private slots: private slots:
void onDockAreasAddedOrRemoved(); void onDockAreasAddedOrRemoved();
void onDockAreaCurrentChanged(int Index); void onDockAreaCurrentChanged(int Index);