Merge branch 'auto_hide_feature_original_f' into auto_hide_feature

This commit is contained in:
Syarif Fakhri 2022-10-19 17:11:45 +08:00
commit 8974b1a299
13 changed files with 259 additions and 343 deletions

View File

@ -653,7 +653,7 @@ CMainWindow::CMainWindow(QWidget *parent) :
//CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true); //CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true);
// uncomment if you would like to enable dock widget auto hiding // 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 // uncomment if you would like to enable an equal distribution of the
// available size of a splitter to all contained dock widgets // available size of a splitter to all contained dock widgets

View File

@ -453,6 +453,7 @@ void CAutoHideDockContainer::toggleCollapseState()
collapseView(isVisible()); collapseView(isVisible());
} }
//============================================================================ //============================================================================
bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event) bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
{ {

View File

@ -191,7 +191,8 @@ void DockAreaTitleBarPrivate::createButtons()
_this->connect(UndockButton, SIGNAL(clicked()), SLOT(onUndockButtonClicked())); _this->connect(UndockButton, SIGNAL(clicked()), SLOT(onUndockButtonClicked()));
// AutoHide Button // 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->setObjectName("dockAreaAutoHideButton");
AutoHideButton->setAutoRaise(true); AutoHideButton->setAutoRaise(true);
internal::setToolTip(AutoHideButton, QObject::tr("Toggle Auto Hide")); internal::setToolTip(AutoHideButton, QObject::tr("Toggle Auto Hide"));

View File

@ -1048,6 +1048,11 @@ bool DockContainerWidgetPrivate::restoreAutoHideDockArea(CDockingStateReader& s,
ADS_PRINT("Restore NodeDockArea Tabs: " << Tabs << " Current: " ADS_PRINT("Restore NodeDockArea Tabs: " << Tabs << " Current: "
<< CurrentDockWidget); << CurrentDockWidget);
if (!CDockManager::testConfigFlag(CDockManager::AutoHideFeatureEnabled))
{
return false;
}
CDockAreaWidget* DockArea = nullptr; CDockAreaWidget* DockArea = nullptr;
CAutoHideDockContainer* dockContainer = nullptr; CAutoHideDockContainer* dockContainer = nullptr;
if (!Testing) if (!Testing)
@ -1447,7 +1452,10 @@ CDockContainerWidget::CDockContainerWidget(CDockManager* DockManager, QWidget *p
{ {
d->DockManager->registerDockContainer(this); d->DockManager->registerDockContainer(this);
createRootSplitter(); 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 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); DockWidget->sideTabWidget()->updateOrientationAndSpacing(area);
sideTabBar(area)->insertSideTab(insertOrder == CDockWidget::First ? 0 : -1, DockWidget->sideTabWidget()); sideTabBar(area)->insertSideTab(insertOrder == CDockWidget::First ? 0 : -1, DockWidget->sideTabWidget());
@ -2083,17 +2097,31 @@ void CDockContainerWidget::createRootSplitter()
//============================================================================ //============================================================================
void CDockContainerWidget::createSideTabBarWidgets() void CDockContainerWidget::createSideTabBarWidgets()
{ {
d->SideTabBarWidgets[CDockWidgetSideTab::Left] = new CSideTabBar(this, Qt::Vertical); {
d->Layout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Left], 1, 0); auto leftLayout = new QVBoxLayout();
d->SideTabBarWidgets[CDockWidgetSideTab::Left] = new CSideTabBar(this, Qt::Vertical);
d->SideTabBarWidgets[CDockWidgetSideTab::Right] = new CSideTabBar(this, Qt::Vertical); leftLayout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Left]);
d->Layout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Right],1,2); 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);
}
} }

View File

@ -226,16 +226,18 @@ public:
enum eAutoHideFlag enum eAutoHideFlag
{ {
DockAreaHasAutoHideButton = 0x01, //!< If the flag is set each dock area has a auto hide menu button AutoHideFeatureEnabled = 0x01,
LeftSideBarPrioritizeIconOnly = 0x02, //!< If the flag is set left side bar will prioritize showing icons only over text DockAreaHasAutoHideButton = 0x02, //!< If the flag is set each dock area has a auto hide menu button
RightSideBarPrioritizeIconOnly = 0x04, //!< If the flag is set right side bar will prioritize showing icons only over text LeftSideBarPrioritizeIconOnly = 0x04, //!< If the flag is set left 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 RightSideBarPrioritizeIconOnly = 0x08, //!< If the flag is set right 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 BottomSideBarPrioritizeIconOnly = 0x10,//!< If the flag is set bottom 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 TopSideBarPrioritizeIconOnly = 0x20, //!< If the flag is set top side bar will prioritize showing icons only over text
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 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. 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 | AutoHideDockAreaHasTitle, ///< the default configuration for left and right side bars
}; };
Q_DECLARE_FLAGS(AutoHideFlags, eAutoHideFlag) Q_DECLARE_FLAGS(AutoHideFlags, eAutoHideFlag)

View File

@ -326,7 +326,7 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) :
d->TabWidget = componentsFactory()->createDockWidgetTab(this); d->TabWidget = componentsFactory()->createDockWidgetTab(this);
d->SideTabWidget = componentsFactory()->createDockWidgetSideTab(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 = new QAction(title, this);
d->ToggleViewAction->setCheckable(true); d->ToggleViewAction->setCheckable(true);

View File

@ -51,68 +51,13 @@ struct DockWidgetSideTabPrivate
{ {
CDockWidgetSideTab* _this; CDockWidgetSideTab* _this;
CDockWidget* DockWidget; CDockWidget* DockWidget;
tTabLabel* TitleLabel;
QBoxLayout* Layout;
QBoxLayout* TitleLayout; // To have independent spacing from the icon
CSideTabBar* SideTabBar; CSideTabBar* SideTabBar;
QSize IconSize;
Qt::Orientation Orientation{Qt::Vertical}; Qt::Orientation Orientation{Qt::Vertical};
SideTabIconLabel* IconLabel = nullptr;
QIcon Icon;
/** /**
* Private data constructor * Private data constructor
*/ */
DockWidgetSideTabPrivate(CDockWidgetSideTab* _public); 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 }; // 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) void CDockWidgetSideTab::setSideTabBar(CSideTabBar* SideTabBar)
@ -183,13 +89,14 @@ void CDockWidgetSideTab::removeFromSideTabBar()
//============================================================================ //============================================================================
CDockWidgetSideTab::CDockWidgetSideTab(CDockWidget* DockWidget, QWidget* parent) : CDockWidgetSideTab::CDockWidgetSideTab(CDockWidget* DockWidget, QWidget* parent) :
QFrame(parent), Super(parent),
d(new DockWidgetSideTabPrivate(this)) d(new DockWidgetSideTabPrivate(this))
{ {
setAttribute(Qt::WA_NoMousePropagation); setAttribute(Qt::WA_NoMousePropagation);
d->DockWidget = DockWidget; d->DockWidget = DockWidget;
d->createLayout(); setText(DockWidget->windowTitle());
setFocusPolicy(Qt::NoFocus); setFocusPolicy(Qt::NoFocus);
setFlat(true);
} }
@ -219,56 +126,12 @@ CDockWidgetSideTab::SideTabBarArea CDockWidgetSideTab::sideTabBarArea() const
return Left; 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) void CDockWidgetSideTab::setOrientation(Qt::Orientation Orientation)
{ {
d->Orientation = Orientation; d->Orientation = Orientation;
d->Layout->setDirection(Orientation == Qt::Vertical ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight); CPushButton::setOrientation((Qt::Horizontal == Orientation)
d->TitleLabel->setOrientation(Orientation); ? CPushButton::Horizontal : CPushButton::VerticalTopToBottom);
updateStyle(); updateStyle();
} }
@ -278,18 +141,7 @@ void CDockWidgetSideTab::updateOrientationAndSpacing(SideTabBarArea area)
{ {
setOrientation((area == Bottom || area == Top) ? Qt::Horizontal : Qt::Vertical); setOrientation((area == Bottom || area == Top) ? Qt::Horizontal : Qt::Vertical);
d->updateContentsMargins(); /*if (CDockManager::testConfigFlag(CDockManager::LeftSideBarPrioritizeIconOnly) && area == Left)
// 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)
{ {
d->TitleLabel->hide(); d->TitleLabel->hide();
d->TitleLayout->setContentsMargins(0, 0, 0, 0); d->TitleLayout->setContentsMargins(0, 0, 0, 0);
@ -316,9 +168,7 @@ void CDockWidgetSideTab::updateOrientationAndSpacing(SideTabBarArea area)
d->TitleLayout->setContentsMargins(0, 0, 0, 0); d->TitleLayout->setContentsMargins(0, 0, 0, 0);
d->IconLabel->setContentsMargins(Spacing / 2, Spacing / 2, Spacing / 2, Spacing / 2); d->IconLabel->setContentsMargins(Spacing / 2, Spacing / 2, Spacing / 2, Spacing / 2);
return; return;
} }*/
d->TitleLabel->show();
} }
@ -340,55 +190,4 @@ CDockWidget* CDockWidgetSideTab::dockWidget() const
return d->DockWidget; 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);
}
} }

View File

@ -29,7 +29,7 @@
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include <QFrame> #include "PushButton.h"
#include "ads_globals.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 * The dock widget tab is shown in the side tab bar to switch between
* pinned dock widgets * pinned dock widgets
*/ */
class ADS_EXPORT CDockWidgetSideTab : public QFrame class ADS_EXPORT CDockWidgetSideTab : public CPushButton
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(SideTabBarArea sideTabBarArea READ sideTabBarArea) Q_PROPERTY(SideTabBarArea sideTabBarArea READ sideTabBarArea)
Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
Q_PROPERTY(bool activeTab READ isActiveTab) Q_PROPERTY(bool activeTab READ isActiveTab)
private: private:
@ -65,13 +64,11 @@ protected:
friend class CDockAreaWidget; friend class CDockAreaWidget;
friend class CDockContainerWidget; friend class CDockContainerWidget;
void mousePressEvent(QMouseEvent* event) override;
void setSideTabBar(CSideTabBar *SideTabBar); void setSideTabBar(CSideTabBar *SideTabBar);
void removeFromSideTabBar(); void removeFromSideTabBar();
public: public:
using Super = QFrame; using Super = CPushButton;
/** /**
* Dock widget side tab bar locations * Dock widget side tab bar locations
@ -108,25 +105,6 @@ public:
*/ */
SideTabBarArea sideTabBarArea() const; 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 * Set orientation vertical or horizontal
*/ */
@ -149,21 +127,7 @@ public:
Q_SIGNALS: Q_SIGNALS:
void elidedChanged(bool elided); void elidedChanged(bool elided);
void clicked();
}; // class DockWidgetSideTab }; // 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 // namespace ads
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -124,7 +124,7 @@ public:
void setOrientation(Qt::Orientation orientation); void setOrientation(Qt::Orientation orientation);
}; // class CVerticalElidingLabel }; // class CVerticalElidingLabel
} // namespace QtLabb } // namespace ads
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#endif // ElidingLabelH #endif // ElidingLabelH

69
src/PushButton.cpp Normal file
View 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
View 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

View File

@ -50,7 +50,8 @@ HEADERS += \
DockFocusController.h \ DockFocusController.h \
AutoHideDockContainer.h \ AutoHideDockContainer.h \
SideTabBar.h \ SideTabBar.h \
DockWidgetSideTab.h DockWidgetSideTab.h \
PushButton.h
SOURCES += \ SOURCES += \
@ -73,7 +74,8 @@ SOURCES += \
DockFocusController.cpp \ DockFocusController.cpp \
AutoHideDockContainer.cpp \ AutoHideDockContainer.cpp \
SideTabBar.cpp \ SideTabBar.cpp \
DockWidgetSideTab.cpp DockWidgetSideTab.cpp \
PushButton.cpp
unix:!macx { unix:!macx {

View File

@ -2,168 +2,170 @@
* Default style sheet on Windows Platforms * Default style sheet on Windows Platforms
*/ */
ads--CDockContainerWidget { ads--CDockContainerWidget {
background: palette(window); background: palette(window);
} }
ads--CDockContainerWidget > QSplitter{ ads--CDockContainerWidget > QSplitter {
padding: 1 0 1 0; padding: 1 0 1 0;
} }
ads--CDockContainerWidget ads--CDockSplitter::handle { ads--CDockContainerWidget ads--CDockSplitter::handle {
background: palette(dark); background: palette(dark);
} }
ads--CDockAreaWidget { ads--CDockAreaWidget {
background: palette(window); background: palette(window);
border: 1px solid white; border: 1px solid white;
} }
ads--CDockWidgetTab { ads--CDockWidgetTab {
background: palette(window); background: palette(window);
border-color: palette(light); border-color: palette(light);
border-style: solid; border-style: solid;
border-width: 0 1px 0 0; border-width: 0 1px 0 0;
padding: 0 0px; padding: 0 0px;
} }
ads--CDockWidgetTab[activeTab="true"] { ads--CDockWidgetTab[activeTab="true"] {
background: qlineargradient(spread : pad, x1 : 0, y1 : 0, x2 : 0, y2 : 0.5, stop : 0 background: qlineargradient(
palette(window), stop:1 palette(light)); spread: pad,
/*background: palette(highlight);*/ x1: 0,
y1: 0,
x2: 0,
y2: 0.5,
stop: 0 palette(window),
stop: 1 palette(light)
);
/*background: palette(highlight);*/
} }
ads--CDockWidgetTab QLabel { ads--CDockWidgetTab QLabel {
color: palette(dark); color: palette(dark);
} }
ads--CDockWidgetTab[activeTab="true"] QLabel { ads--CDockWidgetTab[activeTab="true"] QLabel {
color: palette(foreground); color: palette(foreground);
} }
ads--CDockWidget { ads--CDockWidget {
background: palette(light); background: palette(light);
border-color: palette(light); border-color: palette(light);
border-style: solid; border-style: solid;
border-width: 1px 0 0 0; border-width: 1px 0 0 0;
} }
ads--CTitleBarButton { ads--CTitleBarButton {
padding: 0px 0px; padding: 0px 0px;
} }
QScrollArea#dockWidgetScrollArea { QScrollArea#dockWidgetScrollArea {
padding: 0px; padding: 0px;
border: none; border: none;
} }
#dockAreaAutoHideButton { #dockAreaAutoHideButton {
qproperty-icon: url(:/ads/images/vs-pin-button.svg); qproperty-icon: url(:/ads/images/vs-pin-button.svg);
qproperty-iconSize: 16px; qproperty-iconsize: 16px;
} }
#tabCloseButton { #tabCloseButton {
margin-top: 2px; margin-top: 2px;
background: none; background: none;
border: none; border: none;
padding: 0px -2px; padding: 0px -2px;
qproperty-icon: url(:/ads/images/close-button.svg), qproperty-icon: url(:/ads/images/close-button.svg),
url(:/ads/images/close-button-disabled.svg) disabled; url(:/ads/images/close-button-disabled.svg) disabled;
qproperty-iconSize: 16px; qproperty-iconsize: 16px;
} }
#tabCloseButton:hover { #tabCloseButton:hover {
border: 1px solid rgba(0, 0, 0, 32); border: 1px solid rgba(0, 0, 0, 32);
background: rgba(0, 0, 0, 16); background: rgba(0, 0, 0, 16);
} }
#tabCloseButton:pressed { #tabCloseButton:pressed {
background: rgba(0, 0, 0, 32); background: rgba(0, 0, 0, 32);
} }
#tabsMenuButton::menu-indicator { #tabsMenuButton::menu-indicator {
image: none; image: none;
} }
#tabsMenuButton { #tabsMenuButton {
qproperty-icon: url(:/ads/images/tabs-menu-button.svg); qproperty-icon: url(:/ads/images/tabs-menu-button.svg);
qproperty-iconSize: 16px; qproperty-iconsize: 16px;
} }
#dockAreaCloseButton { #dockAreaCloseButton {
qproperty-icon: url(:/ads/images/close-button.svg), qproperty-icon: url(:/ads/images/close-button.svg),
url(:/ads/images/close-button-disabled.svg) disabled; url(:/ads/images/close-button-disabled.svg) disabled;
qproperty-iconSize: 16px; qproperty-iconsize: 16px;
} }
#detachGroupButton { #detachGroupButton {
qproperty-icon: url(:/ads/images/detach-button.svg), qproperty-icon: url(:/ads/images/detach-button.svg),
url(:/ads/images/detach-button-disabled.svg) disabled; url(:/ads/images/detach-button-disabled.svg) disabled;
qproperty-iconSize: 16px; qproperty-iconsize: 16px;
} }
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
* Styling of auto hide functionality * Styling of auto hide functionality
*---------------------------------------------------------------------------- *----------------------------------------------------------------------------
*/ */
ads--CDockWidgetSideTab { ads--CDockWidgetSideTab {
background: palette(window); /*background: palette(window);*/
qproperty-iconSize: 16px 16px;/* this is optional in case you would like to change icon size*/ qproperty-iconsize: 16px 16px; /* this is optional in case you would like to change icon size*/
} }
ads--CDockWidgetSideTab[sideTabBarArea="0"] { ads--CDockWidgetSideTab[sideTabBarArea="0"] {
border-top: 3px solid grey; border-top: 3px solid grey;
border-right: 1px solid white; border-right: 1px solid white;
} }
ads--CDockWidgetSideTab[sideTabBarArea="1"] { ads--CDockWidgetSideTab[sideTabBarArea="1"] {
border-left: 3px solid grey; border-left: 3px solid grey;
border-bottom: 1px solid white; border-bottom: 1px solid white;
} }
ads--CDockWidgetSideTab[sideTabBarArea="2"] { ads--CDockWidgetSideTab[sideTabBarArea="2"] {
border-right: 3px solid grey; border-right: 3px solid grey;
border-bottom: 1px solid white; border-bottom: 1px solid white;
} }
ads--CDockWidgetSideTab[sideTabBarArea="3"] { ads--CDockWidgetSideTab[sideTabBarArea="3"] {
border-bottom: 3px solid grey; border-bottom: 3px solid grey;
border-right: 1px solid white; border-right: 1px solid white;
} }
ads--CDockWidgetSideTab:hover[sideTabBarArea="0"] { ads--CDockWidgetSideTab:hover[sideTabBarArea="0"] {
border-top: 3px solid palette(highlight); border-top: 3px solid palette(highlight);
} }
ads--CDockWidgetSideTab:hover[sideTabBarArea="1"] { ads--CDockWidgetSideTab:hover[sideTabBarArea="1"] {
border-left: 3px solid palette(highlight); border-left: 3px solid palette(highlight);
} }
ads--CDockWidgetSideTab:hover[sideTabBarArea="2"] { ads--CDockWidgetSideTab:hover[sideTabBarArea="2"] {
border-right: 3px solid palette(highlight); border-right: 3px solid palette(highlight);
} }
ads--CDockWidgetSideTab:hover[sideTabBarArea="3"] { ads--CDockWidgetSideTab:hover[sideTabBarArea="3"] {
border-bottom: 3px solid palette(highlight); border-bottom: 3px solid palette(highlight);
} }
ads--CDockWidgetSideTab[sideTabBarArea="0"][activeTab="true"] { ads--CDockWidgetSideTab[sideTabBarArea="0"][activeTab="true"] {
border-top: 3px solid palette(highlight); border-top: 3px solid palette(highlight);
} }
ads--CDockWidgetSideTab[sideTabBarArea="1"][activeTab="true"] { ads--CDockWidgetSideTab[sideTabBarArea="1"][activeTab="true"] {
border-left: 3px solid palette(highlight); border-left: 3px solid palette(highlight);
} }
ads--CDockWidgetSideTab[sideTabBarArea="2"][activeTab="true"] { ads--CDockWidgetSideTab[sideTabBarArea="2"][activeTab="true"] {
border-right: 3px solid palette(highlight); border-right: 3px solid palette(highlight);
} }
ads--CDockWidgetSideTab[sideTabBarArea="3"][activeTab="true"] { 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; background: white;
}*/ }*/
ads--CAutoHideDockContainer #dockAreaAutoHideButton ads--CAutoHideDockContainer #dockAreaAutoHideButton {
{ qproperty-icon: url(:/ads/images/vs-pin-button-pinned.svg);
qproperty-icon: url(:/ads/images/vs-pin-button-pinned.svg); qproperty-iconsize: 16px;
qproperty-iconSize: 16px;
} }
#autoHideTitleLabel { #autoHideTitleLabel {
padding-left: 4px; padding-left: 4px;
} }