Added setHideSingleWidgetTitleBar to DockWidgetArea

This commit is contained in:
Some Guy 2020-07-18 22:15:10 +02:00 committed by Uwe Kindler
parent 81c99745d4
commit 8443414ae3
3 changed files with 23 additions and 2 deletions

View File

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

View File

@ -30,8 +30,6 @@
//============================================================================
#include "DockAreaWidget.h"
#include <iostream>
#include <QStackedLayout>
#include <QScrollBar>
#include <QScrollArea>
@ -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
{

View File

@ -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
*/