mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-12 16:20:25 +08:00
Update the state of close button on titlebar and tabbar when CDockWidget::DockWidgetClosable changed. (#240)
This commit is contained in:
parent
0eca1b0433
commit
703a9b3e12
@ -971,6 +971,16 @@ QSize CDockAreaWidget::minimumSizeHint() const
|
|||||||
{
|
{
|
||||||
return d->MinSizeHint.isValid() ? d->MinSizeHint : Super::minimumSizeHint();
|
return d->MinSizeHint.isValid() ? d->MinSizeHint : Super::minimumSizeHint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockAreaWidget::onDockWidgetFeaturesChanged()
|
||||||
|
{
|
||||||
|
if (d->TitleBar)
|
||||||
|
d->updateTitleBarButtonStates();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -65,6 +65,7 @@ private:
|
|||||||
friend class CDockWidget;
|
friend class CDockWidget;
|
||||||
friend struct DockManagerPrivate;
|
friend struct DockManagerPrivate;
|
||||||
friend class CDockManager;
|
friend class CDockManager;
|
||||||
|
void onDockWidgetFeaturesChanged();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onTabCloseRequested(int Index);
|
void onTabCloseRequested(int Index);
|
||||||
|
@ -340,6 +340,8 @@ void CDockWidget::setFeatures(DockWidgetFeatures features)
|
|||||||
d->Features = features;
|
d->Features = features;
|
||||||
emit featuresChanged(d->Features);
|
emit featuresChanged(d->Features);
|
||||||
d->TabWidget->onDockWidgetFeaturesChanged();
|
d->TabWidget->onDockWidgetFeaturesChanged();
|
||||||
|
if(CDockAreaWidget* DockArea = dockAreaWidget())
|
||||||
|
DockArea->onDockWidgetFeaturesChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -134,6 +134,18 @@ struct DockWidgetTabPrivate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the close button visibility from current feature/config
|
||||||
|
*/
|
||||||
|
void updateCloseButtonVisibility(bool active)
|
||||||
|
{
|
||||||
|
bool DockWidgetClosable = DockWidget->features().testFlag(CDockWidget::DockWidgetClosable);
|
||||||
|
bool ActiveTabHasCloseButton = testConfigFlag(CDockManager::ActiveTabHasCloseButton);
|
||||||
|
bool AllTabsHaveCloseButton = testConfigFlag(CDockManager::AllTabsHaveCloseButton);
|
||||||
|
bool TabHasCloseButton = (ActiveTabHasCloseButton && active) | AllTabsHaveCloseButton;
|
||||||
|
CloseButton->setVisible(DockWidgetClosable && TabHasCloseButton);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
IFloatingWidget* createFloatingWidget(T* Widget, bool OpaqueUndocking)
|
IFloatingWidget* createFloatingWidget(T* Widget, bool OpaqueUndocking)
|
||||||
{
|
{
|
||||||
@ -461,11 +473,7 @@ bool CDockWidgetTab::isActiveTab() const
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockWidgetTab::setActiveTab(bool active)
|
void CDockWidgetTab::setActiveTab(bool active)
|
||||||
{
|
{
|
||||||
bool DockWidgetClosable = d->DockWidget->features().testFlag(CDockWidget::DockWidgetClosable);
|
d->updateCloseButtonVisibility(active);
|
||||||
bool ActiveTabHasCloseButton = d->testConfigFlag(CDockManager::ActiveTabHasCloseButton);
|
|
||||||
bool AllTabsHaveCloseButton = d->testConfigFlag(CDockManager::AllTabsHaveCloseButton);
|
|
||||||
bool TabHasCloseButton = (ActiveTabHasCloseButton && active) | AllTabsHaveCloseButton;
|
|
||||||
d->CloseButton->setVisible(DockWidgetClosable && TabHasCloseButton);
|
|
||||||
|
|
||||||
// Focus related stuff
|
// Focus related stuff
|
||||||
if (CDockManager::testConfigFlag(CDockManager::FocusHighlighting) && !d->DockWidget->dockManager()->isRestoringState())
|
if (CDockManager::testConfigFlag(CDockManager::FocusHighlighting) && !d->DockWidget->dockManager()->isRestoringState())
|
||||||
@ -653,6 +661,7 @@ void CDockWidgetTab::onDockWidgetFeaturesChanged()
|
|||||||
SizePolicy.setRetainSizeWhenHidden(Features.testFlag(CDockWidget::DockWidgetClosable)
|
SizePolicy.setRetainSizeWhenHidden(Features.testFlag(CDockWidget::DockWidgetClosable)
|
||||||
&& d->testConfigFlag(CDockManager::RetainTabSizeWhenCloseButtonHidden));
|
&& d->testConfigFlag(CDockManager::RetainTabSizeWhenCloseButtonHidden));
|
||||||
d->CloseButton->setSizePolicy(SizePolicy);
|
d->CloseButton->setSizePolicy(SizePolicy);
|
||||||
|
d->updateCloseButtonVisibility(isActiveTab());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user