Added setAutoHide() and toggleAutoHide() function to CDockWidget

This commit is contained in:
Uwe Kindler 2022-11-02 08:27:23 +01:00
parent 7c1d04f7be
commit 9c14c62637
3 changed files with 53 additions and 8 deletions

View File

@ -1304,11 +1304,10 @@ void CDockAreaWidget::setAutoHide(bool Enable)
return;
}
const auto area = calculateSideTabBarArea();
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideButtonTogglesArea)
&& features().testFlag(CDockWidget::DockWidgetPinnable))
{
auto area = calculateSideTabBarArea();
for (const auto DockWidget : openedDockWidgets())
{
if (Enable == isAutoHide())
@ -1321,12 +1320,7 @@ void CDockAreaWidget::setAutoHide(bool Enable)
}
else
{
const auto DockWidget = currentDockWidget();
if (Enable == isAutoHide())
{
return;
}
dockContainer()->createAndSetupAutoHideContainer(area, DockWidget);
currentDockWidget()->setAutoHide(true);
}
}

View File

@ -1156,6 +1156,45 @@ void CDockWidget::raise()
}
//============================================================================
void CDockWidget::setAutoHide(bool Enable)
{
if (!CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled))
{
return;
}
// Do nothing if nothing changes
if (Enable == isAutoHide())
{
return;
}
auto DockArea = dockAreaWidget();
if (!Enable)
{
DockArea->setAutoHide(false);
}
else
{
auto area = DockArea->calculateSideTabBarArea();
dockContainer()->createAndSetupAutoHideContainer(area, this);
}
}
//============================================================================
void CDockWidget::toggleAutoHide()
{
if (!CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled))
{
return;
}
setAutoHide(!isAutoHide());
}
} // namespace ads
//---------------------------------------------------------------------------

View File

@ -592,6 +592,18 @@ public Q_SLOTS:
*/
void showNormal();
/**
* Sets the dock widget into auto hide mode if this feature is enabled
* via CDockManager::setAutoHideFlags(CDockManager::AutoHideFeatureEnabled)
*/
void setAutoHide(bool Enable);
/**
* Switches the dock widget to auto hide mode or vice versa depending on its
* current state.
*/
void toggleAutoHide();
Q_SIGNALS:
/**