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)
{
std::cout << "closeEvent" << std::endl;
qDebug() << "CFloatingDockContainer closeEvent";
d->setDraggingActive(false);
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()";

View File

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