From a668fe2f739608055698e50e8bcdac6caa716bde Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Sun, 12 Apr 2020 01:05:20 +0200 Subject: [PATCH] Added new config flag HideSingleCentralWidgetTitleBar to enble a central single dock widget in the main dock container (dock manager) without titlebar Added a test case for the new flag to MainWindow.cpp --- demo/MainWindow.cpp | 6 +++++- src/DockAreaWidget.cpp | 13 +++++++++---- src/DockManager.h | 8 +++++--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp index 212d2ad..6769eab 100644 --- a/demo/MainWindow.cpp +++ b/demo/MainWindow.cpp @@ -386,7 +386,6 @@ void MainWindowPrivate::createContent() // We create a calendar widget and clear all flags to prevent the dock area // from closing DockWidget = createCalendarDockWidget(ViewMenu); - DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false); DockWidget->setFeature(ads::CDockWidget::DockWidgetMovable, false); DockWidget->setFeature(ads::CDockWidget::DockWidgetFloatable, false); DockWidget->setTabToolTip(QString("Tab ToolTip\nHodie est dies magna")); @@ -550,6 +549,11 @@ CMainWindow::CMainWindow(QWidget *parent) : // uncomment the following line if you want floating container to show active dock widget's icon instead of always showing application icon //CDockManager::setConfigFlag(CDockManager::FloatingContainerHasWidgetIcon, true); + // uncomment the following line if you want a central widget in the main dock container (the dock manager) without a titlebar + // If you enable this code, you can test it in the demo with the Calendar 0 + // dock widget. + // CDockManager::setConfigFlag(CDockManager::HideSingleCentralWidgetTitleBar, true); + // Now create the dock manager and its content d->DockManager = new CDockManager(this); diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index 66420d9..a6e6f1f 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -488,7 +488,7 @@ void CDockAreaWidget::hideAreaWithNoVisibleContent() //Hide empty floating widget CDockContainerWidget* Container = this->dockContainer(); - if (!Container->isFloating()) + if (!Container->isFloating() && !CDockManager::testConfigFlag(CDockManager::HideSingleCentralWidgetTitleBar)) { return; } @@ -498,10 +498,13 @@ void CDockAreaWidget::hideAreaWithNoVisibleContent() auto FloatingWidget = Container->floatingWidget(); if (TopLevelWidget) { - FloatingWidget->updateWindowTitle(); + if (FloatingWidget) + { + FloatingWidget->updateWindowTitle(); + } CDockWidget::emitTopLevelEventForWidget(TopLevelWidget, true); } - else if (Container->openedDockAreas().isEmpty()) + else if (Container->openedDockAreas().isEmpty() && FloatingWidget) { FloatingWidget->hide(); } @@ -729,7 +732,9 @@ void CDockAreaWidget::updateTitleBarVisibility() if (d->TitleBar) { - d->TitleBar->setVisible(!Container->isFloating() || !Container->hasTopLevelDockWidget()); + bool Hidden = Container->hasTopLevelDockWidget() && (Container->isFloating() + || CDockManager::configFlags().testFlag(CDockManager::HideSingleCentralWidgetTitleBar)); + d->TitleBar->setVisible(!Hidden); } } diff --git a/src/DockManager.h b/src/DockManager.h index e20f6de..7a9821d 100644 --- a/src/DockManager.h +++ b/src/DockManager.h @@ -156,9 +156,11 @@ public: DockAreaHasUndockButton = 0x4000, //!< If the flag is set each dock area has an undock button DockAreaHasTabsMenuButton = 0x8000, //!< If the flag is set each dock area has a tabs menu button DockAreaHideDisabledButtons = 0x10000, //!< If the flag is set disabled dock area buttons will not appear on the tollbar at all (enabling them will bring them back) - DockAreaDynamicTabsMenuButtonVisibility = 0x20000, //!< If the flag is set dock area will disable a tabs menu button when there is only one tab in the area - FloatingContainerHasWidgetTitle = 0x40000, - FloatingContainerHasWidgetIcon = 0x80000, + DockAreaDynamicTabsMenuButtonVisibility = 0x20000, //!< If the flag is set dock area will disable a tabs menu button when there is only one tab in the area + FloatingContainerHasWidgetTitle = 0x40000, //!< If set, the Floating Widget window title reflects the title of the current dock widget otherwise it displays application name as window title + FloatingContainerHasWidgetIcon = 0x80000, //!< If set, the Floating Widget icon reflects the icon of the current dock widget otherwise it displays application icon + HideSingleCentralWidgetTitleBar = 0x100000, //!< If there is only one single visible dock widget in the main dock container (the dock manager) and if this flag is set, then the titlebar of this dock widget will be hidden + //!< this only makes sense for non draggable and non floatable widgets and enables the creation of some kind of "central" widget DefaultDockAreaButtons = DockAreaHasCloseButton