mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 07:31:33 +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();
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockAreaWidget::onDockWidgetFeaturesChanged()
|
||||
{
|
||||
if (d->TitleBar)
|
||||
d->updateTitleBarButtonStates();
|
||||
}
|
||||
|
||||
|
||||
} // namespace ads
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -65,6 +65,7 @@ private:
|
||||
friend class CDockWidget;
|
||||
friend struct DockManagerPrivate;
|
||||
friend class CDockManager;
|
||||
void onDockWidgetFeaturesChanged();
|
||||
|
||||
private slots:
|
||||
void onTabCloseRequested(int Index);
|
||||
|
@ -340,6 +340,8 @@ void CDockWidget::setFeatures(DockWidgetFeatures features)
|
||||
d->Features = features;
|
||||
emit featuresChanged(d->Features);
|
||||
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>
|
||||
IFloatingWidget* createFloatingWidget(T* Widget, bool OpaqueUndocking)
|
||||
{
|
||||
@ -461,11 +473,7 @@ bool CDockWidgetTab::isActiveTab() const
|
||||
//============================================================================
|
||||
void CDockWidgetTab::setActiveTab(bool active)
|
||||
{
|
||||
bool DockWidgetClosable = d->DockWidget->features().testFlag(CDockWidget::DockWidgetClosable);
|
||||
bool ActiveTabHasCloseButton = d->testConfigFlag(CDockManager::ActiveTabHasCloseButton);
|
||||
bool AllTabsHaveCloseButton = d->testConfigFlag(CDockManager::AllTabsHaveCloseButton);
|
||||
bool TabHasCloseButton = (ActiveTabHasCloseButton && active) | AllTabsHaveCloseButton;
|
||||
d->CloseButton->setVisible(DockWidgetClosable && TabHasCloseButton);
|
||||
d->updateCloseButtonVisibility(active);
|
||||
|
||||
// Focus related stuff
|
||||
if (CDockManager::testConfigFlag(CDockManager::FocusHighlighting) && !d->DockWidget->dockManager()->isRestoringState())
|
||||
@ -653,6 +661,7 @@ void CDockWidgetTab::onDockWidgetFeaturesChanged()
|
||||
SizePolicy.setRetainSizeWhenHidden(Features.testFlag(CDockWidget::DockWidgetClosable)
|
||||
&& d->testConfigFlag(CDockManager::RetainTabSizeWhenCloseButtonHidden));
|
||||
d->CloseButton->setSizePolicy(SizePolicy);
|
||||
d->updateCloseButtonVisibility(isActiveTab());
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user