From 279a9d7df9800a59977223deaed5c15e946da9e9 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Fri, 4 Nov 2022 09:41:00 +0100 Subject: [PATCH] Fixed delayed hiding of CAutoHideDockContainer on mouse leave when resizing --- src/AutoHideDockContainer.cpp | 10 ++++++- src/AutoHideTab.cpp | 40 ++++++-------------------- src/DockContainerWidget.cpp | 17 ++++++++--- src/DockManager.h | 8 ++---- src/stylesheets/focus_highlighting.css | 9 ++++-- 5 files changed, 39 insertions(+), 45 deletions(-) diff --git a/src/AutoHideDockContainer.cpp b/src/AutoHideDockContainer.cpp index 7ddec6f..7dae896 100644 --- a/src/AutoHideDockContainer.cpp +++ b/src/AutoHideDockContainer.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include "DockManager.h" #include "DockWidgetTab.h" @@ -559,7 +560,14 @@ void CAutoHideDockContainer::resizeEvent(QResizeEvent* event) //============================================================================ void CAutoHideDockContainer::leaveEvent(QEvent *event) { - d->forwardEventToDockContainer(event); + // Resizing of the dock container via the resize handle in non opaque mode + // mays cause a leave event that is not really a leave event. Therefore + // we check here, if we are really outside of our rect. + auto pos = mapFromGlobal(QCursor::pos()); + if (!rect().contains(pos)) + { + d->forwardEventToDockContainer(event); + } Super::leaveEvent(event); } diff --git a/src/AutoHideTab.cpp b/src/AutoHideTab.cpp index 9a81260..3d7e3fa 100644 --- a/src/AutoHideTab.cpp +++ b/src/AutoHideTab.cpp @@ -94,41 +94,17 @@ AutoHideTabPrivate::AutoHideTabPrivate(CAutoHideTab* _public) : //============================================================================ void AutoHideTabPrivate::updateOrientation() { - auto area = SideBar->sideBarLocation(); - _this->setOrientation((area == SideBarBottom || area == SideBarTop) ? Qt::Horizontal : Qt::Vertical); - - if (_this->icon().isNull()) - { - return; - } - - bool IconOnly = false; - switch (area) - { - case SideBarLocation::SideBarLeft: - IconOnly = CDockManager::testAutoHideConfigFlag(CDockManager::LeftSideBarIconOnly); - break; - - case SideBarLocation::SideBarRight: - IconOnly = CDockManager::testAutoHideConfigFlag(CDockManager::RightSideBarIconOnly); - break; - - case SideBarLocation::SideBarTop: - IconOnly = CDockManager::testAutoHideConfigFlag(CDockManager::BottomSideBarIconOnly); - break; - - case SideBarLocation::SideBarBottom: - IconOnly = CDockManager::testAutoHideConfigFlag(CDockManager::TopSideBarIconOnly); - break; - - default: - break; - } - - if (IconOnly) + bool IconOnly = CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideSideBarsIconOnly); + if (IconOnly && !_this->icon().isNull()) { _this->setText(""); _this->setOrientation(Qt::Horizontal); + _this->updateStyle(); + } + else + { + auto area = SideBar->sideBarLocation(); + _this->setOrientation((area == SideBarBottom || area == SideBarTop) ? Qt::Horizontal : Qt::Vertical); } } diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index 141debc..2ddb1ab 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -381,7 +381,6 @@ DockContainerWidgetPrivate::DockContainerWidgetPrivate(CDockContainerWidget* _pu DelayedAutoHideTimer.setSingleShot(true); DelayedAutoHideTimer.setInterval(500); QObject::connect(&DelayedAutoHideTimer, &QTimer::timeout, [this](){ - qDebug() << "DelayedAutoHideTimer timeout"; auto GlobalPos = DelayedAutoHideTab->mapToGlobal(QPoint(0, 0)); qApp->sendEvent(DelayedAutoHideTab, new QMouseEvent(QEvent::MouseButtonPress, QPoint(0, 0), GlobalPos, Qt::LeftButton, {Qt::LeftButton}, Qt::NoModifier)); @@ -2078,7 +2077,6 @@ void CDockContainerWidget::handleAutoHideWidgetEvent(QEvent* e, QWidget* w) auto AutoHideTab = qobject_cast(w); if (AutoHideTab) { - qDebug() << "Event AutoHideTab " << e; switch (e->type()) { case QEvent::Enter: @@ -2094,11 +2092,23 @@ void CDockContainerWidget::handleAutoHideWidgetEvent(QEvent* e, QWidget* w) } break; - case QEvent::Leave: case QEvent::MouseButtonPress: d->DelayedAutoHideTimer.stop(); break; + case QEvent::Leave: + if (AutoHideTab->dockWidget()->isVisible()) + { + d->DelayedAutoHideTab = AutoHideTab; + d->DelayedAutoHideShow = false; + d->DelayedAutoHideTimer.start(); + } + else + { + d->DelayedAutoHideTimer.stop(); + } + break; + default: break; } @@ -2108,7 +2118,6 @@ void CDockContainerWidget::handleAutoHideWidgetEvent(QEvent* e, QWidget* w) auto AutoHideContainer = qobject_cast(w); if (AutoHideContainer) { - qDebug() << "Event AutoHideContainer " << e; switch (e->type()) { case QEvent::Enter: diff --git a/src/DockManager.h b/src/DockManager.h index ceb16f3..4fb3c8d 100644 --- a/src/DockManager.h +++ b/src/DockManager.h @@ -238,12 +238,8 @@ public: DockAreaHasAutoHideButton = 0x02, //!< If the flag is set each dock area has a auto hide menu button AutoHideButtonTogglesArea = 0x04, //!< 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 = 0x08, //!< If the flag is set, the auto hide button will be checked and unchecked depending on the auto hide state. Mainly for styling purposes. - LeftSideBarIconOnly = 0x10, //!< If the flag is set left side bar will show only icon if a the dock widget has an icon assigned - RightSideBarIconOnly = 0x20, //!< If the flag is set right side bar will show only icon if a the dock widget has an icon assigned - BottomSideBarIconOnly = 0x40,//!< If the flag is set bottom side show only icon if a the dock widget has an icon assigned - TopSideBarIconOnly = 0x80, //!< If the flag is set top side bar show only icon if a the dock widget has an icon assigned - AutoHideSideBarsIconOnly = LeftSideBarIconOnly | RightSideBarIconOnly | BottomSideBarIconOnly | TopSideBarIconOnly, - ShowAutoHideOnMouseOver = 0x100, ///< show the auto hide window on mouse over tab and hide it if mouse leaves auto hide container + AutoHideSideBarsIconOnly = 0x10,///< show only icons in auto hide side tab - if a tab has no icon, then the text will be shown + ShowAutoHideOnMouseOver = 0x20, ///< show the auto hide window on mouse over tab and hide it if mouse leaves auto hide container DefaultAutoHideConfig = AutoHideFeatureEnabled | DockAreaHasAutoHideButton ///< the default configuration for left and right side bars diff --git a/src/stylesheets/focus_highlighting.css b/src/stylesheets/focus_highlighting.css index 1057769..3b01452 100644 --- a/src/stylesheets/focus_highlighting.css +++ b/src/stylesheets/focus_highlighting.css @@ -179,6 +179,12 @@ ads--CAutoHideTab { } +ads--CAutoHideTab:hover +{ + color: palette(highlight); +} + + ads--CAutoHideTab[sideBarLocation="0"], ads--CAutoHideTab[sideBarLocation="2"] { border-top: 6px solid rgba(0, 0, 0, 48); @@ -195,14 +201,12 @@ ads--CAutoHideTab[sideBarLocation="3"] { ads--CAutoHideTab:hover[sideBarLocation="0"], ads--CAutoHideTab:hover[sideBarLocation="2"] { border-top: 6px solid palette(highlight); - color: palette(highlight); } ads--CAutoHideTab:hover[sideBarLocation="1"], ads--CAutoHideTab:hover[sideBarLocation="3"] { border-bottom: 6px solid palette(highlight); - color: palette(highlight); } ads--CAutoHideTab[sideBarLocation="0"][activeTab="true"], @@ -217,6 +221,7 @@ ads--CAutoHideTab[sideBarLocation="3"][activeTab="true"] { } + /***************************************************************************** * CAutoHideSideBar *****************************************************************************/