diff --git a/doc/taiwan_ukraine.jpg b/doc/taiwan_ukraine.jpg new file mode 100644 index 0000000..f2f5822 Binary files /dev/null and b/doc/taiwan_ukraine.jpg differ diff --git a/src/SideTabBar.cpp b/src/SideTabBar.cpp index be3b408..38d4dc1 100644 --- a/src/SideTabBar.cpp +++ b/src/SideTabBar.cpp @@ -54,6 +54,15 @@ struct SideTabBarPrivate CDockContainerWidget* ContainerWidget; QBoxLayout* TabsLayout; Qt::Orientation Orientation; + CDockWidgetSideTab::SideTabBarArea SideTabArea = CDockWidgetSideTab::Left; + + /** + * Convenience function to check if this is a horizontal side bar + */ + bool isHorizontal() const + { + return Qt::Horizontal == Orientation; + } }; // struct SideTabBarPrivate //============================================================================ @@ -64,12 +73,14 @@ SideTabBarPrivate::SideTabBarPrivate(CSideTabBar* _public) : //============================================================================ -CSideTabBar::CSideTabBar(CDockContainerWidget* parent, Qt::Orientation orientation) : - QWidget(parent), +CSideTabBar::CSideTabBar(CDockContainerWidget* parent, CDockWidgetSideTab::SideTabBarArea area) : + Super(parent), d(new SideTabBarPrivate(this)) { + d->SideTabArea = area; d->ContainerWidget = parent; - d->Orientation = orientation; + d->Orientation = (area == CDockWidgetSideTab::Bottom || area == CDockWidgetSideTab::Top) + ? Qt::Horizontal : Qt::Vertical; auto mainLayout = new QBoxLayout(d->Orientation == Qt::Vertical ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight); @@ -80,9 +91,19 @@ CSideTabBar::CSideTabBar(CDockContainerWidget* parent, Qt::Orientation orientati mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->setSpacing(0); mainLayout->addStretch(1); - setLayout(mainLayout); + setFocusPolicy(Qt::NoFocus); + if (d->isHorizontal()) + { + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + } + else + { + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); + } + + hide(); } @@ -98,6 +119,7 @@ void CSideTabBar::insertSideTab(int Index, CDockWidgetSideTab* SideTab) { d->TabsLayout->insertWidget(Index, SideTab); SideTab->setSideTabBar(this); + show(); } @@ -105,6 +127,10 @@ void CSideTabBar::insertSideTab(int Index, CDockWidgetSideTab* SideTab) void CSideTabBar::removeSideTab(CDockWidgetSideTab* SideTab) { d->TabsLayout->removeWidget(SideTab); + if (d->TabsLayout->isEmpty()) + { + hide(); + } } @@ -139,4 +165,11 @@ int CSideTabBar::tabCount() const { return d->TabsLayout->count(); } + + +//============================================================================ +CDockWidgetSideTab::SideTabBarArea CSideTabBar::sideTabBarArea() const +{ + return d->SideTabArea; +} } diff --git a/src/SideTabBar.h b/src/SideTabBar.h index 47d0d49..bf587b3 100644 --- a/src/SideTabBar.h +++ b/src/SideTabBar.h @@ -29,7 +29,8 @@ //============================================================================ // INCLUDES //============================================================================ -#include +#include +#include "DockWidgetSideTab.h" #include "ads_globals.h" namespace ads @@ -37,15 +38,14 @@ namespace ads struct SideTabBarPrivate; class CDockContainerWidget; class CDockWidgetSideTab; -class CDockWidgetTab; /** * Side tab widget that is shown at the edges of a dock container. */ -class ADS_EXPORT CSideTabBar : public QWidget +class ADS_EXPORT CSideTabBar : public QFrame { Q_OBJECT - + Q_PROPERTY(int sideTabBarArea READ sideTabBarArea) Q_PROPERTY(Qt::Orientation orientation READ orientation) private: @@ -57,12 +57,12 @@ protected: void paintEvent(QPaintEvent* event) override; public: - using Super = QWidget; + using Super = QFrame; /** * Default Constructor */ - CSideTabBar(CDockContainerWidget* parent, Qt::Orientation orientation); + CSideTabBar(CDockContainerWidget* parent, CDockWidgetSideTab::SideTabBarArea area); /** * Virtual Destructor @@ -94,8 +94,13 @@ public: */ int tabCount() const; - Q_SIGNALS: - void sideTabAutoHideToggleRequested(); + /** + * Getter for side tab bar area property + */ + CDockWidgetSideTab::SideTabBarArea sideTabBarArea() const; + +Q_SIGNALS: + void sideTabAutoHideToggleRequested(); }; }