5454#include " DockSplitter.h"
5555#include " DockAreaTitleBar.h"
5656
57+ #include < iostream>
58+
5759
5860namespace ads
5961{
@@ -242,6 +244,7 @@ struct DockAreaWidgetPrivate
242244 DockAreaLayout* ContentsLayout;
243245 CDockAreaTitleBar* TitleBar;
244246 CDockManager* DockManager = nullptr ;
247+ bool UpdateCloseButton = false ;
245248
246249 /* *
247250 * Private data constructor
@@ -293,6 +296,11 @@ struct DockAreaWidgetPrivate
293296 {
294297 return TitleBar->tabBar ();
295298 }
299+
300+ /* *
301+ * Udpates the enable state of the close button
302+ */
303+ void updateCloseButtonState ();
296304};
297305// struct DockAreaWidgetPrivate
298306
@@ -319,6 +327,25 @@ void DockAreaWidgetPrivate::createTitleBar()
319327}
320328
321329
330+ // ============================================================================
331+ void DockAreaWidgetPrivate::updateCloseButtonState ()
332+ {
333+ if (_this->isHidden ())
334+ {
335+ UpdateCloseButton = true ;
336+ return ;
337+ }
338+
339+ if (!UpdateCloseButton)
340+ {
341+ return ;
342+ }
343+ TitleBar->button (TitleBarButtonClose)->setEnabled (
344+ _this->features ().testFlag (CDockWidget::DockWidgetClosable));
345+ UpdateCloseButton = false ;
346+ }
347+
348+
322349// ============================================================================
323350CDockAreaWidget::CDockAreaWidget (CDockManager* DockManager, CDockContainerWidget* parent) :
324351 QFrame (parent),
@@ -383,6 +410,7 @@ void CDockAreaWidget::insertDockWidget(int index, CDockWidget* DockWidget,
383410 setCurrentIndex (index);
384411 }
385412 DockWidget->setDockArea (this );
413+ d->updateCloseButtonState ();
386414}
387415
388416
@@ -414,6 +442,7 @@ void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
414442 hideAreaWithNoVisibleContent ();
415443 }
416444
445+ d->updateCloseButtonState ();
417446 updateTitleBarVisibility ();
418447 auto TopLevelDockWidget = dockContainer ()->topLevelDockWidget ();
419448 if (TopLevelDockWidget)
@@ -730,10 +759,19 @@ CDockWidget::DockWidgetFeatures CDockAreaWidget::features() const
730759void CDockAreaWidget::toggleView (bool Open)
731760{
732761 setVisible (Open);
762+
733763 emit viewToggled (Open);
734764}
735765
736766
767+ // ============================================================================
768+ void CDockAreaWidget::setVisible (bool Visible)
769+ {
770+ Super::setVisible (Visible);
771+ d->updateCloseButtonState ();
772+ }
773+
774+
737775// ============================================================================
738776QAbstractButton* CDockAreaWidget::titleBarButton (TitleBarButton which) const
739777{
0 commit comments