mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 13:15:43 +08:00
AutoHide dock area now always shows pin button independently from DockAreaHasAutoHideButton flag
This commit is contained in:
parent
8a82e4cf57
commit
2760fb1fe9
@ -68,10 +68,10 @@ static const char* const LocationProperty = "Location";
|
||||
struct DockAreaTitleBarPrivate
|
||||
{
|
||||
CDockAreaTitleBar* _this;
|
||||
QPointer<tTitleBarButton> TabsMenuButton;
|
||||
QPointer<tTitleBarButton> AutoHideButton;
|
||||
QPointer<tTitleBarButton> UndockButton;
|
||||
QPointer<tTitleBarButton> CloseButton;
|
||||
QPointer<CTitleBarButton> TabsMenuButton;
|
||||
QPointer<CTitleBarButton> AutoHideButton;
|
||||
QPointer<CTitleBarButton> UndockButton;
|
||||
QPointer<CTitleBarButton> 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)
|
||||
{
|
||||
|
@ -30,6 +30,7 @@
|
||||
//============================================================================
|
||||
// INCLUDES
|
||||
//============================================================================
|
||||
#include <QToolButton>
|
||||
#include <QFrame>
|
||||
|
||||
#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
|
||||
|
@ -31,43 +31,12 @@
|
||||
// INCLUDES
|
||||
//============================================================================
|
||||
#include <QFrame>
|
||||
#include <QToolButton>
|
||||
|
||||
#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;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
@ -467,6 +467,7 @@ void CDockAreaWidget::setAutoHideDockContainer(CAutoHideDockContainer* AutoHideD
|
||||
d->AutoHideDockContainer = AutoHideDockContainer;
|
||||
updateAutoHideButtonCheckState();
|
||||
updateTitleBarButtonsToolTips();
|
||||
d->TitleBar->button(TitleBarButtonAutoHide)->setShowInTitleBar(true);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user