Merge pull request #8 from Opostol/master

DockWidgetClosable now prevents Floating Dock Windows from closing
This commit is contained in:
githubuser0xFFFF 2018-08-14 11:57:01 +02:00 committed by GitHub
commit f5b3c0556d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);
if (isClosable())
QWidget::closeEvent(event); 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);