Fixed issue #378 - Don't show empty floating containers on startup

This commit is contained in:
Uwe Kindler 2021-12-06 09:42:12 +01:00
parent 0df1a41a1d
commit 2afe62ec77
4 changed files with 37 additions and 1 deletions

View File

@ -466,6 +466,15 @@ void MainWindowPrivate::createContent()
Action = ui.menuTests->addAction(QString("Raise %1").arg(DockWidget->windowTitle()));
DockWidget->connect(Action, SIGNAL(triggered()), SLOT(raise()));
// Test hidden floating dock widget
DockWidget = createLongTextLabelDockWidget();
DockManager->addDockWidgetFloating(DockWidget);
DockWidget->toggleView(false);
// Test visible floating dock widget
DockWidget = createCalendarDockWidget();
DockManager->addDockWidgetFloating(DockWidget);
#ifdef Q_OS_WIN
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))

View File

@ -1625,6 +1625,21 @@ QList<CDockAreaWidget*> CDockContainerWidget::openedDockAreas() const
}
//============================================================================
bool CDockContainerWidget::hasOpenDockAreas() const
{
for (auto DockArea : d->DockAreas)
{
if (!DockArea->isHidden())
{
return true;
}
}
return false;
}
//============================================================================
void CDockContainerWidget::saveState(QXmlStreamWriter& s) const
{

View File

@ -216,6 +216,13 @@ public:
*/
QList<CDockAreaWidget*> openedDockAreas() const;
/**
* This function returns true, if the container has open dock areas.
* This functions is a little bit faster than calling openedDockAreas().isEmpty()
* because it returns as soon as it finds an open dock area
*/
bool hasOpenDockAreas() const;
/**
* This function returns true if this dock area has only one single
* visible dock widget.

View File

@ -762,7 +762,12 @@ void CDockManager::showEvent(QShowEvent *event)
for (auto FloatingWidget : d->UninitializedFloatingWidgets)
{
FloatingWidget->show();
// Check, if someone closed a floating dock widget before the dock
// manager is shown
if (FloatingWidget->dockContainer()->hasOpenDockAreas())
{
FloatingWidget->show();
}
}
d->UninitializedFloatingWidgets.clear();
}