Renamed toggleAutoHide to setAutoHide and added toggleAutoHide function

This commit is contained in:
Uwe Kindler 2022-11-01 21:31:27 +01:00
parent fda5887d50
commit 540961b8dd
5 changed files with 55 additions and 9 deletions

View File

@ -493,7 +493,7 @@ void CDockAreaTitleBar::onCurrentTabChanged(int Index)
//============================================================================
void CDockAreaTitleBar::onAutoHideButtonClicked()
{
d->DockArea->toggleAutoHide(!d->DockArea->isAutoHide());
d->DockArea->setAutoHide(!d->DockArea->isAutoHide());
}

View File

@ -61,6 +61,15 @@ namespace ads
static const char* const INDEX_PROPERTY = "index";
static const char* const ACTION_PROPERTY = "action";
/**
* Check, if auto hide is enabled
*/
static bool isAutoHideFeatureEnabled()
{
return CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled);
}
/**
* Internal dock area layout mimics stack layout but only inserts the current
* widget into the internal QLayout object.
@ -826,7 +835,7 @@ void CDockAreaWidget::updateTitleBarVisibility()
Hidden &= !IsAutoHide; // Titlebar must always be visible when auto hidden so it can be dragged
d->TitleBar->setVisible(!Hidden);
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled))
if (isAutoHideFeatureEnabled())
{
auto tabBar = d->TitleBar->tabBar();
tabBar->setVisible(!IsAutoHide); // Never show tab bar when auto hidden
@ -1176,16 +1185,29 @@ void CDockAreaWidget::closeArea()
}
}
//============================================================================
void CDockAreaWidget::toggleAutoHide(bool Enable)
SideBarLocation CDockAreaWidget::calculateSideTabBarArea() const
{
return dockContainer()->calculateSideTabBarArea(this);
}
//============================================================================
void CDockAreaWidget::setAutoHide(bool Enable)
{
if (!isAutoHideFeatureEnabled())
{
return;
}
if (!Enable)
{
autoHideDockContainer()->moveContentsToParent();
return;
}
const auto area = dockContainer()->calculateSideTabBarArea(this);
const auto area = calculateSideTabBarArea();
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideButtonTogglesArea)
&& features().testFlag(CDockWidget::DockWidgetPinnable))
@ -1212,6 +1234,18 @@ void CDockAreaWidget::toggleAutoHide(bool Enable)
}
//============================================================================
void CDockAreaWidget::toggleAutoHide()
{
if (!isAutoHideFeatureEnabled())
{
return;
}
setAutoHide(!isAutoHide());
}
//============================================================================
void CDockAreaWidget::closeOtherAreas()
{

View File

@ -89,6 +89,12 @@ private Q_SLOTS:
*/
void updateTitleBarButtonToolTip();
/**
* Calculate the auto hide side bar location depending on the dock area
* widget position in the container
*/
SideBarLocation calculateSideTabBarArea() const;
protected:
#ifdef Q_OS_WIN
@ -211,7 +217,7 @@ public:
CAutoHideDockContainer* autoHideDockContainer() const;
/**
* Returns true if the dock area exists in an auto hide dock container
* Returns true if the dock area is in an auto hide container
*/
bool isAutoHide() const;
@ -385,9 +391,15 @@ public Q_SLOTS:
void closeArea();
/**
* Toggles the Auto hides behaviour of the dock area and all dock widgets in this area
* Sets the dock area into auto hide mode or into normal mode
*/
void toggleAutoHide(bool Enable);
void setAutoHide(bool Enable);
/**
* Switches the dock area to auto hide mode or vice versa depending on its
* current state.
*/
void toggleAutoHide();
/**
* This function closes all other areas except of this area

View File

@ -1411,7 +1411,7 @@ enum eBorderLocation
//============================================================================
SideBarLocation CDockContainerWidget::calculateSideTabBarArea(CDockAreaWidget* DockAreaWidget)
SideBarLocation CDockContainerWidget::calculateSideTabBarArea(const CDockAreaWidget* DockAreaWidget) const
{
auto ContentRect = this->contentRect();

View File

@ -220,7 +220,7 @@ public:
/**
* Get's the auto hide dock side tab bar area based on the dock area widget position
*/
SideBarLocation calculateSideTabBarArea(CDockAreaWidget* DockAreaWidget);
SideBarLocation calculateSideTabBarArea(const CDockAreaWidget* DockAreaWidget) const;
/**
* Removes dockwidget