mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-12 16:20:25 +08:00
Fixed delayed hiding of CAutoHideDockContainer on mouse leave when resizing
This commit is contained in:
parent
c0247fc02a
commit
279a9d7df9
@ -35,6 +35,7 @@
|
|||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QCursor>
|
||||||
|
|
||||||
#include "DockManager.h"
|
#include "DockManager.h"
|
||||||
#include "DockWidgetTab.h"
|
#include "DockWidgetTab.h"
|
||||||
@ -558,8 +559,15 @@ void CAutoHideDockContainer::resizeEvent(QResizeEvent* event)
|
|||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CAutoHideDockContainer::leaveEvent(QEvent *event)
|
void CAutoHideDockContainer::leaveEvent(QEvent *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);
|
d->forwardEventToDockContainer(event);
|
||||||
|
}
|
||||||
Super::leaveEvent(event);
|
Super::leaveEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,41 +94,17 @@ AutoHideTabPrivate::AutoHideTabPrivate(CAutoHideTab* _public) :
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void AutoHideTabPrivate::updateOrientation()
|
void AutoHideTabPrivate::updateOrientation()
|
||||||
{
|
{
|
||||||
auto area = SideBar->sideBarLocation();
|
bool IconOnly = CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideSideBarsIconOnly);
|
||||||
_this->setOrientation((area == SideBarBottom || area == SideBarTop) ? Qt::Horizontal : Qt::Vertical);
|
if (IconOnly && !_this->icon().isNull())
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
_this->setText("");
|
_this->setText("");
|
||||||
_this->setOrientation(Qt::Horizontal);
|
_this->setOrientation(Qt::Horizontal);
|
||||||
|
_this->updateStyle();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto area = SideBar->sideBarLocation();
|
||||||
|
_this->setOrientation((area == SideBarBottom || area == SideBarTop) ? Qt::Horizontal : Qt::Vertical);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,7 +381,6 @@ DockContainerWidgetPrivate::DockContainerWidgetPrivate(CDockContainerWidget* _pu
|
|||||||
DelayedAutoHideTimer.setSingleShot(true);
|
DelayedAutoHideTimer.setSingleShot(true);
|
||||||
DelayedAutoHideTimer.setInterval(500);
|
DelayedAutoHideTimer.setInterval(500);
|
||||||
QObject::connect(&DelayedAutoHideTimer, &QTimer::timeout, [this](){
|
QObject::connect(&DelayedAutoHideTimer, &QTimer::timeout, [this](){
|
||||||
qDebug() << "DelayedAutoHideTimer timeout";
|
|
||||||
auto GlobalPos = DelayedAutoHideTab->mapToGlobal(QPoint(0, 0));
|
auto GlobalPos = DelayedAutoHideTab->mapToGlobal(QPoint(0, 0));
|
||||||
qApp->sendEvent(DelayedAutoHideTab, new QMouseEvent(QEvent::MouseButtonPress,
|
qApp->sendEvent(DelayedAutoHideTab, new QMouseEvent(QEvent::MouseButtonPress,
|
||||||
QPoint(0, 0), GlobalPos, Qt::LeftButton, {Qt::LeftButton}, Qt::NoModifier));
|
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<CAutoHideTab*>(w);
|
auto AutoHideTab = qobject_cast<CAutoHideTab*>(w);
|
||||||
if (AutoHideTab)
|
if (AutoHideTab)
|
||||||
{
|
{
|
||||||
qDebug() << "Event AutoHideTab " << e;
|
|
||||||
switch (e->type())
|
switch (e->type())
|
||||||
{
|
{
|
||||||
case QEvent::Enter:
|
case QEvent::Enter:
|
||||||
@ -2094,11 +2092,23 @@ void CDockContainerWidget::handleAutoHideWidgetEvent(QEvent* e, QWidget* w)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QEvent::Leave:
|
|
||||||
case QEvent::MouseButtonPress:
|
case QEvent::MouseButtonPress:
|
||||||
d->DelayedAutoHideTimer.stop();
|
d->DelayedAutoHideTimer.stop();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case QEvent::Leave:
|
||||||
|
if (AutoHideTab->dockWidget()->isVisible())
|
||||||
|
{
|
||||||
|
d->DelayedAutoHideTab = AutoHideTab;
|
||||||
|
d->DelayedAutoHideShow = false;
|
||||||
|
d->DelayedAutoHideTimer.start();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d->DelayedAutoHideTimer.stop();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2108,7 +2118,6 @@ void CDockContainerWidget::handleAutoHideWidgetEvent(QEvent* e, QWidget* w)
|
|||||||
auto AutoHideContainer = qobject_cast<CAutoHideDockContainer*>(w);
|
auto AutoHideContainer = qobject_cast<CAutoHideDockContainer*>(w);
|
||||||
if (AutoHideContainer)
|
if (AutoHideContainer)
|
||||||
{
|
{
|
||||||
qDebug() << "Event AutoHideContainer " << e;
|
|
||||||
switch (e->type())
|
switch (e->type())
|
||||||
{
|
{
|
||||||
case QEvent::Enter:
|
case QEvent::Enter:
|
||||||
|
@ -238,12 +238,8 @@ public:
|
|||||||
DockAreaHasAutoHideButton = 0x02, //!< If the flag is set each dock area has a auto hide menu button
|
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
|
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.
|
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
|
AutoHideSideBarsIconOnly = 0x10,///< show only icons in auto hide side tab - if a tab has no icon, then the text will be shown
|
||||||
RightSideBarIconOnly = 0x20, //!< If the flag is set right side bar will show only icon if a the dock widget has an icon assigned
|
ShowAutoHideOnMouseOver = 0x20, ///< show the auto hide window on mouse over tab and hide it if mouse leaves auto hide container
|
||||||
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
|
|
||||||
|
|
||||||
DefaultAutoHideConfig = AutoHideFeatureEnabled
|
DefaultAutoHideConfig = AutoHideFeatureEnabled
|
||||||
| DockAreaHasAutoHideButton ///< the default configuration for left and right side bars
|
| DockAreaHasAutoHideButton ///< the default configuration for left and right side bars
|
||||||
|
@ -179,6 +179,12 @@ ads--CAutoHideTab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ads--CAutoHideTab:hover
|
||||||
|
{
|
||||||
|
color: palette(highlight);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ads--CAutoHideTab[sideBarLocation="0"],
|
ads--CAutoHideTab[sideBarLocation="0"],
|
||||||
ads--CAutoHideTab[sideBarLocation="2"] {
|
ads--CAutoHideTab[sideBarLocation="2"] {
|
||||||
border-top: 6px solid rgba(0, 0, 0, 48);
|
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="0"],
|
||||||
ads--CAutoHideTab:hover[sideBarLocation="2"] {
|
ads--CAutoHideTab:hover[sideBarLocation="2"] {
|
||||||
border-top: 6px solid palette(highlight);
|
border-top: 6px solid palette(highlight);
|
||||||
color: palette(highlight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ads--CAutoHideTab:hover[sideBarLocation="1"],
|
ads--CAutoHideTab:hover[sideBarLocation="1"],
|
||||||
ads--CAutoHideTab:hover[sideBarLocation="3"] {
|
ads--CAutoHideTab:hover[sideBarLocation="3"] {
|
||||||
border-bottom: 6px solid palette(highlight);
|
border-bottom: 6px solid palette(highlight);
|
||||||
color: palette(highlight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ads--CAutoHideTab[sideBarLocation="0"][activeTab="true"],
|
ads--CAutoHideTab[sideBarLocation="0"][activeTab="true"],
|
||||||
@ -217,6 +221,7 @@ ads--CAutoHideTab[sideBarLocation="3"][activeTab="true"] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* CAutoHideSideBar
|
* CAutoHideSideBar
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user