mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-24 05:22:06 +08:00
Fix bug where undock button would be show incorrectly in floating dock
widgets when toggling overlay Also centralized and simplified the logic for the title bar button visibility
This commit is contained in:
parent
af549d8ca9
commit
c1df05b55d
@ -310,6 +310,11 @@ struct DockAreaWidgetPrivate
|
||||
*/
|
||||
void updateTitleBarButtonStates();
|
||||
|
||||
/**
|
||||
* Udpates the enable state of the close and detach button
|
||||
*/
|
||||
void updateTitleBarButtonVisibility(bool isTopLevel);
|
||||
|
||||
/**
|
||||
* Scans all contained dock widgets for the max. minimum size hint
|
||||
*/
|
||||
@ -358,14 +363,38 @@ void DockAreaWidgetPrivate::updateTitleBarButtonStates()
|
||||
_this->features().testFlag(CDockWidget::DockWidgetClosable));
|
||||
TitleBar->button(TitleBarButtonUndock)->setEnabled(
|
||||
_this->features().testFlag(CDockWidget::DockWidgetFloatable));
|
||||
// Undock and tabs should never show when overlayed
|
||||
TitleBar->button(TitleBarButtonUndock)->setVisible(!_this->isOverlayed());
|
||||
TitleBar->button(TitleBarButtonTabsMenu)->setVisible(!_this->isOverlayed());
|
||||
TitleBar->updateDockWidgetActionsButtons();
|
||||
UpdateTitleBarButtons = false;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void DockAreaWidgetPrivate::updateTitleBarButtonVisibility(bool IsTopLevel)
|
||||
{
|
||||
auto *const container = _this->dockContainer();
|
||||
if (!container)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsTopLevel)
|
||||
{
|
||||
TitleBar->button(TitleBarButtonClose)->setVisible(!container->isFloating());
|
||||
TitleBar->button(TitleBarButtonAutoHide)->setVisible(!container->isFloating());
|
||||
// Undock and tabs should never show when overlayed
|
||||
TitleBar->button(TitleBarButtonUndock)->setVisible(!container->isFloating() && !_this->isOverlayed());
|
||||
TitleBar->button(TitleBarButtonTabsMenu)->setVisible(!_this->isOverlayed());
|
||||
}
|
||||
else
|
||||
{
|
||||
TitleBar->button(TitleBarButtonClose)->setVisible(true);
|
||||
TitleBar->button(TitleBarButtonAutoHide)->setVisible(true);
|
||||
TitleBar->button(TitleBarButtonUndock)->setVisible(!_this->isOverlayed());
|
||||
TitleBar->button(TitleBarButtonTabsMenu)->setVisible(!_this->isOverlayed());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CDockAreaWidget::CDockAreaWidget(CDockManager* DockManager, CDockContainerWidget* parent) :
|
||||
QFrame(parent),
|
||||
@ -787,6 +816,7 @@ void CDockAreaWidget::updateTitleBarVisibility()
|
||||
auto tabBar = d->TitleBar->tabBar();
|
||||
tabBar->setVisible(isOverlayed() ? false : !Hidden); // Never show tab bar when overlayed
|
||||
d->TitleBar->overlayTitleLabel()->setVisible(isOverlayed()); // Always show when overlayed, never otherwise
|
||||
updateTitleBarButtonVisibility(Container->topLevelDockArea() == this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -810,6 +840,11 @@ void CDockAreaWidget::updateAutoHidebuttonCheckState()
|
||||
autoHideButton->blockSignals(false);
|
||||
}
|
||||
|
||||
void CDockAreaWidget::updateTitleBarButtonVisibility(bool IsTopLevel) const
|
||||
{
|
||||
d->updateTitleBarButtonVisibility(IsTopLevel);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockAreaWidget::saveState(QXmlStreamWriter& s) const
|
||||
|
@ -156,6 +156,11 @@ protected:
|
||||
*/
|
||||
void updateAutoHidebuttonCheckState();
|
||||
|
||||
/*
|
||||
* Update the title bar button visibility based on if it's top level or not
|
||||
*/
|
||||
void updateTitleBarButtonVisibility(bool IsTopLevel) const;
|
||||
|
||||
protected Q_SLOTS:
|
||||
void toggleView(bool Open);
|
||||
|
||||
|
@ -428,15 +428,11 @@ void DockContainerWidgetPrivate::onVisibleDockAreaCountChanged()
|
||||
if (TopLevelDockArea)
|
||||
{
|
||||
this->TopLevelDockArea = TopLevelDockArea;
|
||||
TopLevelDockArea->titleBarButton(TitleBarButtonUndock)->setVisible(false || !_this->isFloating());
|
||||
TopLevelDockArea->titleBarButton(TitleBarButtonClose)->setVisible(false || !_this->isFloating());
|
||||
TopLevelDockArea->titleBarButton(TitleBarButtonAutoHide)->setVisible(false || !_this->isFloating());
|
||||
TopLevelDockArea->updateTitleBarButtonVisibility(true);
|
||||
}
|
||||
else if (this->TopLevelDockArea)
|
||||
{
|
||||
this->TopLevelDockArea->titleBarButton(TitleBarButtonUndock)->setVisible(true);
|
||||
this->TopLevelDockArea->titleBarButton(TitleBarButtonClose)->setVisible(true);
|
||||
this->TopLevelDockArea->titleBarButton(TitleBarButtonAutoHide)->setVisible(true);
|
||||
this->TopLevelDockArea->updateTitleBarButtonVisibility(false);
|
||||
this->TopLevelDockArea = nullptr;
|
||||
}
|
||||
}
|
||||
@ -833,7 +829,6 @@ void DockContainerWidgetPrivate::addDockAreasToList(const QList<CDockAreaWidget*
|
||||
// likely hidden. We need to ensure, that it is visible
|
||||
for (auto DockArea : NewDockAreas)
|
||||
{
|
||||
DockArea->titleBarButton(TitleBarButtonUndock)->setVisible(true);
|
||||
DockArea->titleBarButton(TitleBarButtonClose)->setVisible(true);
|
||||
DockArea->titleBarButton(TitleBarButtonAutoHide)->setVisible(true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user