mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-13 00:30:25 +08:00
Merge branch 'auto_hide_feature_original_f' into auto_hide_feature
This commit is contained in:
commit
8974b1a299
@ -653,7 +653,7 @@ CMainWindow::CMainWindow(QWidget *parent) :
|
||||
//CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true);
|
||||
|
||||
// uncomment if you would like to enable dock widget auto hiding
|
||||
// CDockManager::setConfigFlag(CDockManager::DefaultAutoHideConfig, true);
|
||||
CDockManager::setConfigFlag(CDockManager::DefaultAutoHideConfig, true);
|
||||
|
||||
// uncomment if you would like to enable an equal distribution of the
|
||||
// available size of a splitter to all contained dock widgets
|
||||
|
@ -453,6 +453,7 @@ void CAutoHideDockContainer::toggleCollapseState()
|
||||
collapseView(isVisible());
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
|
||||
{
|
||||
|
@ -191,7 +191,8 @@ void DockAreaTitleBarPrivate::createButtons()
|
||||
_this->connect(UndockButton, SIGNAL(clicked()), SLOT(onUndockButtonClicked()));
|
||||
|
||||
// AutoHide Button
|
||||
AutoHideButton = new CTitleBarButton(testConfigFlag(CDockManager::DockAreaHasAutoHideButton));
|
||||
const auto autoHideEnabled = testConfigFlag(CDockManager::AutoHideFeatureEnabled);
|
||||
AutoHideButton = new CTitleBarButton(testConfigFlag(CDockManager::DockAreaHasAutoHideButton) && autoHideEnabled);
|
||||
AutoHideButton->setObjectName("dockAreaAutoHideButton");
|
||||
AutoHideButton->setAutoRaise(true);
|
||||
internal::setToolTip(AutoHideButton, QObject::tr("Toggle Auto Hide"));
|
||||
|
@ -1048,6 +1048,11 @@ bool DockContainerWidgetPrivate::restoreAutoHideDockArea(CDockingStateReader& s,
|
||||
ADS_PRINT("Restore NodeDockArea Tabs: " << Tabs << " Current: "
|
||||
<< CurrentDockWidget);
|
||||
|
||||
if (!CDockManager::testConfigFlag(CDockManager::AutoHideFeatureEnabled))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CDockAreaWidget* DockArea = nullptr;
|
||||
CAutoHideDockContainer* dockContainer = nullptr;
|
||||
if (!Testing)
|
||||
@ -1447,7 +1452,10 @@ CDockContainerWidget::CDockContainerWidget(CDockManager* DockManager, QWidget *p
|
||||
{
|
||||
d->DockManager->registerDockContainer(this);
|
||||
createRootSplitter();
|
||||
createSideTabBarWidgets();
|
||||
if (CDockManager::testConfigFlag(CDockManager::AutoHideFeatureEnabled))
|
||||
{
|
||||
createSideTabBarWidgets();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1498,6 +1506,12 @@ CAutoHideDockContainer* CDockContainerWidget::createAndInitializeAutoHideDockWid
|
||||
{
|
||||
DockWidget->setDockManager(d->DockManager); // Overlay Dock Container needs a valid dock manager
|
||||
}
|
||||
if (!CDockManager::testConfigFlag(CDockManager::AutoHideFeatureEnabled))
|
||||
{
|
||||
Q_ASSERT_X(false, "CDockContainerWidget::createAndInitializeDockWidgetOverlayContainer",
|
||||
"Requested area does not exist in config");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DockWidget->sideTabWidget()->updateOrientationAndSpacing(area);
|
||||
sideTabBar(area)->insertSideTab(insertOrder == CDockWidget::First ? 0 : -1, DockWidget->sideTabWidget());
|
||||
@ -2083,17 +2097,31 @@ void CDockContainerWidget::createRootSplitter()
|
||||
//============================================================================
|
||||
void CDockContainerWidget::createSideTabBarWidgets()
|
||||
{
|
||||
d->SideTabBarWidgets[CDockWidgetSideTab::Left] = new CSideTabBar(this, Qt::Vertical);
|
||||
d->Layout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Left], 1, 0);
|
||||
|
||||
d->SideTabBarWidgets[CDockWidgetSideTab::Right] = new CSideTabBar(this, Qt::Vertical);
|
||||
d->Layout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Right],1,2);
|
||||
{
|
||||
auto leftLayout = new QVBoxLayout();
|
||||
d->SideTabBarWidgets[CDockWidgetSideTab::Left] = new CSideTabBar(this, Qt::Vertical);
|
||||
leftLayout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Left]);
|
||||
leftLayout->addStretch(1);
|
||||
d->Layout->addLayout(leftLayout, 1, 0);
|
||||
}
|
||||
|
||||
d->SideTabBarWidgets[CDockWidgetSideTab::Bottom] = new CSideTabBar(this, Qt::Horizontal);
|
||||
d->Layout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Bottom], 2, 1);
|
||||
{
|
||||
auto rightLayout = new QVBoxLayout();
|
||||
d->SideTabBarWidgets[CDockWidgetSideTab::Right] = new CSideTabBar(this, Qt::Vertical);
|
||||
rightLayout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Right]);
|
||||
rightLayout->addStretch(1);
|
||||
d->Layout->addLayout(rightLayout, 1, 2);
|
||||
}
|
||||
|
||||
d->SideTabBarWidgets[CDockWidgetSideTab::Top] = new CSideTabBar(this, Qt::Horizontal);
|
||||
d->Layout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Top], 0, 1);
|
||||
{
|
||||
d->SideTabBarWidgets[CDockWidgetSideTab::Bottom] = new CSideTabBar(this, Qt::Horizontal);
|
||||
d->Layout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Bottom], 2, 1);
|
||||
}
|
||||
|
||||
{
|
||||
d->SideTabBarWidgets[CDockWidgetSideTab::Top] = new CSideTabBar(this, Qt::Horizontal);
|
||||
d->Layout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Top], 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -226,16 +226,18 @@ public:
|
||||
|
||||
enum eAutoHideFlag
|
||||
{
|
||||
DockAreaHasAutoHideButton = 0x01, //!< If the flag is set each dock area has a auto hide menu button
|
||||
LeftSideBarPrioritizeIconOnly = 0x02, //!< If the flag is set left side bar will prioritize showing icons only over text
|
||||
RightSideBarPrioritizeIconOnly = 0x04, //!< If the flag is set right side bar will prioritize showing icons only over text
|
||||
BottomSideBarPrioritizeIconOnly = 0x08,//!< If the flag is set bottom side bar will prioritize showing icons only over text
|
||||
TopSideBarPrioritizeIconOnly = 0x10, //!< If the flag is set top side bar will prioritize showing icons only over text
|
||||
AutoHideDockAreaHasTitle = 0x20, //!< If the flag is set overlay dock area title bar will show the window title
|
||||
AutoHideButtonTogglesArea = 0x40, //!< If the flag is set, the auto hide button enables auto hiding for all dock widgets in an area, if disabled, only the current dock widget will be toggled
|
||||
AutoHideFeatureEnabled = 0x01,
|
||||
DockAreaHasAutoHideButton = 0x02, //!< If the flag is set each dock area has a auto hide menu button
|
||||
LeftSideBarPrioritizeIconOnly = 0x04, //!< If the flag is set left side bar will prioritize showing icons only over text
|
||||
RightSideBarPrioritizeIconOnly = 0x08, //!< If the flag is set right side bar will prioritize showing icons only over text
|
||||
BottomSideBarPrioritizeIconOnly = 0x10,//!< If the flag is set bottom side bar will prioritize showing icons only over text
|
||||
TopSideBarPrioritizeIconOnly = 0x20, //!< If the flag is set top side bar will prioritize showing icons only over text
|
||||
AutoHideDockAreaHasTitle = 0x40, //!< If the flag is set overlay dock area title bar will show the window title
|
||||
AutoHideButtonTogglesArea = 0x80, //!< If the flag is set, the auto hide button enables auto hiding for all dock widgets in an area, if disabled, only the current dock widget will be toggled
|
||||
AutoHideButtonCheckable = 0x80, //!< If the flag is set, the auto hide button will be checked and unchecked depending on the auto hide state. Mainly for styling purposes.
|
||||
|
||||
DefaultAutoHideConfig = DockAreaHasAutoHideButton
|
||||
DefaultAutoHideConfig = AutoHideFeatureEnabled
|
||||
| DockAreaHasAutoHideButton
|
||||
| AutoHideDockAreaHasTitle, ///< the default configuration for left and right side bars
|
||||
};
|
||||
Q_DECLARE_FLAGS(AutoHideFlags, eAutoHideFlag)
|
||||
|
@ -326,7 +326,7 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) :
|
||||
d->TabWidget = componentsFactory()->createDockWidgetTab(this);
|
||||
d->SideTabWidget = componentsFactory()->createDockWidgetSideTab(this);
|
||||
|
||||
connect(d->SideTabWidget, &CDockWidgetSideTab::clicked, this, &CDockWidget::onDockWidgetSideTabClicked);
|
||||
connect(d->SideTabWidget, &CDockWidgetSideTab::pressed, this, &CDockWidget::onDockWidgetSideTabClicked);
|
||||
|
||||
d->ToggleViewAction = new QAction(title, this);
|
||||
d->ToggleViewAction->setCheckable(true);
|
||||
|
@ -51,68 +51,13 @@ struct DockWidgetSideTabPrivate
|
||||
{
|
||||
CDockWidgetSideTab* _this;
|
||||
CDockWidget* DockWidget;
|
||||
tTabLabel* TitleLabel;
|
||||
QBoxLayout* Layout;
|
||||
QBoxLayout* TitleLayout; // To have independent spacing from the icon
|
||||
CSideTabBar* SideTabBar;
|
||||
QSize IconSize;
|
||||
Qt::Orientation Orientation{Qt::Vertical};
|
||||
SideTabIconLabel* IconLabel = nullptr;
|
||||
QIcon Icon;
|
||||
|
||||
/**
|
||||
* Private data constructor
|
||||
*/
|
||||
DockWidgetSideTabPrivate(CDockWidgetSideTab* _public);
|
||||
|
||||
/**
|
||||
* Creates the complete layout
|
||||
*/
|
||||
void createLayout();
|
||||
|
||||
/**
|
||||
* Update the icon in case the icon size changed
|
||||
*/
|
||||
void updateIcon()
|
||||
{
|
||||
if (!IconLabel || Icon.isNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IconSize.isValid())
|
||||
{
|
||||
IconLabel->setPixmap(Icon.pixmap(IconSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
IconLabel->setPixmap(Icon.pixmap(_this->style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, _this)));
|
||||
}
|
||||
IconLabel->setVisible(true);
|
||||
}
|
||||
|
||||
void updateContentsMargins()
|
||||
{
|
||||
QFontMetrics fm(TitleLabel->font());
|
||||
int Spacing = qRound(fm.height() / 2.0);
|
||||
|
||||
if (Orientation == Qt::Vertical)
|
||||
{
|
||||
TitleLayout->setContentsMargins(Spacing, Spacing, 0, Spacing);
|
||||
if (IconLabel)
|
||||
{
|
||||
IconLabel->setContentsMargins(Spacing / 2, Spacing / 2, Spacing / 2, 0);
|
||||
}
|
||||
}
|
||||
else if (Orientation == Qt::Horizontal)
|
||||
{
|
||||
TitleLayout->setContentsMargins(Spacing / 2, Spacing, Spacing, Spacing / 2);
|
||||
if (IconLabel)
|
||||
{
|
||||
IconLabel->setContentsMargins(Spacing / 2, Spacing / 2, 0, Spacing / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}; // struct DockWidgetTabPrivate
|
||||
|
||||
|
||||
@ -123,45 +68,6 @@ DockWidgetSideTabPrivate::DockWidgetSideTabPrivate(CDockWidgetSideTab* _public)
|
||||
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void DockWidgetSideTabPrivate::createLayout()
|
||||
{
|
||||
TitleLabel = new tTabLabel();
|
||||
TitleLabel->setElideMode(Qt::ElideRight);
|
||||
TitleLabel->setText(DockWidget->windowTitle());
|
||||
TitleLabel->setObjectName("dockWidgetTabLabel");
|
||||
_this->connect(TitleLabel, SIGNAL(elidedChanged(bool)), SIGNAL(elidedChanged(bool)));
|
||||
|
||||
// Fill the layout
|
||||
// Purely for spacing on the text without messing up spacing on the icon
|
||||
TitleLayout = new QBoxLayout(QBoxLayout::TopToBottom);
|
||||
TitleLayout->setAlignment(Qt::AlignCenter);
|
||||
TitleLayout->addWidget(TitleLabel);
|
||||
TitleLayout->setSpacing(0);
|
||||
|
||||
Layout = new QBoxLayout(QBoxLayout::TopToBottom);
|
||||
Layout->setAlignment(Qt::AlignCenter);
|
||||
Layout->setContentsMargins(0,0,0,0);
|
||||
Layout->setSpacing(0);
|
||||
_this->setLayout(Layout);
|
||||
Layout->addLayout(TitleLayout);
|
||||
|
||||
updateContentsMargins();
|
||||
|
||||
TitleLabel->setVisible(true);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void CDockWidgetSideTab::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
emit clicked();
|
||||
}
|
||||
|
||||
QFrame::mousePressEvent(event);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockWidgetSideTab::setSideTabBar(CSideTabBar* SideTabBar)
|
||||
@ -183,13 +89,14 @@ void CDockWidgetSideTab::removeFromSideTabBar()
|
||||
|
||||
//============================================================================
|
||||
CDockWidgetSideTab::CDockWidgetSideTab(CDockWidget* DockWidget, QWidget* parent) :
|
||||
QFrame(parent),
|
||||
Super(parent),
|
||||
d(new DockWidgetSideTabPrivate(this))
|
||||
{
|
||||
setAttribute(Qt::WA_NoMousePropagation);
|
||||
d->DockWidget = DockWidget;
|
||||
d->createLayout();
|
||||
setText(DockWidget->windowTitle());
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
setFlat(true);
|
||||
}
|
||||
|
||||
|
||||
@ -219,56 +126,12 @@ CDockWidgetSideTab::SideTabBarArea CDockWidgetSideTab::sideTabBarArea() const
|
||||
return Left;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockWidgetSideTab::setIcon(const QIcon& Icon)
|
||||
{
|
||||
QBoxLayout* Layout = qobject_cast<QBoxLayout*>(layout());
|
||||
if (!d->IconLabel && Icon.isNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!d->IconLabel)
|
||||
{
|
||||
d->IconLabel = new SideTabIconLabel();
|
||||
internal::setToolTip(d->IconLabel, d->TitleLabel->toolTip());
|
||||
Layout->insertWidget(0, d->IconLabel, Qt::AlignHCenter);
|
||||
}
|
||||
else if (Icon.isNull())
|
||||
{
|
||||
// Remove icon label
|
||||
Layout->removeWidget(d->IconLabel);
|
||||
delete d->IconLabel;
|
||||
d->IconLabel = nullptr;
|
||||
}
|
||||
|
||||
d->Icon = Icon;
|
||||
d->updateIcon();
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
QSize CDockWidgetSideTab::iconSize() const
|
||||
{
|
||||
return d->IconSize;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockWidgetSideTab::setIconSize(const QSize& Size)
|
||||
{
|
||||
d->IconSize = Size;
|
||||
d->updateIcon();
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockWidgetSideTab::setOrientation(Qt::Orientation Orientation)
|
||||
{
|
||||
d->Orientation = Orientation;
|
||||
d->Layout->setDirection(Orientation == Qt::Vertical ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight);
|
||||
d->TitleLabel->setOrientation(Orientation);
|
||||
CPushButton::setOrientation((Qt::Horizontal == Orientation)
|
||||
? CPushButton::Horizontal : CPushButton::VerticalTopToBottom);
|
||||
updateStyle();
|
||||
}
|
||||
|
||||
@ -278,18 +141,7 @@ void CDockWidgetSideTab::updateOrientationAndSpacing(SideTabBarArea area)
|
||||
{
|
||||
setOrientation((area == Bottom || area == Top) ? Qt::Horizontal : Qt::Vertical);
|
||||
|
||||
d->updateContentsMargins();
|
||||
|
||||
// Handle Icon changes
|
||||
if (d->Icon.isNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QFontMetrics fm(d->TitleLabel->font());
|
||||
int Spacing = qRound(fm.height() / 2.0);
|
||||
|
||||
if (CDockManager::testConfigFlag(CDockManager::LeftSideBarPrioritizeIconOnly) && area == Left)
|
||||
/*if (CDockManager::testConfigFlag(CDockManager::LeftSideBarPrioritizeIconOnly) && area == Left)
|
||||
{
|
||||
d->TitleLabel->hide();
|
||||
d->TitleLayout->setContentsMargins(0, 0, 0, 0);
|
||||
@ -316,9 +168,7 @@ void CDockWidgetSideTab::updateOrientationAndSpacing(SideTabBarArea area)
|
||||
d->TitleLayout->setContentsMargins(0, 0, 0, 0);
|
||||
d->IconLabel->setContentsMargins(Spacing / 2, Spacing / 2, Spacing / 2, Spacing / 2);
|
||||
return;
|
||||
}
|
||||
|
||||
d->TitleLabel->show();
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
@ -340,55 +190,4 @@ CDockWidget* CDockWidgetSideTab::dockWidget() const
|
||||
return d->DockWidget;
|
||||
}
|
||||
|
||||
/**
|
||||
* Private data class of SideTabIcon class (pimpl)
|
||||
*/
|
||||
struct SideTabIconLabelPrivate
|
||||
{
|
||||
SideTabIconLabel* _this;
|
||||
QLabel* IconLabel;
|
||||
QBoxLayout* Layout;
|
||||
|
||||
SideTabIconLabelPrivate(SideTabIconLabel* _public);
|
||||
}; // struct SideTabIconLabelPrivate
|
||||
|
||||
|
||||
//============================================================================
|
||||
SideTabIconLabelPrivate::SideTabIconLabelPrivate(SideTabIconLabel* _public) :
|
||||
_this(_public)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
SideTabIconLabel::SideTabIconLabel(QWidget* parent) : QWidget(parent),
|
||||
d(new SideTabIconLabelPrivate(this))
|
||||
{
|
||||
d->Layout = new QBoxLayout(QBoxLayout::TopToBottom);
|
||||
d->Layout->addWidget(d->IconLabel = new QLabel());
|
||||
d->Layout->setAlignment(Qt::AlignCenter);
|
||||
d->IconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
||||
setLayout(d->Layout);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
SideTabIconLabel::~SideTabIconLabel()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void SideTabIconLabel::setPixmap(const QPixmap& pixmap)
|
||||
{
|
||||
d->IconLabel->setPixmap(pixmap);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void SideTabIconLabel::setContentsMargins(int left, int top, int right, int bottom)
|
||||
{
|
||||
d->Layout->setContentsMargins(left, top, right, bottom);
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
//============================================================================
|
||||
// INCLUDES
|
||||
//============================================================================
|
||||
#include <QFrame>
|
||||
#include "PushButton.h"
|
||||
|
||||
#include "ads_globals.h"
|
||||
|
||||
@ -46,12 +46,11 @@ struct SideTabIconLabelPrivate;
|
||||
* The dock widget tab is shown in the side tab bar to switch between
|
||||
* pinned dock widgets
|
||||
*/
|
||||
class ADS_EXPORT CDockWidgetSideTab : public QFrame
|
||||
class ADS_EXPORT CDockWidgetSideTab : public CPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(SideTabBarArea sideTabBarArea READ sideTabBarArea)
|
||||
Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
|
||||
Q_PROPERTY(bool activeTab READ isActiveTab)
|
||||
|
||||
private:
|
||||
@ -65,13 +64,11 @@ protected:
|
||||
friend class CDockAreaWidget;
|
||||
friend class CDockContainerWidget;
|
||||
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
|
||||
void setSideTabBar(CSideTabBar *SideTabBar);
|
||||
void removeFromSideTabBar();
|
||||
|
||||
public:
|
||||
using Super = QFrame;
|
||||
using Super = CPushButton;
|
||||
|
||||
/**
|
||||
* Dock widget side tab bar locations
|
||||
@ -108,25 +105,6 @@ public:
|
||||
*/
|
||||
SideTabBarArea sideTabBarArea() const;
|
||||
|
||||
/**
|
||||
* Sets the icon to show in title bar
|
||||
*/
|
||||
void setIcon(const QIcon& Icon);
|
||||
|
||||
/**
|
||||
* Returns the icon size.
|
||||
* If no explicit icon size has been set, the function returns an invalid
|
||||
* QSize
|
||||
*/
|
||||
QSize iconSize() const;
|
||||
|
||||
/**
|
||||
* Set an explicit icon size.
|
||||
* If no icon size has been set explicitly, than the tab sets the icon size
|
||||
* depending on the style
|
||||
*/
|
||||
void setIconSize(const QSize& Size);
|
||||
|
||||
/**
|
||||
* Set orientation vertical or horizontal
|
||||
*/
|
||||
@ -149,21 +127,7 @@ public:
|
||||
|
||||
Q_SIGNALS:
|
||||
void elidedChanged(bool elided);
|
||||
void clicked();
|
||||
}; // class DockWidgetSideTab
|
||||
|
||||
class SideTabIconLabel : public QWidget
|
||||
{
|
||||
private:
|
||||
SideTabIconLabelPrivate *d; ///< private data (pimpl)
|
||||
|
||||
public:
|
||||
SideTabIconLabel(QWidget* parent = nullptr);
|
||||
virtual ~SideTabIconLabel();
|
||||
|
||||
void setPixmap(const QPixmap &pixmap);
|
||||
void setContentsMargins(int left, int top, int right, int bottom);
|
||||
}; // class SideTabIconLabel
|
||||
}
|
||||
// namespace ads
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -124,7 +124,7 @@ public:
|
||||
void setOrientation(Qt::Orientation orientation);
|
||||
}; // class CVerticalElidingLabel
|
||||
|
||||
} // namespace QtLabb
|
||||
} // namespace ads
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
#endif // ElidingLabelH
|
||||
|
69
src/PushButton.cpp
Normal file
69
src/PushButton.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
//============================================================================
|
||||
/// \file PushButton.cpp
|
||||
/// \author Uwe Kindler
|
||||
/// \date 18.10.2022
|
||||
/// \brief Implementation of CPushButton
|
||||
//============================================================================
|
||||
|
||||
//============================================================================
|
||||
// INCLUDES
|
||||
//============================================================================
|
||||
#include "PushButton.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QStyleOptionButton>
|
||||
#include <QDebug>
|
||||
#include <QStylePainter>
|
||||
|
||||
|
||||
namespace ads
|
||||
{
|
||||
QSize CPushButton::sizeHint() const
|
||||
{
|
||||
QSize sh = QPushButton::sizeHint();
|
||||
|
||||
if (m_Orientation != CPushButton::Horizontal)
|
||||
{
|
||||
sh.transpose();
|
||||
}
|
||||
|
||||
return sh;
|
||||
}
|
||||
|
||||
void CPushButton::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
QStylePainter painter(this);
|
||||
QStyleOptionButton option;
|
||||
initStyleOption(&option);
|
||||
|
||||
if (m_Orientation == CPushButton::VerticalTopToBottom)
|
||||
{
|
||||
painter.rotate(90);
|
||||
painter.translate(0, -1 * width());
|
||||
option.rect = option.rect.transposed();
|
||||
}
|
||||
else if (m_Orientation == CPushButton::VerticalBottomToTop)
|
||||
{
|
||||
painter.rotate(-90);
|
||||
painter.translate(-1 * height(), 0);
|
||||
option.rect = option.rect.transposed();
|
||||
}
|
||||
|
||||
painter.drawControl(QStyle::CE_PushButton, option);
|
||||
}
|
||||
|
||||
CPushButton::Orientation CPushButton::orientation() const
|
||||
{
|
||||
return m_Orientation;
|
||||
}
|
||||
|
||||
void CPushButton::setOrientation(Orientation orientation)
|
||||
{
|
||||
m_Orientation = orientation;
|
||||
}
|
||||
} // namespace ads
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// EOF PushButton.cpp
|
49
src/PushButton.h
Normal file
49
src/PushButton.h
Normal file
@ -0,0 +1,49 @@
|
||||
#ifndef PushButtonH
|
||||
#define PushButtonH
|
||||
//============================================================================
|
||||
/// \file PushButton.h
|
||||
/// \author Uwe Kindler
|
||||
/// \date 18.10.2022
|
||||
/// \brief Declaration of CPushButton
|
||||
//============================================================================
|
||||
|
||||
//============================================================================
|
||||
// INCLUDES
|
||||
//============================================================================
|
||||
#include <QPushButton>
|
||||
|
||||
namespace ads
|
||||
{
|
||||
|
||||
/**
|
||||
* ADS specific push button class
|
||||
*/
|
||||
class CPushButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Orientation {
|
||||
Horizontal,
|
||||
VerticalTopToBottom,
|
||||
VerticalBottomToTop
|
||||
};
|
||||
|
||||
using QPushButton::QPushButton;
|
||||
|
||||
virtual QSize sizeHint() const override;
|
||||
|
||||
Orientation orientation() const;
|
||||
void setOrientation(Orientation orientation);
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
private:
|
||||
Orientation m_Orientation = Horizontal;
|
||||
};
|
||||
|
||||
} // namespace ads
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
#endif // PushButtonH
|
||||
|
@ -50,7 +50,8 @@ HEADERS += \
|
||||
DockFocusController.h \
|
||||
AutoHideDockContainer.h \
|
||||
SideTabBar.h \
|
||||
DockWidgetSideTab.h
|
||||
DockWidgetSideTab.h \
|
||||
PushButton.h
|
||||
|
||||
|
||||
SOURCES += \
|
||||
@ -73,7 +74,8 @@ SOURCES += \
|
||||
DockFocusController.cpp \
|
||||
AutoHideDockContainer.cpp \
|
||||
SideTabBar.cpp \
|
||||
DockWidgetSideTab.cpp
|
||||
DockWidgetSideTab.cpp \
|
||||
PushButton.cpp
|
||||
|
||||
|
||||
unix:!macx {
|
||||
|
@ -2,168 +2,170 @@
|
||||
* Default style sheet on Windows Platforms
|
||||
*/
|
||||
ads--CDockContainerWidget {
|
||||
background: palette(window);
|
||||
background: palette(window);
|
||||
}
|
||||
ads--CDockContainerWidget > QSplitter{
|
||||
padding: 1 0 1 0;
|
||||
ads--CDockContainerWidget > QSplitter {
|
||||
padding: 1 0 1 0;
|
||||
}
|
||||
|
||||
ads--CDockContainerWidget ads--CDockSplitter::handle {
|
||||
background: palette(dark);
|
||||
background: palette(dark);
|
||||
}
|
||||
|
||||
ads--CDockAreaWidget {
|
||||
background: palette(window);
|
||||
border: 1px solid white;
|
||||
background: palette(window);
|
||||
border: 1px solid white;
|
||||
}
|
||||
|
||||
|
||||
ads--CDockWidgetTab {
|
||||
background: palette(window);
|
||||
border-color: palette(light);
|
||||
border-style: solid;
|
||||
border-width: 0 1px 0 0;
|
||||
padding: 0 0px;
|
||||
background: palette(window);
|
||||
border-color: palette(light);
|
||||
border-style: solid;
|
||||
border-width: 0 1px 0 0;
|
||||
padding: 0 0px;
|
||||
}
|
||||
|
||||
ads--CDockWidgetTab[activeTab="true"] {
|
||||
background: qlineargradient(spread : pad, x1 : 0, y1 : 0, x2 : 0, y2 : 0.5, stop : 0
|
||||
palette(window), stop:1 palette(light));
|
||||
/*background: palette(highlight);*/
|
||||
background: qlineargradient(
|
||||
spread: pad,
|
||||
x1: 0,
|
||||
y1: 0,
|
||||
x2: 0,
|
||||
y2: 0.5,
|
||||
stop: 0 palette(window),
|
||||
stop: 1 palette(light)
|
||||
);
|
||||
/*background: palette(highlight);*/
|
||||
}
|
||||
|
||||
ads--CDockWidgetTab QLabel {
|
||||
color: palette(dark);
|
||||
color: palette(dark);
|
||||
}
|
||||
|
||||
ads--CDockWidgetTab[activeTab="true"] QLabel {
|
||||
color: palette(foreground);
|
||||
color: palette(foreground);
|
||||
}
|
||||
|
||||
|
||||
ads--CDockWidget {
|
||||
background: palette(light);
|
||||
border-color: palette(light);
|
||||
border-style: solid;
|
||||
border-width: 1px 0 0 0;
|
||||
background: palette(light);
|
||||
border-color: palette(light);
|
||||
border-style: solid;
|
||||
border-width: 1px 0 0 0;
|
||||
}
|
||||
|
||||
ads--CTitleBarButton {
|
||||
padding: 0px 0px;
|
||||
padding: 0px 0px;
|
||||
}
|
||||
|
||||
QScrollArea#dockWidgetScrollArea {
|
||||
padding: 0px;
|
||||
border: none;
|
||||
padding: 0px;
|
||||
border: none;
|
||||
}
|
||||
|
||||
#dockAreaAutoHideButton {
|
||||
qproperty-icon: url(:/ads/images/vs-pin-button.svg);
|
||||
qproperty-iconSize: 16px;
|
||||
qproperty-icon: url(:/ads/images/vs-pin-button.svg);
|
||||
qproperty-iconsize: 16px;
|
||||
}
|
||||
|
||||
|
||||
#tabCloseButton {
|
||||
margin-top: 2px;
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0px -2px;
|
||||
qproperty-icon: url(:/ads/images/close-button.svg),
|
||||
url(:/ads/images/close-button-disabled.svg) disabled;
|
||||
qproperty-iconSize: 16px;
|
||||
margin-top: 2px;
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0px -2px;
|
||||
qproperty-icon: url(:/ads/images/close-button.svg),
|
||||
url(:/ads/images/close-button-disabled.svg) disabled;
|
||||
qproperty-iconsize: 16px;
|
||||
}
|
||||
|
||||
#tabCloseButton:hover {
|
||||
border: 1px solid rgba(0, 0, 0, 32);
|
||||
background: rgba(0, 0, 0, 16);
|
||||
border: 1px solid rgba(0, 0, 0, 32);
|
||||
background: rgba(0, 0, 0, 16);
|
||||
}
|
||||
|
||||
#tabCloseButton:pressed {
|
||||
background: rgba(0, 0, 0, 32);
|
||||
background: rgba(0, 0, 0, 32);
|
||||
}
|
||||
|
||||
#tabsMenuButton::menu-indicator {
|
||||
image: none;
|
||||
image: none;
|
||||
}
|
||||
|
||||
#tabsMenuButton {
|
||||
qproperty-icon: url(:/ads/images/tabs-menu-button.svg);
|
||||
qproperty-iconSize: 16px;
|
||||
qproperty-icon: url(:/ads/images/tabs-menu-button.svg);
|
||||
qproperty-iconsize: 16px;
|
||||
}
|
||||
|
||||
#dockAreaCloseButton {
|
||||
qproperty-icon: url(:/ads/images/close-button.svg),
|
||||
url(:/ads/images/close-button-disabled.svg) disabled;
|
||||
qproperty-iconSize: 16px;
|
||||
qproperty-icon: url(:/ads/images/close-button.svg),
|
||||
url(:/ads/images/close-button-disabled.svg) disabled;
|
||||
qproperty-iconsize: 16px;
|
||||
}
|
||||
|
||||
#detachGroupButton {
|
||||
qproperty-icon: url(:/ads/images/detach-button.svg),
|
||||
url(:/ads/images/detach-button-disabled.svg) disabled;
|
||||
qproperty-iconSize: 16px;
|
||||
qproperty-icon: url(:/ads/images/detach-button.svg),
|
||||
url(:/ads/images/detach-button-disabled.svg) disabled;
|
||||
qproperty-iconsize: 16px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Styling of auto hide functionality
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
ads--CDockWidgetSideTab {
|
||||
background: palette(window);
|
||||
qproperty-iconSize: 16px 16px;/* this is optional in case you would like to change icon size*/
|
||||
/*background: palette(window);*/
|
||||
qproperty-iconsize: 16px 16px; /* this is optional in case you would like to change icon size*/
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="0"] {
|
||||
border-top: 3px solid grey;
|
||||
border-right: 1px solid white;
|
||||
border-top: 3px solid grey;
|
||||
border-right: 1px solid white;
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="1"] {
|
||||
border-left: 3px solid grey;
|
||||
border-bottom: 1px solid white;
|
||||
border-left: 3px solid grey;
|
||||
border-bottom: 1px solid white;
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="2"] {
|
||||
border-right: 3px solid grey;
|
||||
border-bottom: 1px solid white;
|
||||
border-right: 3px solid grey;
|
||||
border-bottom: 1px solid white;
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="3"] {
|
||||
border-bottom: 3px solid grey;
|
||||
border-right: 1px solid white;
|
||||
border-bottom: 3px solid grey;
|
||||
border-right: 1px solid white;
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab:hover[sideTabBarArea="0"] {
|
||||
border-top: 3px solid palette(highlight);
|
||||
border-top: 3px solid palette(highlight);
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab:hover[sideTabBarArea="1"] {
|
||||
border-left: 3px solid palette(highlight);
|
||||
border-left: 3px solid palette(highlight);
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab:hover[sideTabBarArea="2"] {
|
||||
border-right: 3px solid palette(highlight);
|
||||
border-right: 3px solid palette(highlight);
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab:hover[sideTabBarArea="3"] {
|
||||
border-bottom: 3px solid palette(highlight);
|
||||
border-bottom: 3px solid palette(highlight);
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="0"][activeTab="true"] {
|
||||
border-top: 3px solid palette(highlight);
|
||||
border-top: 3px solid palette(highlight);
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="1"][activeTab="true"] {
|
||||
border-left: 3px solid palette(highlight);
|
||||
border-left: 3px solid palette(highlight);
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="2"][activeTab="true"] {
|
||||
border-right: 3px solid palette(highlight);
|
||||
border-right: 3px solid palette(highlight);
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="3"][activeTab="true"] {
|
||||
border-bottom: 3px solid palette(highlight);
|
||||
border-bottom: 3px solid palette(highlight);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -186,12 +188,11 @@ ads--CAutoHideDockContainer::handle:horizontal {
|
||||
background: white;
|
||||
}*/
|
||||
|
||||
ads--CAutoHideDockContainer #dockAreaAutoHideButton
|
||||
{
|
||||
qproperty-icon: url(:/ads/images/vs-pin-button-pinned.svg);
|
||||
qproperty-iconSize: 16px;
|
||||
ads--CAutoHideDockContainer #dockAreaAutoHideButton {
|
||||
qproperty-icon: url(:/ads/images/vs-pin-button-pinned.svg);
|
||||
qproperty-iconsize: 16px;
|
||||
}
|
||||
|
||||
#autoHideTitleLabel {
|
||||
padding-left: 4px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user