From ad0c2103bf36a289a07aa9f9977f5f7b525ff70f Mon Sep 17 00:00:00 2001 From: Syarif Fakhri Date: Fri, 14 Oct 2022 16:09:13 +0800 Subject: [PATCH 1/8] fix crash when using widgets that delete on close --- src/AutoHideDockContainer.cpp | 8 +++----- src/DockContainerWidget.cpp | 8 +++++++- src/DockWidget.cpp | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/AutoHideDockContainer.cpp b/src/AutoHideDockContainer.cpp index 65bb075..83a34fe 100644 --- a/src/AutoHideDockContainer.cpp +++ b/src/AutoHideDockContainer.cpp @@ -196,9 +196,6 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockManager* DockManager, CDockW updateSize(); parent->registerAutoHideWidget(this); - - d->DockArea->installEventFilter(this); - parent->installEventFilter(this); } //============================================================================ @@ -231,8 +228,7 @@ CAutoHideDockContainer::~CAutoHideDockContainer() ADS_PRINT("~CAutoHideDockContainer"); // Remove event filter in case there are any queued messages - d->DockArea->removeEventFilter(this); - parent()->removeEventFilter(this); + qApp->removeEventFilter(this); if (d->DockManager) { @@ -439,6 +435,8 @@ void CAutoHideDockContainer::collapseView(bool Enable) show(); d->DockArea->show(); d->DockWidget->show(); + updateMask(); + updateSize(); qApp->installEventFilter(this); } } diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index fa928e1..eccfec8 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -1054,9 +1054,10 @@ bool DockContainerWidgetPrivate::restoreAutoHideDockArea(CDockingStateReader& s, } CDockAreaWidget* DockArea = nullptr; + CAutoHideDockContainer* dockContainer = nullptr; if (!Testing) { - const auto dockContainer = new CAutoHideDockContainer(DockManager, area, _this); + dockContainer = new CAutoHideDockContainer(DockManager, area, _this); if (!dockContainer->restoreState(s, Testing)) { return false; @@ -1108,6 +1109,11 @@ bool DockContainerWidgetPrivate::restoreAutoHideDockArea(CDockingStateReader& s, DockArea->autoHideDockContainer()->toggleView(!Closed); } + if (dockContainer && !dockContainer->dockWidget()) + { + dockContainer->cleanupAndDelete(); + } + return true; } diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index 2a90d3d..0d189a0 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -248,7 +248,7 @@ void DockWidgetPrivate::updateParentDockArea() void DockWidgetPrivate::closeAutoHideDockWidgetsIfNeeded() { - if (_this->dockContainer() && _this->dockContainer()->openedDockWidgets().isEmpty()) + if (_this->dockContainer() && _this->dockContainer()->openedDockWidgets().isEmpty() && !_this->dockManager()->isRestoringState()) { for (auto autoHideWidget : _this->dockContainer()->autoHideWidgets()) { From efb87c868b998305d50aa18e8ce7241eaf9c358c Mon Sep 17 00:00:00 2001 From: Syarif Fakhri Date: Fri, 14 Oct 2022 16:20:32 +0800 Subject: [PATCH 2/8] update size then mask --- src/AutoHideDockContainer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AutoHideDockContainer.cpp b/src/AutoHideDockContainer.cpp index 83a34fe..100e801 100644 --- a/src/AutoHideDockContainer.cpp +++ b/src/AutoHideDockContainer.cpp @@ -192,8 +192,8 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockManager* DockManager, CDockW } } - updateMask(); updateSize(); + updateMask(); parent->registerAutoHideWidget(this); } @@ -435,8 +435,8 @@ void CAutoHideDockContainer::collapseView(bool Enable) show(); d->DockArea->show(); d->DockWidget->show(); - updateMask(); updateSize(); + updateMask(); qApp->installEventFilter(this); } } From 91190e8744d65467a571339f1a64f36d1f85626b Mon Sep 17 00:00:00 2001 From: Syarif Fakhri Date: Fri, 14 Oct 2022 17:47:41 +0800 Subject: [PATCH 3/8] cleaner dock widget side tab click handling --- src/AutoHideDockContainer.cpp | 1 + src/DockWidget.cpp | 8 -------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/AutoHideDockContainer.cpp b/src/AutoHideDockContainer.cpp index 100e801..408d383 100644 --- a/src/AutoHideDockContainer.cpp +++ b/src/AutoHideDockContainer.cpp @@ -437,6 +437,7 @@ void CAutoHideDockContainer::collapseView(bool Enable) d->DockWidget->show(); updateSize(); updateMask(); + d->DockManager->setDockWidgetFocused(d->DockWidget); qApp->installEventFilter(this); } } diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index 0d189a0..50eaf15 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -1085,15 +1085,7 @@ void CDockWidget::onDockWidgetSideTabClicked() return; } - autoHideContainer->raise(); autoHideContainer->toggleCollapseState(); - if (autoHideContainer->isVisible()) - { - // d->DockManager->setDockWidgetFocused(this) does not - // de focus the old widget, leading to the auto hide still being visible - // even after clicking outside the auto hide. - setFocus(Qt::ActiveWindowFocusReason); - } } //============================================================================ From ac8cf863a03234d1622ffe07ddd3e26d59e2c1e8 Mon Sep 17 00:00:00 2001 From: Syarif Fakhri Date: Fri, 14 Oct 2022 21:07:58 +0800 Subject: [PATCH 4/8] remove unused css --- src/stylesheets/default.css | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/stylesheets/default.css b/src/stylesheets/default.css index 7f8d502..42cf1c1 100644 --- a/src/stylesheets/default.css +++ b/src/stylesheets/default.css @@ -43,16 +43,6 @@ ads--CDockWidgetSideTab { background: palette(window); } -ads--CDockWidgetSideTab[sideTabBarArea="Left"] { - border-left: 3px solid grey; - border-bottom: 1px solid white; -} - -ads--CDockWidgetSideTab[sideTabBarArea="Right"] { - border-right: 3px solid grey; - border-bottom: 1px solid white; -} - ads--CDockWidget { background: palette(light); border-color: palette(light); From f9b62234b0615dc720953d167a12b9f1445d628b Mon Sep 17 00:00:00 2001 From: Syarif Fakhri Date: Fri, 14 Oct 2022 21:13:32 +0800 Subject: [PATCH 5/8] Add top area --- src/AutoHideDockContainer.cpp | 25 +++++++++++++++++- src/DockContainerWidget.cpp | 31 +++++++++++++++-------- src/DockManager.h | 15 ++++++----- src/DockWidgetSideTab.cpp | 11 ++++++-- src/DockWidgetSideTab.h | 1 + src/stylesheets/focus_highlighting.css | 35 +++++++++++++++++++------- 6 files changed, 90 insertions(+), 28 deletions(-) diff --git a/src/AutoHideDockContainer.cpp b/src/AutoHideDockContainer.cpp index 408d383..0d6f700 100644 --- a/src/AutoHideDockContainer.cpp +++ b/src/AutoHideDockContainer.cpp @@ -80,6 +80,10 @@ struct AutoHideDockContainerPrivate { return BottomDockWidgetArea; } + case CDockWidgetSideTab::Top: + { + return TopDockWidgetArea; + } } return LeftDockWidgetArea; @@ -106,6 +110,10 @@ struct AutoHideDockContainerPrivate { return QPoint(_this->width() / 2, _this->height() - 1); } + case CDockWidgetSideTab::Top: + { + return QPoint(_this->width() / 2, 1); + } } return QPoint(); @@ -125,6 +133,11 @@ struct AutoHideDockContainerPrivate return QRect(QPoint(topLeft.x(), topLeft.y() - handleSize), QSize(rect.size().width(), rect.size().height() + handleSize)); } + if (SideTabBarArea == CDockWidgetSideTab::Top) + { + return QRect(QPoint(topLeft.x(), topLeft.y()), QSize(rect.size().width(), rect.size().height() + handleSize)); + } + auto offset = 0; if (SideTabBarArea == CDockWidgetSideTab::SideTabBarArea::RightTop || SideTabBarArea == CDockWidgetSideTab::SideTabBarArea::RightBottom) { @@ -150,7 +163,7 @@ CDockContainerWidget* CAutoHideDockContainer::parentContainer() const //============================================================================ CAutoHideDockContainer::CAutoHideDockContainer(CDockManager* DockManager, CDockWidgetSideTab::SideTabBarArea area, CDockContainerWidget* parent) : - QSplitter(area == CDockWidgetSideTab::Bottom ? Qt::Orientation::Vertical : Qt::Orientation::Horizontal, parent), + QSplitter((area == CDockWidgetSideTab::Bottom || area == CDockWidgetSideTab::Top) ? Qt::Orientation::Vertical : Qt::Orientation::Horizontal, parent), d(new AutoHideDockContainerPrivate(this)) { d->DockManager = DockManager; @@ -170,6 +183,12 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockManager* DockManager, CDockW switch (area) { + case CDockWidgetSideTab::Top: + { + addWidget(d->DockArea); + addWidget(emptyWidget); + break; + } case CDockWidgetSideTab::LeftBottom: case CDockWidgetSideTab::LeftTop: { @@ -469,6 +488,10 @@ bool CAutoHideDockContainer::areaExistsInConfig(CDockWidgetSideTab::SideTabBarAr { return CDockManager::testConfigFlag(CDockManager::DockContainerHasBottomSideBar); } + case CDockWidgetSideTab::Top: + { + return CDockManager::testConfigFlag(CDockManager::DockContainerHasTopSideBar); + } } return true; diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index eccfec8..77b4304 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -1440,7 +1440,7 @@ CDockContainerWidget::CDockContainerWidget(CDockManager* DockManager, QWidget *p d->Layout->setContentsMargins(0, 0, 0, 0); d->Layout->setSpacing(0); d->Layout->setColumnStretch(1, 1); - d->Layout->setRowStretch(0, 1); + d->Layout->setRowStretch(1, 1); setLayout(d->Layout); // The function d->newSplitter() accesses the config flags from dock @@ -1523,16 +1523,21 @@ CAutoHideDockContainer* CDockContainerWidget::createAndInitializeAutoHideDockWid //============================================================================ CDockWidgetSideTab::SideTabBarArea CDockContainerWidget::getDockAreaPosition(CDockAreaWidget* DockAreaWidget) { - // Handle bottom case + // Handle bottom case and top case // It's bottom if the width is wider than the height, and if it's below 50% of the window const auto dockWidgetFrameGeometry = DockAreaWidget->frameGeometry(); const auto splitterCenter = rootSplitter()->mapToGlobal(rootSplitter()->frameGeometry().center()); - if (dockWidgetFrameGeometry.width() > dockWidgetFrameGeometry.height() - && DockAreaWidget->mapToGlobal(dockWidgetFrameGeometry.topLeft()).y() > splitterCenter.y() - && CDockManager::testConfigFlag(CDockManager::DockContainerHasBottomSideBar)) + if (dockWidgetFrameGeometry.width() > dockWidgetFrameGeometry.height()) { - return CDockWidgetSideTab::Bottom; + if (DockAreaWidget->mapToGlobal(dockWidgetFrameGeometry.topLeft()).y() > splitterCenter.y() && CDockManager::testConfigFlag(CDockManager::DockContainerHasBottomSideBar)) + { + return CDockWidgetSideTab::Bottom; + } + if (CDockManager::testConfigFlag(CDockManager::DockContainerHasTopSideBar)) + { + return CDockWidgetSideTab::Top; + } } // Then handle left and right @@ -2040,7 +2045,7 @@ void CDockContainerWidget::createRootSplitter() return; } d->RootSplitter = d->newSplitter(Qt::Horizontal); - d->Layout->addWidget(d->RootSplitter, 0, 1); // Add it to the center - the 0 and 2 indexes are used for the SideTabBar widgets + d->Layout->addWidget(d->RootSplitter, 1, 1); // Add it to the center - the 0 and 2 indexes are used for the SideTabBar widgets } @@ -2055,7 +2060,7 @@ void CDockContainerWidget::createSideTabBarWidgets() leftLayout->addStretch(1); d->SideTabBarWidgets[CDockWidgetSideTab::LeftBottom] = new CSideTabBar(this, Qt::Vertical); leftLayout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::LeftBottom]); - d->Layout->addLayout(leftLayout, 0, 0); + d->Layout->addLayout(leftLayout, 1, 0); } if (CDockManager::testConfigFlag(CDockManager::DockContainerHasRightSideBar)) @@ -2066,13 +2071,19 @@ void CDockContainerWidget::createSideTabBarWidgets() rightLayout->addStretch(1); d->SideTabBarWidgets[CDockWidgetSideTab::RightBottom] = new CSideTabBar(this, Qt::Vertical); rightLayout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::RightBottom]); - d->Layout->addLayout(rightLayout, 0, 2); + d->Layout->addLayout(rightLayout, 1, 2); } if (CDockManager::testConfigFlag(CDockManager::DockContainerHasBottomSideBar)) { d->SideTabBarWidgets[CDockWidgetSideTab::Bottom] = new CSideTabBar(this, Qt::Horizontal); - d->Layout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Bottom], 1, 1); + d->Layout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Bottom], 2, 1); + } + + if (CDockManager::testConfigFlag(CDockManager::DockContainerHasTopSideBar)) + { + d->SideTabBarWidgets[CDockWidgetSideTab::Top] = new CSideTabBar(this, Qt::Horizontal); + d->Layout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Top], 0, 1); } } diff --git a/src/DockManager.h b/src/DockManager.h index e1f23c0..e9599cc 100644 --- a/src/DockManager.h +++ b/src/DockManager.h @@ -229,15 +229,18 @@ public: DockContainerHasLeftSideBar = 0x01, //!< If the flag is set left side bar will prioritize showing icons only over text DockContainerHasRightSideBar = 0x02, //!< If the flag is set right side bar will prioritize showing icons only over text DockContainerHasBottomSideBar = 0x04, //!< If the flag is set right side bar will prioritize showing icons only over text - DockAreaHasAutoHideButton = 0x08, //!< If the flag is set each dock area has a auto hide menu button - LeftSideBarPrioritizeIconOnly = 0x10, //!< If the flag is set each container will have a left side bar - RightSideBarPrioritizeIconOnly = 0x20, //!< If the flag is set each container will have a right side bar - BottomSideBarPrioritizeIconOnly = 0x40, //!< If the flag is set bottom side bar will prioritize showing icons only over text - AutoHideDockAreaHasTitle = 0x80, //!< If the flag is set overlay dock area title bar will show the window title + DockContainerHasTopSideBar = 0x08, //!< If the flag is set right side bar will prioritize showing icons only over text + DockAreaHasAutoHideButton = 0x10, //!< If the flag is set each dock area has a auto hide menu button + LeftSideBarPrioritizeIconOnly = 0x20, //!< If the flag is set each container will have a left side bar + RightSideBarPrioritizeIconOnly = 0x40, //!< If the flag is set each container will have a right side bar + BottomSideBarPrioritizeIconOnly = 0x80, //!< If the flag is set bottom side bar will prioritize showing icons only over text + TopSideBarPrioritizeIconOnly = 0x100, //!< If the flag is set bottom side bar will prioritize showing icons only over text + AutoHideDockAreaHasTitle = 0x200, //!< If the flag is set overlay dock area title bar will show the window title - DefaultAutoHideConfig = DockContainerHasLeftSideBar + DefaultAutoHideConfig = DockContainerHasLeftSideBar | BottomSideBarPrioritizeIconOnly | TopSideBarPrioritizeIconOnly | DockContainerHasRightSideBar | DockContainerHasBottomSideBar + | DockContainerHasTopSideBar | DockAreaHasAutoHideButton | AutoHideDockAreaHasTitle, ///< the default configuration for left and right side bars }; diff --git a/src/DockWidgetSideTab.cpp b/src/DockWidgetSideTab.cpp index 6307707..1ee9a7d 100644 --- a/src/DockWidgetSideTab.cpp +++ b/src/DockWidgetSideTab.cpp @@ -106,7 +106,7 @@ struct DockWidgetSideTabPrivate } else if (Orientation == Qt::Horizontal) { - TitleLayout->setContentsMargins(Spacing / 2, Spacing / 2, Spacing, Spacing); + TitleLayout->setContentsMargins(Spacing / 2, Spacing, Spacing, Spacing); if (IconLabel) { IconLabel->setContentsMargins(Spacing / 2, Spacing / 2, 0, Spacing / 2); @@ -276,7 +276,7 @@ void CDockWidgetSideTab::setOrientation(Qt::Orientation Orientation) //============================================================================ void CDockWidgetSideTab::updateOrientationAndSpacing(SideTabBarArea area) { - setOrientation(area == Bottom ? Qt::Horizontal : Qt::Vertical); + setOrientation((area == Bottom || area == Top) ? Qt::Horizontal : Qt::Vertical); d->updateContentsMargins(); @@ -304,6 +304,13 @@ void CDockWidgetSideTab::updateOrientationAndSpacing(SideTabBarArea area) return; } if (CDockManager::testConfigFlag(CDockManager::BottomSideBarPrioritizeIconOnly) && area == Bottom) + { + d->TitleLabel->hide(); + d->TitleLayout->setContentsMargins(0, 0, 0, 0); + d->IconLabel->setContentsMargins(Spacing / 2, Spacing / 2, Spacing / 2, Spacing); + return; + } + if (CDockManager::testConfigFlag(CDockManager::TopSideBarPrioritizeIconOnly) && area == Top) { d->TitleLabel->hide(); d->TitleLayout->setContentsMargins(0, 0, 0, 0); diff --git a/src/DockWidgetSideTab.h b/src/DockWidgetSideTab.h index 42ebdca..3a6e716 100644 --- a/src/DockWidgetSideTab.h +++ b/src/DockWidgetSideTab.h @@ -77,6 +77,7 @@ public: */ enum SideTabBarArea { + Top, LeftTop, LeftBottom, RightTop, diff --git a/src/stylesheets/focus_highlighting.css b/src/stylesheets/focus_highlighting.css index 672783c..1a6fe77 100644 --- a/src/stylesheets/focus_highlighting.css +++ b/src/stylesheets/focus_highlighting.css @@ -27,17 +27,22 @@ ads--CDockWidgetSideTab { qproperty-iconSize: 16px 16px;/* this is optional in case you would like to change icon size*/ } -ads--CDockWidgetSideTab[sideTabBarArea="0"],[sideTabBarArea="1"] { +ads--CDockWidgetSideTab[sideTabBarArea="0"] { + border-top: 3px solid grey; + border-right: 1px solid white; +} + +ads--CDockWidgetSideTab[sideTabBarArea="1"],[sideTabBarArea="2"] { border-left: 3px solid grey; border-bottom: 1px solid white; } -ads--CDockWidgetSideTab[sideTabBarArea="2"],[sideTabBarArea="3"] { +ads--CDockWidgetSideTab[sideTabBarArea="3"],[sideTabBarArea="4"] { border-right: 3px solid grey; border-bottom: 1px solid white; } -ads--CDockWidgetSideTab[sideTabBarArea="4"] { +ads--CDockWidgetSideTab[sideTabBarArea="5"] { border-bottom: 3px solid grey; border-right: 1px solid white; } @@ -120,27 +125,39 @@ ads--CDockSplitter::handle { } /* Focus related styling */ -ads--CDockWidgetSideTab:hover[sideTabBarArea="0"],:hover[sideTabBarArea="1"] { +ads--CDockWidgetSideTab:hover[sideTabBarArea="0"] { + border-top: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab:hover[sideTabBarArea="1"],:hover[sideTabBarArea="2"] { border-left: 3px solid palette(highlight); } -ads--CDockWidgetSideTab:hover[sideTabBarArea="2"],:hover[sideTabBarArea="3"] { +ads--CDockWidgetSideTab:hover[sideTabBarArea="3"],:hover[sideTabBarArea="4"] { border-right: 3px solid palette(highlight); } -ads--CDockWidgetSideTab:hover[sideTabBarArea="4"] { +ads--CDockWidgetSideTab:hover[sideTabBarArea="5"] { border-bottom: 3px solid palette(highlight); } -ads--CDockWidgetSideTab[sideTabBarArea="0"][focused="true"],[sideTabBarArea="1"][focused="true"] { +ads--CDockWidgetSideTab:hover[sideTabBarArea="0"][focused="true"] { + border-top: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab[sideTabBarArea="0"][focused="true"] { + border-top: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab[sideTabBarArea="1"][focused="true"],[sideTabBarArea="2"][focused="true"] { border-left: 3px solid palette(highlight); } -ads--CDockWidgetSideTab[sideTabBarArea="2"][focused="true"],[sideTabBarArea="3"][focused="true"] { +ads--CDockWidgetSideTab[sideTabBarArea="3"][focused="true"],[sideTabBarArea="4"][focused="true"] { border-right: 3px solid palette(highlight); } -ads--CDockWidgetSideTab[sideTabBarArea="4"][focused="true"] { +ads--CDockWidgetSideTab[sideTabBarArea="5"][focused="true"] { border-bottom: 3px solid palette(highlight); } From b0544be068a86dff3f6ac040d2edb10b5e4339a4 Mon Sep 17 00:00:00 2001 From: Syarif Fakhri Date: Fri, 14 Oct 2022 21:32:05 +0800 Subject: [PATCH 6/8] Added activeTab property --- src/AutoHideDockContainer.cpp | 2 + src/DockWidgetSideTab.cpp | 12 ++++++ src/DockWidgetSideTab.h | 5 +++ src/stylesheets/default.css | 57 ++++++++++++++++++++++++++ src/stylesheets/focus_highlighting.css | 12 +++--- 5 files changed, 82 insertions(+), 6 deletions(-) diff --git a/src/AutoHideDockContainer.cpp b/src/AutoHideDockContainer.cpp index 0d6f700..626b438 100644 --- a/src/AutoHideDockContainer.cpp +++ b/src/AutoHideDockContainer.cpp @@ -459,6 +459,8 @@ void CAutoHideDockContainer::collapseView(bool Enable) d->DockManager->setDockWidgetFocused(d->DockWidget); qApp->installEventFilter(this); } + + d->DockWidget->sideTabWidget()->updateStyle(); } diff --git a/src/DockWidgetSideTab.cpp b/src/DockWidgetSideTab.cpp index 1ee9a7d..b62ca81 100644 --- a/src/DockWidgetSideTab.cpp +++ b/src/DockWidgetSideTab.cpp @@ -322,6 +322,18 @@ void CDockWidgetSideTab::updateOrientationAndSpacing(SideTabBarArea area) } +//============================================================================ +bool CDockWidgetSideTab::isActiveTab() const +{ + if (d->DockWidget->autoHideDockContainer()) + { + return d->DockWidget->autoHideDockContainer()->isVisible(); + } + + return false; +} + + //============================================================================ CDockWidget* CDockWidgetSideTab::dockWidget() const { diff --git a/src/DockWidgetSideTab.h b/src/DockWidgetSideTab.h index 3a6e716..bb8dc9f 100644 --- a/src/DockWidgetSideTab.h +++ b/src/DockWidgetSideTab.h @@ -52,6 +52,7 @@ class ADS_EXPORT CDockWidgetSideTab : public QFrame Q_PROPERTY(SideTabBarArea sideTabBarArea READ sideTabBarArea) Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize) + Q_PROPERTY(bool activeTab READ isActiveTab) private: DockWidgetSideTabPrivate* d; ///< private data (pimpl) @@ -139,6 +140,10 @@ public: */ void updateOrientationAndSpacing(SideTabBarArea area); + /** + * Returns true, if this is the active tab. The tab is active if the auto hide widget is visible + */ + bool isActiveTab() const; /** * returns the dock widget this belongs to diff --git a/src/stylesheets/default.css b/src/stylesheets/default.css index 42cf1c1..127baed 100644 --- a/src/stylesheets/default.css +++ b/src/stylesheets/default.css @@ -41,6 +41,63 @@ ads--CDockWidgetTab[activeTab="true"] QLabel { ads--CDockWidgetSideTab { 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; +} + +ads--CDockWidgetSideTab[sideTabBarArea="1"],[sideTabBarArea="2"] { + border-left: 3px solid grey; + border-bottom: 1px solid white; +} + +ads--CDockWidgetSideTab[sideTabBarArea="3"],[sideTabBarArea="4"] { + border-right: 3px solid grey; + border-bottom: 1px solid white; +} + +ads--CDockWidgetSideTab[sideTabBarArea="5"] { + border-bottom: 3px solid grey; + border-right: 1px solid white; +} + +ads--CDockWidgetSideTab:hover[sideTabBarArea="0"] { + border-top: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab:hover[sideTabBarArea="1"],:hover[sideTabBarArea="2"] { + border-left: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab:hover[sideTabBarArea="3"],:hover[sideTabBarArea="4"] { + border-right: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab:hover[sideTabBarArea="5"] { + border-bottom: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab:hover[sideTabBarArea="0"][activeTab="true"] { + border-top: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab[sideTabBarArea="0"][activeTab="true"] { + border-top: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab[sideTabBarArea="1"][activeTab="true"],[sideTabBarArea="2"][activeTab="true"] { + border-left: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab[sideTabBarArea="3"][activeTab="true"],[sideTabBarArea="4"][focused="true"] { + border-right: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab[sideTabBarArea="5"][activeTab="true"] { + border-bottom: 3px solid palette(highlight); } ads--CDockWidget { diff --git a/src/stylesheets/focus_highlighting.css b/src/stylesheets/focus_highlighting.css index 1a6fe77..a24aa9a 100644 --- a/src/stylesheets/focus_highlighting.css +++ b/src/stylesheets/focus_highlighting.css @@ -141,27 +141,27 @@ ads--CDockWidgetSideTab:hover[sideTabBarArea="5"] { border-bottom: 3px solid palette(highlight); } -ads--CDockWidgetSideTab:hover[sideTabBarArea="0"][focused="true"] { +ads--CDockWidgetSideTab:hover[sideTabBarArea="0"][activeTab="true"] { border-top: 3px solid palette(highlight); } -ads--CDockWidgetSideTab[sideTabBarArea="0"][focused="true"] { +ads--CDockWidgetSideTab[sideTabBarArea="0"][activeTab="true"] { border-top: 3px solid palette(highlight); } -ads--CDockWidgetSideTab[sideTabBarArea="1"][focused="true"],[sideTabBarArea="2"][focused="true"] { +ads--CDockWidgetSideTab[sideTabBarArea="1"][activeTab="true"],[sideTabBarArea="2"][activeTab="true"] { border-left: 3px solid palette(highlight); } -ads--CDockWidgetSideTab[sideTabBarArea="3"][focused="true"],[sideTabBarArea="4"][focused="true"] { +ads--CDockWidgetSideTab[sideTabBarArea="3"][activeTab="true"],[sideTabBarArea="4"][focused="true"] { border-right: 3px solid palette(highlight); } -ads--CDockWidgetSideTab[sideTabBarArea="5"][focused="true"] { +ads--CDockWidgetSideTab[sideTabBarArea="5"][activeTab="true"] { border-bottom: 3px solid palette(highlight); } -ads--CDockWidgetTab[focused="true"] { +ads--CDockWidgetTab[activeTab="true"] { background: palette(highlight); border-color: palette(highlight); } From 754a41d11820651b97abf1849119befbec10b62a Mon Sep 17 00:00:00 2001 From: Syarif Fakhri Date: Fri, 14 Oct 2022 21:41:39 +0800 Subject: [PATCH 7/8] Formatting and cleanup - Update user-guide.md - Remove incorrect configuration from dock manager.h - Fix spacing --- doc/user-guide.md | 10 +++++----- src/DockManager.h | 2 +- src/DockWidgetSideTab.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/user-guide.md b/doc/user-guide.md index 981826e..1d6cb17 100644 --- a/doc/user-guide.md +++ b/doc/user-guide.md @@ -633,7 +633,7 @@ d->DockManager = new CDockManager(this); ### Adding Auto Hide Widgets -Adding an overlay widget is similar to adding a dock widget, simply call `dockManager->addAutoHideDockWidget`. +Adding an auto hide widget is similar to adding a dock widget, simply call `dockManager->addAutoHideDockWidget`. ```c++ d->DockManager = new CDockManager(this); @@ -646,17 +646,17 @@ See `autohide` example to learn how it works. ### Configuration Flags For Auto Hide Widgets -- `DockContainerHasLeftSideBar`, `DockContainerHasRightSideBar`, `DockContainerHasBottomSideBar` -> Enabling each of these enables the side bar at each location. Disabling any of them would mean that the widget cannot be added at that location, so it would be added at the next available location. E.g. If you only enable `DockContainerHasRightSideBar` and `DockContainerHasBottomSideBar` then it will be added to the bottom side bar or right side bar respectively. If none of these are enabled, the auto hide button will not be added, as at least one of them must be enabled to work. +- `DockContainerHasTopSideBar`,`DockContainerHasLeftSideBar`, `DockContainerHasRightSideBar`, `DockContainerHasBottomSideBar` -> Enabling each of these enables the side bar at each location. Disabling any of them would mean that the widget cannot be added at that location, so it would be added at the next available location. E.g. If you only enable `DockContainerHasRightSideBar` and `DockContainerHasBottomSideBar` then it will be added to the bottom side bar or right side bar respectively. If none of these are enabled, the auto hide button will not be added, as at least one of them must be enabled to work. - `DockAreaHasAutoHideButton` -> Adds the auto hide button to the title bar of the dock area -- `LeftSideBarPrioritizeIconOnly`, `RightSideBarPrioritizeIconOnly`, `BottomSideBarPrioritizeIconOnly` -> If this is set, the side bar this is enabled with will prioritize showing an icon only, as opposed to an icon and text. This is set per side bar, so if you only enable `LeftSideBarPrioritizeIconOnly`, the right and bottom side bars will still show the icon and the text. This is only relevant if an icon is set, otherwise it will only show text as usual. +- `TopSideBarPrioritizeIconOnly`, `LeftSideBarPrioritizeIconOnly`, `RightSideBarPrioritizeIconOnly`, `BottomSideBarPrioritizeIconOnly` -> If this is set, the side bar this is enabled with will prioritize showing an icon only, as opposed to an icon and text. This is set per side bar, so if you only enable `LeftSideBarPrioritizeIconOnly`, the right and bottom side bars will still show the icon and the text. This is only relevant if an icon is set, otherwise it will only show text as usual. - `AutoHideDockAreaHasTitle` -> Adds the title of the dock window where the title bar would be. -- `DefaultAutoHideConfig` -> Enables `DockContainerHasLeftSideBar`, `DockContainerHasRightSideBar`, `DockContainerHasBottomSideBar`, `DockAreaHasAutoHideButton`, `AutoHideDockAreaHasTitle` +- `DefaultAutoHideConfig` -> Enables `DockContainerHasTopSideBar`, `DockContainerHasLeftSideBar`, `DockContainerHasRightSideBar`, `DockContainerHasBottomSideBar`, `DockAreaHasAutoHideButton`, `AutoHideDockAreaHasTitle` ### Limitations - Currently the `LeftBottom` and `RightBottom` areas can only be added programatically, and not through the pin icon. These are used if you'd like to add a new dock widget separated from the normal dock areas. -- Adding a `DockWidget` (e.g. via `addDockWidget`) to an overlayed `DockArea` that already has a dockwidget is undefined behavior. An overlayed dock area does not have tabs and does not support more than one `DockWidget` in it's area. If you want to add a `DockWidget` to a `DockArea` that *could* be overlayed, check first if it's overlayed via `CDockArea::isAutoHide` and handle it accordingly (typically by adding the overlay dock widget as a side tab instead of to the area). +- Adding a `DockWidget` (e.g. via `addDockWidget`) to an `DockArea` in an Auto Hide Widget that already has a dockwidget is undefined behavior. An overlayed dock area does not have tabs and does not support more than one `DockWidget` in it's area. If you want to add a `DockWidget` to a `DockArea` that *could* be in an auto hidden widget, check first if it's auto hidden via `CDockArea::isAutoHide` and handle it accordingly (typically by adding the overlay dock widget as a side tab instead of to the area). ## Styling diff --git a/src/DockManager.h b/src/DockManager.h index e9599cc..b3e6599 100644 --- a/src/DockManager.h +++ b/src/DockManager.h @@ -237,7 +237,7 @@ public: TopSideBarPrioritizeIconOnly = 0x100, //!< If the flag is set bottom side bar will prioritize showing icons only over text AutoHideDockAreaHasTitle = 0x200, //!< If the flag is set overlay dock area title bar will show the window title - DefaultAutoHideConfig = DockContainerHasLeftSideBar | BottomSideBarPrioritizeIconOnly | TopSideBarPrioritizeIconOnly + DefaultAutoHideConfig = DockContainerHasLeftSideBar | DockContainerHasRightSideBar | DockContainerHasBottomSideBar | DockContainerHasTopSideBar diff --git a/src/DockWidgetSideTab.h b/src/DockWidgetSideTab.h index bb8dc9f..6c1d26b 100644 --- a/src/DockWidgetSideTab.h +++ b/src/DockWidgetSideTab.h @@ -83,7 +83,7 @@ public: LeftBottom, RightTop, RightBottom, - Bottom + Bottom }; Q_ENUM(SideTabBarArea) From 4399f6ea29f32aba179b9a2eaaec9c161d699311 Mon Sep 17 00:00:00 2001 From: Syarif Fakhri Date: Fri, 14 Oct 2022 21:49:53 +0800 Subject: [PATCH 8/8] Update css --- src/stylesheets/default.css | 2 + src/stylesheets/default_linux.css | 63 ++++++++++++++ src/stylesheets/focus_highlighting.css | 90 ++++++++++---------- src/stylesheets/focus_highlighting_linux.css | 78 ++++++++++------- 4 files changed, 157 insertions(+), 76 deletions(-) diff --git a/src/stylesheets/default.css b/src/stylesheets/default.css index 127baed..19d8b58 100644 --- a/src/stylesheets/default.css +++ b/src/stylesheets/default.css @@ -39,6 +39,7 @@ ads--CDockWidgetTab[activeTab="true"] QLabel { color: palette(foreground); } +/* Side tab styling */ ads--CDockWidgetSideTab { background: palette(window); qproperty-iconSize: 16px 16px;/* this is optional in case you would like to change icon size*/ @@ -99,6 +100,7 @@ ads--CDockWidgetSideTab[sideTabBarArea="3"][activeTab="true"],[sideTabBarArea="4 ads--CDockWidgetSideTab[sideTabBarArea="5"][activeTab="true"] { border-bottom: 3px solid palette(highlight); } +/* Side tab styling */ ads--CDockWidget { background: palette(light); diff --git a/src/stylesheets/default_linux.css b/src/stylesheets/default_linux.css index f9161f8..2a90402 100644 --- a/src/stylesheets/default_linux.css +++ b/src/stylesheets/default_linux.css @@ -43,6 +43,69 @@ ads--CDockWidgetTab[activeTab="true"] QLabel { color: palette(foreground); } +/* Side tab styling */ +ads--CDockWidgetSideTab { + 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; +} + +ads--CDockWidgetSideTab[sideTabBarArea="1"],[sideTabBarArea="2"] { + border-left: 3px solid grey; + border-bottom: 1px solid white; +} + +ads--CDockWidgetSideTab[sideTabBarArea="3"],[sideTabBarArea="4"] { + border-right: 3px solid grey; + border-bottom: 1px solid white; +} + +ads--CDockWidgetSideTab[sideTabBarArea="5"] { + border-bottom: 3px solid grey; + border-right: 1px solid white; +} + +ads--CDockWidgetSideTab:hover[sideTabBarArea="0"] { + border-top: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab:hover[sideTabBarArea="1"],:hover[sideTabBarArea="2"] { + border-left: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab:hover[sideTabBarArea="3"],:hover[sideTabBarArea="4"] { + border-right: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab:hover[sideTabBarArea="5"] { + border-bottom: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab:hover[sideTabBarArea="0"][activeTab="true"] { + border-top: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab[sideTabBarArea="0"][activeTab="true"] { + border-top: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab[sideTabBarArea="1"][activeTab="true"],[sideTabBarArea="2"][activeTab="true"] { + border-left: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab[sideTabBarArea="3"][activeTab="true"],[sideTabBarArea="4"][focused="true"] { + border-right: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab[sideTabBarArea="5"][activeTab="true"] { + border-bottom: 3px solid palette(highlight); +} +/* Side tab styling */ + ads--CDockWidget { background: palette(light); border-color: palette(light); diff --git a/src/stylesheets/focus_highlighting.css b/src/stylesheets/focus_highlighting.css index a24aa9a..ccab906 100644 --- a/src/stylesheets/focus_highlighting.css +++ b/src/stylesheets/focus_highlighting.css @@ -22,6 +22,21 @@ ads--CDockWidgetTab { qproperty-iconSize: 16px 16px;/* this is optional in case you would like to change icon size*/ } +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);*/ +} + +ads--CDockWidgetTab QLabel { + color: palette(dark); +} + +ads--CDockWidgetTab[activeTab="true"] QLabel { + color: palette(foreground); +} + +/* Side tab styling */ ads--CDockWidgetSideTab { background: palette(window); qproperty-iconSize: 16px 16px;/* this is optional in case you would like to change icon size*/ @@ -47,20 +62,43 @@ ads--CDockWidgetSideTab[sideTabBarArea="5"] { border-right: 1px solid white; } -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);*/ +ads--CDockWidgetSideTab:hover[sideTabBarArea="0"] { + border-top: 3px solid palette(highlight); } -ads--CDockWidgetTab QLabel { - color: palette(dark); +ads--CDockWidgetSideTab:hover[sideTabBarArea="1"],:hover[sideTabBarArea="2"] { + border-left: 3px solid palette(highlight); } -ads--CDockWidgetTab[activeTab="true"] QLabel { - color: palette(foreground); +ads--CDockWidgetSideTab:hover[sideTabBarArea="3"],:hover[sideTabBarArea="4"] { + border-right: 3px solid palette(highlight); } +ads--CDockWidgetSideTab:hover[sideTabBarArea="5"] { + border-bottom: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab:hover[sideTabBarArea="0"][activeTab="true"] { + border-top: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab[sideTabBarArea="0"][activeTab="true"] { + border-top: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab[sideTabBarArea="1"][activeTab="true"],[sideTabBarArea="2"][activeTab="true"] { + border-left: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab[sideTabBarArea="3"][activeTab="true"],[sideTabBarArea="4"][focused="true"] { + border-right: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab[sideTabBarArea="5"][activeTab="true"] { + border-bottom: 3px solid palette(highlight); +} +/* Side tab styling */ + ads--CDockWidget { background: palette(light); border-color: palette(light); @@ -125,42 +163,6 @@ ads--CDockSplitter::handle { } /* Focus related styling */ -ads--CDockWidgetSideTab:hover[sideTabBarArea="0"] { - border-top: 3px solid palette(highlight); -} - -ads--CDockWidgetSideTab:hover[sideTabBarArea="1"],:hover[sideTabBarArea="2"] { - border-left: 3px solid palette(highlight); -} - -ads--CDockWidgetSideTab:hover[sideTabBarArea="3"],:hover[sideTabBarArea="4"] { - border-right: 3px solid palette(highlight); -} - -ads--CDockWidgetSideTab:hover[sideTabBarArea="5"] { - border-bottom: 3px solid palette(highlight); -} - -ads--CDockWidgetSideTab:hover[sideTabBarArea="0"][activeTab="true"] { - border-top: 3px solid palette(highlight); -} - -ads--CDockWidgetSideTab[sideTabBarArea="0"][activeTab="true"] { - border-top: 3px solid palette(highlight); -} - -ads--CDockWidgetSideTab[sideTabBarArea="1"][activeTab="true"],[sideTabBarArea="2"][activeTab="true"] { - border-left: 3px solid palette(highlight); -} - -ads--CDockWidgetSideTab[sideTabBarArea="3"][activeTab="true"],[sideTabBarArea="4"][focused="true"] { - border-right: 3px solid palette(highlight); -} - -ads--CDockWidgetSideTab[sideTabBarArea="5"][activeTab="true"] { - border-bottom: 3px solid palette(highlight); -} - ads--CDockWidgetTab[activeTab="true"] { background: palette(highlight); border-color: palette(highlight); diff --git a/src/stylesheets/focus_highlighting_linux.css b/src/stylesheets/focus_highlighting_linux.css index 594ce6b..e32c57a 100644 --- a/src/stylesheets/focus_highlighting_linux.css +++ b/src/stylesheets/focus_highlighting_linux.css @@ -44,26 +44,69 @@ ads--CDockWidgetTab[activeTab="true"] QLabel { color: palette(foreground); } +/* Side tab styling */ ads--CDockWidgetSideTab { background: palette(window); qproperty-iconSize: 16px 16px;/* this is optional in case you would like to change icon size*/ } -ads--CDockWidgetSideTab[sideTabBarArea="0"],[sideTabBarArea="1"] { +ads--CDockWidgetSideTab[sideTabBarArea="0"] { + border-top: 3px solid grey; + border-right: 1px solid white; +} + +ads--CDockWidgetSideTab[sideTabBarArea="1"],[sideTabBarArea="2"] { border-left: 3px solid grey; border-bottom: 1px solid white; } -ads--CDockWidgetSideTab[sideTabBarArea="2"],[sideTabBarArea="3"] { +ads--CDockWidgetSideTab[sideTabBarArea="3"],[sideTabBarArea="4"] { border-right: 3px solid grey; border-bottom: 1px solid white; } -ads--CDockWidgetSideTab[sideTabBarArea="4"] { +ads--CDockWidgetSideTab[sideTabBarArea="5"] { border-bottom: 3px solid grey; border-right: 1px solid white; } +ads--CDockWidgetSideTab:hover[sideTabBarArea="0"] { + border-top: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab:hover[sideTabBarArea="1"],:hover[sideTabBarArea="2"] { + border-left: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab:hover[sideTabBarArea="3"],:hover[sideTabBarArea="4"] { + border-right: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab:hover[sideTabBarArea="5"] { + border-bottom: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab:hover[sideTabBarArea="0"][activeTab="true"] { + border-top: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab[sideTabBarArea="0"][activeTab="true"] { + border-top: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab[sideTabBarArea="1"][activeTab="true"],[sideTabBarArea="2"][activeTab="true"] { + border-left: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab[sideTabBarArea="3"][activeTab="true"],[sideTabBarArea="4"][focused="true"] { + border-right: 3px solid palette(highlight); +} + +ads--CDockWidgetSideTab[sideTabBarArea="5"][activeTab="true"] { + border-bottom: 3px solid palette(highlight); +} +/* Side tab styling */ + ads--CDockWidget { background: palette(light); border-color: palette(light); @@ -124,35 +167,6 @@ QScrollArea#dockWidgetScrollArea { /* Focus related styling */ -ads--CDockWidgetSideTab:hover[sideTabBarArea="0"],:hover[sideTabBarArea="1"] { - border-left: 3px solid palette(highlight); -} - -ads--CDockWidgetSideTab:hover[sideTabBarArea="2"],:hover[sideTabBarArea="3"] { - border-right: 3px solid palette(highlight); -} - -ads--CDockWidgetSideTab:hover[sideTabBarArea="4"] { - border-bottom: 3px solid palette(highlight); -} - -ads--CDockWidgetSideTab[sideTabBarArea="0"][focused="true"],[sideTabBarArea="1"][focused="true"] { - border-left: 3px solid palette(highlight); -} - -ads--CDockWidgetSideTab[sideTabBarArea="2"][focused="true"],[sideTabBarArea="3"][focused="true"] { - border-right: 3px solid palette(highlight); -} - -ads--CDockWidgetSideTab[sideTabBarArea="4"][focused="true"] { - border-bottom: 3px solid palette(highlight); -} - -ads--CDockWidgetTab[focused="true"] { - background: palette(highlight); - border-color: palette(highlight); -} - ads--CDockWidgetTab[focused="true"]>#tabCloseButton { qproperty-icon: url(:/ads/images/close-button-focused.svg) }