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
This commit is contained in:
Uwe Kindler 2020-04-12 01:05:20 +02:00
parent 12bb7b73e9
commit a668fe2f73
3 changed files with 19 additions and 8 deletions

View File

@ -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);

View File

@ -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;
}
@ -497,11 +497,14 @@ void CDockAreaWidget::hideAreaWithNoVisibleContent()
auto TopLevelWidget = Container->topLevelDockWidget();
auto FloatingWidget = Container->floatingWidget();
if (TopLevelWidget)
{
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);
}
}

View File

@ -157,8 +157,10 @@ public:
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,
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