mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 07:31:33 +08:00
Merge branch 'master' of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System
This commit is contained in:
commit
6d9c4cee02
@ -86,6 +86,18 @@ public:
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete widgets without parents in this layout
|
||||
*/
|
||||
~CDockAreaLayout()
|
||||
{
|
||||
for(auto Widget : m_Widgets)
|
||||
{
|
||||
if(!Widget->parent())
|
||||
delete Widget;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of widgets in this layout
|
||||
*/
|
||||
@ -466,6 +478,14 @@ void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
|
||||
ADS_PRINT("Dock Area empty");
|
||||
DockContainer->removeDockArea(this);
|
||||
this->deleteLater();
|
||||
if(DockContainer->dockAreaCount() == 0)
|
||||
{
|
||||
if(CFloatingDockContainer* FloatingDockContainer = DockContainer->floatingWidget())
|
||||
{
|
||||
FloatingDockContainer->hide();
|
||||
FloatingDockContainer->deleteLater();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (DockWidget == CurrentDockWidget)
|
||||
{
|
||||
@ -951,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);
|
||||
|
@ -484,6 +484,12 @@ CDockManager::~CDockManager()
|
||||
{
|
||||
delete FloatingWidget;
|
||||
}
|
||||
auto DockWidgetsMap = d->DockWidgetsMap;
|
||||
for(auto DockWidget : d->DockWidgetsMap)
|
||||
{
|
||||
if(!DockWidget->parent())
|
||||
delete DockWidget;
|
||||
}
|
||||
delete d;
|
||||
}
|
||||
|
||||
@ -653,7 +659,14 @@ void CDockManager::showEvent(QShowEvent *event)
|
||||
|
||||
for (auto FloatingWidget : d->UninitializedFloatingWidgets)
|
||||
{
|
||||
FloatingWidget->show();
|
||||
for(CDockWidget* DockWidget : FloatingWidget->dockWidgets())
|
||||
{
|
||||
if(!DockWidget->isClosed())
|
||||
{
|
||||
FloatingWidget->show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
d->UninitializedFloatingWidgets.clear();
|
||||
}
|
||||
|
@ -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