diff --git a/src/DockAreaTitleBar.cpp b/src/DockAreaTitleBar.cpp index 3950739..20554f8 100644 --- a/src/DockAreaTitleBar.cpp +++ b/src/DockAreaTitleBar.cpp @@ -68,10 +68,10 @@ static const char* const LocationProperty = "Location"; struct DockAreaTitleBarPrivate { CDockAreaTitleBar* _this; - QPointer TabsMenuButton; - QPointer AutoHideButton; - QPointer UndockButton; - QPointer CloseButton; + QPointer TabsMenuButton; + QPointer AutoHideButton; + QPointer UndockButton; + QPointer CloseButton; QBoxLayout* Layout; CDockAreaWidget* DockArea; CDockAreaTabBar* TabBar; @@ -540,7 +540,7 @@ void CDockAreaTitleBar::onAutoHideToActionClicked() //============================================================================ -QAbstractButton* CDockAreaTitleBar::button(TitleBarButton which) const +CTitleBarButton* CDockAreaTitleBar::button(TitleBarButton which) const { switch (which) { @@ -805,9 +805,9 @@ QString CDockAreaTitleBar::titleBarButtonToolTip(TitleBarButton Button) const } //============================================================================ -CTitleBarButton::CTitleBarButton(bool visible, QWidget* parent) +CTitleBarButton::CTitleBarButton(bool showInTitleBar, QWidget* parent) : tTitleBarButton(parent), - Visible(visible), + ShowInTitleBar(showInTitleBar), HideWhenDisabled(CDockManager::testConfigFlag(CDockManager::DockAreaHideDisabledButtons)) { setFocusPolicy(Qt::NoFocus); @@ -817,7 +817,7 @@ CTitleBarButton::CTitleBarButton(bool visible, QWidget* parent) void CTitleBarButton::setVisible(bool visible) { // 'visible' can stay 'true' if and only if this button is configured to generaly visible: - visible = visible && this->Visible; + visible = visible && this->ShowInTitleBar; // 'visible' can stay 'true' unless: this button is configured to be invisible when it is disabled and it is currently disabled: if (visible && HideWhenDisabled) @@ -828,6 +828,18 @@ void CTitleBarButton::setVisible(bool visible) Super::setVisible(visible); } + +//============================================================================ +void CTitleBarButton::setShowInTitleBar(bool Show) +{ + this->ShowInTitleBar = Show; + if (!Show) + { + setVisible(false); + } +} + + //============================================================================ bool CTitleBarButton::event(QEvent *ev) { diff --git a/src/DockAreaTitleBar.h b/src/DockAreaTitleBar.h index 76987a4..46ac231 100644 --- a/src/DockAreaTitleBar.h +++ b/src/DockAreaTitleBar.h @@ -30,6 +30,7 @@ //============================================================================ // INCLUDES //============================================================================ +#include #include #include "ads_globals.h" @@ -43,6 +44,44 @@ class CDockAreaWidget; struct DockAreaTitleBarPrivate; class CElidingLabel; +using tTitleBarButton = QToolButton; + +/** +* Title bar button of a dock area that customizes tTitleBarButton appearance/behaviour +* according to various config flags such as: +* CDockManager::DockAreaHas_xxx_Button - if set to 'false' keeps the button always invisible +* CDockManager::DockAreaHideDisabledButtons - if set to 'true' hides button when it is disabled +*/ +class CTitleBarButton : public tTitleBarButton +{ + Q_OBJECT + +private: + bool ShowInTitleBar = true; + bool HideWhenDisabled = false; + +public: + using Super = tTitleBarButton; + CTitleBarButton(bool ShowInTitleBar = true, QWidget* parent = nullptr); + + /** + * Adjust this visibility change request with our internal settings: + */ + virtual void setVisible(bool visible) override; + + /** + * Configures, if the title bar button should be shown in title bar + */ + void setShowInTitleBar(bool Show); + +protected: + /** + * Handle EnabledChanged signal to set button invisible if the configured + */ + bool event(QEvent *ev) override; +}; + + /** * Title bar of a dock area. * The title bar contains a tabbar with all tabs for a dock widget group and @@ -121,7 +160,7 @@ public: /** * Returns the button corresponding to the given title bar button identifier */ - QAbstractButton* button(TitleBarButton which) const; + CTitleBarButton* button(TitleBarButton which) const; /** * Returns the auto hide title label, used when the dock area is expanded and auto hidden diff --git a/src/DockAreaTitleBar_p.h b/src/DockAreaTitleBar_p.h index b94a510..599c45f 100644 --- a/src/DockAreaTitleBar_p.h +++ b/src/DockAreaTitleBar_p.h @@ -31,43 +31,12 @@ // INCLUDES //============================================================================ #include -#include #include "ads_globals.h" namespace ads { -using tTitleBarButton = QToolButton; -/** -* Title bar button of a dock area that customizes tTitleBarButton appearance/behaviour -* according to various config flags such as: -* CDockManager::DockAreaHas_xxx_Button - if set to 'false' keeps the button always invisible -* CDockManager::DockAreaHideDisabledButtons - if set to 'true' hides button when it is disabled -*/ -class CTitleBarButton : public tTitleBarButton -{ - Q_OBJECT - -private: - bool Visible = true; - bool HideWhenDisabled = false; - -public: - using Super = tTitleBarButton; - CTitleBarButton(bool visible = true, QWidget* parent = nullptr); - - /** - * Adjust this visibility change request with our internal settings: - */ - virtual void setVisible(bool visible) override; - -protected: - /** - * Handle EnabledChanged signal to set button invisible if the configured - */ - bool event(QEvent *ev) override; -}; /** diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index 95309c6..29186a2 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -467,6 +467,7 @@ void CDockAreaWidget::setAutoHideDockContainer(CAutoHideDockContainer* AutoHideD d->AutoHideDockContainer = AutoHideDockContainer; updateAutoHideButtonCheckState(); updateTitleBarButtonsToolTips(); + d->TitleBar->button(TitleBarButtonAutoHide)->setShowInTitleBar(true); }