@@ -179,7 +179,8 @@ void DockAreaTitleBarPrivate::createButtons()
179
179
QSizePolicy ButtonSizePolicy (QSizePolicy::Fixed, QSizePolicy::Expanding);
180
180
181
181
// Tabs menu button
182
- TabsMenuButton = new CTitleBarButton (testConfigFlag (CDockManager::DockAreaHasTabsMenuButton));
182
+ TabsMenuButton = new CTitleBarButton (testConfigFlag (CDockManager::DockAreaHasTabsMenuButton),
183
+ false , TitleBarButtonTabsMenu);
183
184
TabsMenuButton->setObjectName (" tabsMenuButton" );
184
185
TabsMenuButton->setAutoRaise (true );
185
186
TabsMenuButton->setPopupMode (QToolButton::InstantPopup);
@@ -197,7 +198,8 @@ void DockAreaTitleBarPrivate::createButtons()
197
198
SLOT (onTabsMenuActionTriggered (QAction*)));
198
199
199
200
// Undock button
200
- UndockButton = new CTitleBarButton (testConfigFlag (CDockManager::DockAreaHasUndockButton));
201
+ UndockButton = new CTitleBarButton (testConfigFlag (CDockManager::DockAreaHasUndockButton),
202
+ true , TitleBarButtonUndock);
201
203
UndockButton->setObjectName (" detachGroupButton" );
202
204
UndockButton->setAutoRaise (true );
203
205
internal::setToolTip (UndockButton, QObject::tr (" Detach Group" ));
@@ -208,7 +210,8 @@ void DockAreaTitleBarPrivate::createButtons()
208
210
209
211
// AutoHide Button
210
212
const auto autoHideEnabled = testAutoHideConfigFlag (CDockManager::AutoHideFeatureEnabled);
211
- AutoHideButton = new CTitleBarButton (testAutoHideConfigFlag (CDockManager::DockAreaHasAutoHideButton) && autoHideEnabled);
213
+ AutoHideButton = new CTitleBarButton (testAutoHideConfigFlag (CDockManager::DockAreaHasAutoHideButton) && autoHideEnabled,
214
+ true , TitleBarButtonAutoHide);
212
215
AutoHideButton->setObjectName (" dockAreaAutoHideButton" );
213
216
AutoHideButton->setAutoRaise (true );
214
217
internal::setToolTip (AutoHideButton, _this->titleBarButtonToolTip (TitleBarButtonAutoHide));
@@ -220,7 +223,8 @@ void DockAreaTitleBarPrivate::createButtons()
220
223
_this->connect (AutoHideButton, SIGNAL (clicked ()), SLOT (onAutoHideButtonClicked ()));
221
224
222
225
// Minimize button
223
- MinimizeButton = new CTitleBarButton (testAutoHideConfigFlag (CDockManager::AutoHideHasMinimizeButton));
226
+ MinimizeButton = new CTitleBarButton (testAutoHideConfigFlag (CDockManager::AutoHideHasMinimizeButton),
227
+ false , TitleBarButtonMinimize);
224
228
MinimizeButton->setObjectName (" dockAreaMinimizeButton" );
225
229
MinimizeButton->setAutoRaise (true );
226
230
MinimizeButton->setVisible (false );
@@ -231,7 +235,8 @@ void DockAreaTitleBarPrivate::createButtons()
231
235
_this->connect (MinimizeButton, SIGNAL (clicked ()), SLOT (minimizeAutoHideContainer ()));
232
236
233
237
// Close button
234
- CloseButton = new CTitleBarButton (testConfigFlag (CDockManager::DockAreaHasCloseButton));
238
+ CloseButton = new CTitleBarButton (testConfigFlag (CDockManager::DockAreaHasCloseButton),
239
+ true , TitleBarButtonClose);
235
240
CloseButton->setObjectName (" dockAreaCloseButton" );
236
241
CloseButton->setAutoRaise (true );
237
242
internal::setButtonIcon (CloseButton, QStyle::SP_TitleBarCloseButton, ads::DockAreaCloseIcon);
@@ -510,7 +515,7 @@ void CDockAreaTitleBar::updateDockWidgetActionsButtons()
510
515
int InsertIndex = indexOf (d->TabsMenuButton );
511
516
for (auto Action : Actions)
512
517
{
513
- auto Button = new CTitleBarButton (true , this );
518
+ auto Button = new CTitleBarButton (true , false , TitleBarButtonTabsMenu, this );
514
519
Button->setDefaultAction (Action);
515
520
Button->setAutoRaise (true );
516
521
Button->setPopupMode (QToolButton::InstantPopup);
@@ -856,10 +861,25 @@ void CDockAreaTitleBar::showAutoHideControls(bool Show)
856
861
857
862
858
863
// ============================================================================
859
- CTitleBarButton::CTitleBarButton (bool showInTitleBar, QWidget* parent)
864
+ bool CDockAreaTitleBar::isAutoHide () const
865
+ {
866
+ return d->DockArea && d->DockArea ->isAutoHide ();
867
+ }
868
+
869
+
870
+ // ============================================================================
871
+ CDockAreaWidget* CDockAreaTitleBar::dockAreaWidget () const
872
+ {
873
+ return d->DockArea ;
874
+ }
875
+
876
+
877
+ // ============================================================================
878
+ CTitleBarButton::CTitleBarButton (bool showInTitleBar, bool hideWhenDisabled, TitleBarButton ButtonId, QWidget* parent)
860
879
: tTitleBarButton(parent),
861
880
ShowInTitleBar (showInTitleBar),
862
- HideWhenDisabled(CDockManager::testConfigFlag(CDockManager::DockAreaHideDisabledButtons))
881
+ HideWhenDisabled(CDockManager::testConfigFlag(CDockManager::DockAreaHideDisabledButtons) && hideWhenDisabled),
882
+ TitleBarButtonId(ButtonId)
863
883
{
864
884
setFocusPolicy (Qt::NoFocus);
865
885
}
@@ -894,16 +914,47 @@ void CTitleBarButton::setShowInTitleBar(bool Show)
894
914
// ============================================================================
895
915
bool CTitleBarButton::event (QEvent *ev)
896
916
{
897
- if (QEvent::EnabledChange == ev->type () && HideWhenDisabled)
917
+ if (QEvent::EnabledChange != ev->type () || ! HideWhenDisabled || !ShowInTitleBar )
898
918
{
899
- // force setVisible() call
900
- // Calling setVisible() directly here doesn't work well when button is expected to be shown first time
901
- QMetaObject::invokeMethod (this , " setVisible" , Qt::QueuedConnection, Q_ARG (bool , isEnabled ()));
919
+ return Super::event (ev);
902
920
}
903
921
922
+ bool Show = true ;
923
+ if (isInAutoHideArea ())
924
+ {
925
+ switch (TitleBarButtonId)
926
+ {
927
+ case TitleBarButtonClose: Show = CDockManager::testAutoHideConfigFlag (CDockManager::AutoHideHasCloseButton); break ;
928
+ case TitleBarButtonUndock: Show = false ; break ;
929
+ default :
930
+ break ;
931
+ }
932
+ }
933
+
934
+ // force setVisible() call - Calling setVisible() directly here doesn't
935
+ // work well when button is expected to be shown first time
936
+ QMetaObject::invokeMethod (this , " setVisible" , Qt::QueuedConnection,
937
+ Q_ARG (bool , isEnabledTo (this ->parentWidget ()) & Show));
938
+
904
939
return Super::event (ev);
905
940
}
906
941
942
+
943
+ // ============================================================================
944
+ CDockAreaTitleBar* CTitleBarButton::titleBar () const
945
+ {
946
+ return qobject_cast<CDockAreaTitleBar*>(parentWidget ());
947
+ }
948
+
949
+
950
+ // ============================================================================
951
+ bool CTitleBarButton::isInAutoHideArea () const
952
+ {
953
+ auto TitleBar = titleBar ();
954
+ return TitleBar && TitleBar->isAutoHide ();
955
+ }
956
+
957
+
907
958
// ============================================================================
908
959
CSpacerWidget::CSpacerWidget (QWidget* Parent /* = 0*/ ) : Super(Parent)
909
960
{
0 commit comments