Skip to content

Commit 2760fb1

Browse files
AutoHide dock area now always shows pin button independently from DockAreaHasAutoHideButton flag
1 parent 8a82e4c commit 2760fb1

File tree

4 files changed

+61
-40
lines changed

4 files changed

+61
-40
lines changed

src/DockAreaTitleBar.cpp

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ static const char* const LocationProperty = "Location";
6868
struct DockAreaTitleBarPrivate
6969
{
7070
CDockAreaTitleBar* _this;
71-
QPointer<tTitleBarButton> TabsMenuButton;
72-
QPointer<tTitleBarButton> AutoHideButton;
73-
QPointer<tTitleBarButton> UndockButton;
74-
QPointer<tTitleBarButton> CloseButton;
71+
QPointer<CTitleBarButton> TabsMenuButton;
72+
QPointer<CTitleBarButton> AutoHideButton;
73+
QPointer<CTitleBarButton> UndockButton;
74+
QPointer<CTitleBarButton> CloseButton;
7575
QBoxLayout* Layout;
7676
CDockAreaWidget* DockArea;
7777
CDockAreaTabBar* TabBar;
@@ -540,7 +540,7 @@ void CDockAreaTitleBar::onAutoHideToActionClicked()
540540

541541

542542
//============================================================================
543-
QAbstractButton* CDockAreaTitleBar::button(TitleBarButton which) const
543+
CTitleBarButton* CDockAreaTitleBar::button(TitleBarButton which) const
544544
{
545545
switch (which)
546546
{
@@ -805,9 +805,9 @@ QString CDockAreaTitleBar::titleBarButtonToolTip(TitleBarButton Button) const
805805
}
806806

807807
//============================================================================
808-
CTitleBarButton::CTitleBarButton(bool visible, QWidget* parent)
808+
CTitleBarButton::CTitleBarButton(bool showInTitleBar, QWidget* parent)
809809
: tTitleBarButton(parent),
810-
Visible(visible),
810+
ShowInTitleBar(showInTitleBar),
811811
HideWhenDisabled(CDockManager::testConfigFlag(CDockManager::DockAreaHideDisabledButtons))
812812
{
813813
setFocusPolicy(Qt::NoFocus);
@@ -817,7 +817,7 @@ CTitleBarButton::CTitleBarButton(bool visible, QWidget* parent)
817817
void CTitleBarButton::setVisible(bool visible)
818818
{
819819
// 'visible' can stay 'true' if and only if this button is configured to generaly visible:
820-
visible = visible && this->Visible;
820+
visible = visible && this->ShowInTitleBar;
821821

822822
// 'visible' can stay 'true' unless: this button is configured to be invisible when it is disabled and it is currently disabled:
823823
if (visible && HideWhenDisabled)
@@ -828,6 +828,18 @@ void CTitleBarButton::setVisible(bool visible)
828828
Super::setVisible(visible);
829829
}
830830

831+
832+
//============================================================================
833+
void CTitleBarButton::setShowInTitleBar(bool Show)
834+
{
835+
this->ShowInTitleBar = Show;
836+
if (!Show)
837+
{
838+
setVisible(false);
839+
}
840+
}
841+
842+
831843
//============================================================================
832844
bool CTitleBarButton::event(QEvent *ev)
833845
{

src/DockAreaTitleBar.h

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
//============================================================================
3131
// INCLUDES
3232
//============================================================================
33+
#include <QToolButton>
3334
#include <QFrame>
3435

3536
#include "ads_globals.h"
@@ -43,6 +44,44 @@ class CDockAreaWidget;
4344
struct DockAreaTitleBarPrivate;
4445
class CElidingLabel;
4546

47+
using tTitleBarButton = QToolButton;
48+
49+
/**
50+
* Title bar button of a dock area that customizes tTitleBarButton appearance/behaviour
51+
* according to various config flags such as:
52+
* CDockManager::DockAreaHas_xxx_Button - if set to 'false' keeps the button always invisible
53+
* CDockManager::DockAreaHideDisabledButtons - if set to 'true' hides button when it is disabled
54+
*/
55+
class CTitleBarButton : public tTitleBarButton
56+
{
57+
Q_OBJECT
58+
59+
private:
60+
bool ShowInTitleBar = true;
61+
bool HideWhenDisabled = false;
62+
63+
public:
64+
using Super = tTitleBarButton;
65+
CTitleBarButton(bool ShowInTitleBar = true, QWidget* parent = nullptr);
66+
67+
/**
68+
* Adjust this visibility change request with our internal settings:
69+
*/
70+
virtual void setVisible(bool visible) override;
71+
72+
/**
73+
* Configures, if the title bar button should be shown in title bar
74+
*/
75+
void setShowInTitleBar(bool Show);
76+
77+
protected:
78+
/**
79+
* Handle EnabledChanged signal to set button invisible if the configured
80+
*/
81+
bool event(QEvent *ev) override;
82+
};
83+
84+
4685
/**
4786
* Title bar of a dock area.
4887
* The title bar contains a tabbar with all tabs for a dock widget group and
@@ -121,7 +160,7 @@ public Q_SLOTS:
121160
/**
122161
* Returns the button corresponding to the given title bar button identifier
123162
*/
124-
QAbstractButton* button(TitleBarButton which) const;
163+
CTitleBarButton* button(TitleBarButton which) const;
125164

126165
/**
127166
* Returns the auto hide title label, used when the dock area is expanded and auto hidden

src/DockAreaTitleBar_p.h

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,43 +31,12 @@
3131
// INCLUDES
3232
//============================================================================
3333
#include <QFrame>
34-
#include <QToolButton>
3534

3635
#include "ads_globals.h"
3736

3837
namespace ads
3938
{
40-
using tTitleBarButton = QToolButton;
4139

42-
/**
43-
* Title bar button of a dock area that customizes tTitleBarButton appearance/behaviour
44-
* according to various config flags such as:
45-
* CDockManager::DockAreaHas_xxx_Button - if set to 'false' keeps the button always invisible
46-
* CDockManager::DockAreaHideDisabledButtons - if set to 'true' hides button when it is disabled
47-
*/
48-
class CTitleBarButton : public tTitleBarButton
49-
{
50-
Q_OBJECT
51-
52-
private:
53-
bool Visible = true;
54-
bool HideWhenDisabled = false;
55-
56-
public:
57-
using Super = tTitleBarButton;
58-
CTitleBarButton(bool visible = true, QWidget* parent = nullptr);
59-
60-
/**
61-
* Adjust this visibility change request with our internal settings:
62-
*/
63-
virtual void setVisible(bool visible) override;
64-
65-
protected:
66-
/**
67-
* Handle EnabledChanged signal to set button invisible if the configured
68-
*/
69-
bool event(QEvent *ev) override;
70-
};
7140

7241

7342
/**

src/DockAreaWidget.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ void CDockAreaWidget::setAutoHideDockContainer(CAutoHideDockContainer* AutoHideD
467467
d->AutoHideDockContainer = AutoHideDockContainer;
468468
updateAutoHideButtonCheckState();
469469
updateTitleBarButtonsToolTips();
470+
d->TitleBar->button(TitleBarButtonAutoHide)->setShowInTitleBar(true);
470471
}
471472

472473

0 commit comments

Comments
 (0)