diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp index 73bd4eb..bff4786 100644 --- a/demo/MainWindow.cpp +++ b/demo/MainWindow.cpp @@ -399,6 +399,9 @@ void MainWindowPrivate::createContent() // Test custom factory - we inject a help button into the title bar ads::CDockComponentsFactory::setFactory(new CCustomComponentsFactory()); auto TopDockArea = DockManager->addDockWidget(ads::TopDockWidgetArea, FileSystemWidget); + // Uncomment the next line if you would like to test the + // setHideSingleWidgetTitleBar() functionality + // TopDockArea->setHideSingleWidgetTitleBar(true); ads::CDockComponentsFactory::resetDefaultFactory(); // We create a calendar widget and clear all flags to prevent the dock area diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index 64dcf24..01acfa6 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -30,8 +30,6 @@ //============================================================================ #include "DockAreaWidget.h" -#include - #include #include #include @@ -251,6 +249,7 @@ struct DockAreaWidgetPrivate CDockManager* DockManager = nullptr; bool UpdateTitleBarButtons = false; DockWidgetAreas AllowedAreas = AllDockAreas; + bool HideSingleWidgetTitleBar = false; QSize MinSizeHint; /** @@ -747,6 +746,7 @@ void CDockAreaWidget::updateTitleBarVisibility() { bool Hidden = Container->hasTopLevelDockWidget() && (Container->isFloating() || CDockManager::testConfigFlag(CDockManager::HideSingleCentralWidgetTitleBar)); + Hidden |= (d->HideSingleWidgetTitleBar && openDockWidgetsCount() == 1); d->TitleBar->setVisible(!Hidden); } } @@ -850,16 +850,28 @@ void CDockAreaWidget::setVisible(bool Visible) } } + +//============================================================================ void CDockAreaWidget::setAllowedAreas(DockWidgetAreas areas) { d->AllowedAreas = areas; } + +//============================================================================ DockWidgetAreas CDockAreaWidget::allowedAreas() const { return d->AllowedAreas; } +//============================================================================ +void CDockAreaWidget::setHideSingleWidgetTitleBar(bool hide) +{ + d->HideSingleWidgetTitleBar = hide; + updateTitleBarVisibility(); +} + + //============================================================================ QAbstractButton* CDockAreaWidget::titleBarButton(TitleBarButton which) const { diff --git a/src/DockAreaWidget.h b/src/DockAreaWidget.h index 16f42d7..3deada4 100644 --- a/src/DockAreaWidget.h +++ b/src/DockAreaWidget.h @@ -272,6 +272,12 @@ public: */ DockWidgetAreas allowedAreas() const; + /** + * Will hide the title bar when set to true and there is only one + * dock widget in this area + */ + void setHideSingleWidgetTitleBar(bool hide); + /** * Returns the title bar of this dock area */