Skip to content

Commit 8443414

Browse files
SleepProggergithubuser0xFFFF
authored andcommitted
Added setHideSingleWidgetTitleBar to DockWidgetArea
1 parent 81c9974 commit 8443414

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

demo/MainWindow.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,9 @@ void MainWindowPrivate::createContent()
399399
// Test custom factory - we inject a help button into the title bar
400400
ads::CDockComponentsFactory::setFactory(new CCustomComponentsFactory());
401401
auto TopDockArea = DockManager->addDockWidget(ads::TopDockWidgetArea, FileSystemWidget);
402+
// Uncomment the next line if you would like to test the
403+
// setHideSingleWidgetTitleBar() functionality
404+
// TopDockArea->setHideSingleWidgetTitleBar(true);
402405
ads::CDockComponentsFactory::resetDefaultFactory();
403406

404407
// We create a calendar widget and clear all flags to prevent the dock area

src/DockAreaWidget.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
//============================================================================
3131
#include "DockAreaWidget.h"
3232

33-
#include <iostream>
34-
3533
#include <QStackedLayout>
3634
#include <QScrollBar>
3735
#include <QScrollArea>
@@ -251,6 +249,7 @@ struct DockAreaWidgetPrivate
251249
CDockManager* DockManager = nullptr;
252250
bool UpdateTitleBarButtons = false;
253251
DockWidgetAreas AllowedAreas = AllDockAreas;
252+
bool HideSingleWidgetTitleBar = false;
254253
QSize MinSizeHint;
255254

256255
/**
@@ -747,6 +746,7 @@ void CDockAreaWidget::updateTitleBarVisibility()
747746
{
748747
bool Hidden = Container->hasTopLevelDockWidget() && (Container->isFloating()
749748
|| CDockManager::testConfigFlag(CDockManager::HideSingleCentralWidgetTitleBar));
749+
Hidden |= (d->HideSingleWidgetTitleBar && openDockWidgetsCount() == 1);
750750
d->TitleBar->setVisible(!Hidden);
751751
}
752752
}
@@ -850,16 +850,28 @@ void CDockAreaWidget::setVisible(bool Visible)
850850
}
851851
}
852852

853+
854+
//============================================================================
853855
void CDockAreaWidget::setAllowedAreas(DockWidgetAreas areas)
854856
{
855857
d->AllowedAreas = areas;
856858
}
857859

860+
861+
//============================================================================
858862
DockWidgetAreas CDockAreaWidget::allowedAreas() const
859863
{
860864
return d->AllowedAreas;
861865
}
862866

867+
//============================================================================
868+
void CDockAreaWidget::setHideSingleWidgetTitleBar(bool hide)
869+
{
870+
d->HideSingleWidgetTitleBar = hide;
871+
updateTitleBarVisibility();
872+
}
873+
874+
863875
//============================================================================
864876
QAbstractButton* CDockAreaWidget::titleBarButton(TitleBarButton which) const
865877
{

src/DockAreaWidget.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,12 @@ protected slots:
272272
*/
273273
DockWidgetAreas allowedAreas() const;
274274

275+
/**
276+
* Will hide the title bar when set to true and there is only one
277+
* dock widget in this area
278+
*/
279+
void setHideSingleWidgetTitleBar(bool hide);
280+
275281
/**
276282
* Returns the title bar of this dock area
277283
*/

0 commit comments

Comments
 (0)