Skip to content

Commit 2afe62e

Browse files
Fixed issue #378 - Don't show empty floating containers on startup
1 parent 0df1a41 commit 2afe62e

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

demo/MainWindow.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,15 @@ void MainWindowPrivate::createContent()
466466
Action = ui.menuTests->addAction(QString("Raise %1").arg(DockWidget->windowTitle()));
467467
DockWidget->connect(Action, SIGNAL(triggered()), SLOT(raise()));
468468

469+
// Test hidden floating dock widget
470+
DockWidget = createLongTextLabelDockWidget();
471+
DockManager->addDockWidgetFloating(DockWidget);
472+
DockWidget->toggleView(false);
473+
474+
// Test visible floating dock widget
475+
DockWidget = createCalendarDockWidget();
476+
DockManager->addDockWidgetFloating(DockWidget);
477+
469478

470479
#ifdef Q_OS_WIN
471480
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))

src/DockContainerWidget.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,21 @@ QList<CDockAreaWidget*> CDockContainerWidget::openedDockAreas() const
16251625
}
16261626

16271627

1628+
//============================================================================
1629+
bool CDockContainerWidget::hasOpenDockAreas() const
1630+
{
1631+
for (auto DockArea : d->DockAreas)
1632+
{
1633+
if (!DockArea->isHidden())
1634+
{
1635+
return true;
1636+
}
1637+
}
1638+
1639+
return false;
1640+
}
1641+
1642+
16281643
//============================================================================
16291644
void CDockContainerWidget::saveState(QXmlStreamWriter& s) const
16301645
{

src/DockContainerWidget.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,13 @@ class ADS_EXPORT CDockContainerWidget : public QFrame
216216
*/
217217
QList<CDockAreaWidget*> openedDockAreas() const;
218218

219+
/**
220+
* This function returns true, if the container has open dock areas.
221+
* This functions is a little bit faster than calling openedDockAreas().isEmpty()
222+
* because it returns as soon as it finds an open dock area
223+
*/
224+
bool hasOpenDockAreas() const;
225+
219226
/**
220227
* This function returns true if this dock area has only one single
221228
* visible dock widget.

src/DockManager.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,12 @@ void CDockManager::showEvent(QShowEvent *event)
762762

763763
for (auto FloatingWidget : d->UninitializedFloatingWidgets)
764764
{
765-
FloatingWidget->show();
765+
// Check, if someone closed a floating dock widget before the dock
766+
// manager is shown
767+
if (FloatingWidget->dockContainer()->hasOpenDockAreas())
768+
{
769+
FloatingWidget->show();
770+
}
766771
}
767772
d->UninitializedFloatingWidgets.clear();
768773
}

0 commit comments

Comments
 (0)