diff --git a/doc/cfg_flag_AutoHideOpenOnDragHover.gif b/doc/cfg_flag_AutoHideOpenOnDragHover.gif
new file mode 100644
index 0000000..8b62e26
Binary files /dev/null and b/doc/cfg_flag_AutoHideOpenOnDragHover.gif differ
diff --git a/doc/user-guide.md b/doc/user-guide.md
index e59bae6..4edf7a6 100644
--- a/doc/user-guide.md
+++ b/doc/user-guide.md
@@ -49,6 +49,7 @@
- [`AutoHideCloseButtonCollapsesDock`](#autohideclosebuttoncollapsesdock)
- [`AutoHideHasCloseButton`](#autohidehasclosebutton)
- [`AutoHideHasMinimizeButton`](#autohidehasminimizebutton)
+ - [`AutoHideOpenOnDragHover`](#autohideopenondraghover)
- [DockWidget Feature Flags](#dockwidget-feature-flags)
- [`DockWidgetClosable`](#dockwidgetclosable)
- [`DockWidgetMovable`](#dockwidgetmovable)
@@ -150,7 +151,7 @@ This ie enabled by default to minimize the size of the saved data.
### `TabCloseButtonIsToolButton`
-If enabled the tab close buttons will be `QToolButtons` instead of `QPushButtons` -
+If enabled the tab close buttons will be `QToolButtons` instead of `QPushButtons` -
disabled by default. Normally the default configuration should be ok but if your
application requires `QToolButtons` instead of `QPushButtons` for styling reasons
or for any other reasons, then you can enable this flag.
@@ -181,7 +182,7 @@ constant, that means, if enabled, the tabs need more space.
### `DragPreviewIsDynamic`
-If non-opaque undocking is enabled, this flag defines the behavior of the drag
+If non-opaque undocking is enabled, this flag defines the behavior of the drag
preview window. If this flag is enabled, then it will give the user the
impression, that the floating drag preview is dynamically adjusted to the drop
area. In order to give the perfect impression, you should disable the flags
@@ -197,7 +198,7 @@ CDockManager::setConfigFlag(CDockManager::DragPreviewHasWindowFrame, false);
### `DragPreviewShowsContentPixmap`
-If non-opaque undocking is enabled, the created drag preview window shows a
+If non-opaque undocking is enabled, the created drag preview window shows a
copy of the content of the dock widget / dock are that is dragged, if this
flag is enabled (default).
@@ -210,7 +211,7 @@ like window without any content.
### `DragPreviewHasWindowFrame`
-If non-opaque undocking is enabled, then this flag configures if the drag
+If non-opaque undocking is enabled, then this flag configures if the drag
preview is frameless (default) or looks like a real window. If it is enabled,
then the drag preview is a transparent window with a system window frame.
@@ -378,7 +379,7 @@ ads--CDockAreaWidget[focused="true"] ads--CDockAreaTitleBar
If you have a content widget that does not support focussing for some reason
(like `QVTKOpenGLStereoWidget` from the [VTK library](https://github.com/Kitware/VTK)),
-then you can manually switch the focus by reacting on mouse events. The
+then you can manually switch the focus by reacting on mouse events. The
following code shows, how to install en event filter on the `QVTKOpenGLStereoWidget`
to properly switch the focus on `QEvent::MouseButtonPress`:
@@ -422,7 +423,7 @@ bool CMainWindow::eventFilter(QObject *watched, QEvent *event)
### `EqualSplitOnInsertion`
This flag configures how the space is distributed if a new dock widget is
-inserted into an existing dock area. The flag is disabled by default. If 3
+inserted into an existing dock area. The flag is disabled by default. If 3
dock widgets are inserted with the following code
```c++
@@ -433,7 +434,7 @@ then this is the result, if the flag is disabled:
![EqualSplitOnInsertion false](cfg_flag_EqualSplitOnInsertion_false.png)
-If the flag is enabled, then the space is equally distributed to all widgets
+If the flag is enabled, then the space is equally distributed to all widgets
in a splitter:
![EqualSplitOnInsertion true](cfg_flag_EqualSplitOnInsertion_true.png)
@@ -501,7 +502,7 @@ for active tabs. Inactive tabs only show their icon:
The Advanced Docking System supports "Auto-Hide" functionality for **all**
dock containers. The "Auto Hide" feature allows to display more information
-using less screen space by hiding or showing windows pinned to one of the
+using less screen space by hiding or showing windows pinned to one of the
four dock container borders.
Enabling this feature adds a button with a pin icon to each dock area.
@@ -563,7 +564,7 @@ That means, you can drag them to a different border or sidebar:
### Auto-Hide Tab Sorting
-You can drag Auto-Hide tabs to a new position in the current sidebar
+You can drag Auto-Hide tabs to a new position in the current sidebar
to sort them:
![Auo-Hide sort tabs](AutoHide_Sort_Tabs.gif)
@@ -632,7 +633,7 @@ the other Auto-Hide flags will be evaluated.
### `DockAreaHasAutoHideButton`
-If this flag is set (default), then each dock area has a pin button in the title
+If this flag is set (default), then each dock area has a pin button in the title
bar to toggle Auto-Hide state.
![DockAreaHasAutoHideButton true](cfg_flag_DockAreaHasAutoHideButton.png)
@@ -676,7 +677,7 @@ works if this feature is enabled.
Some users don't understand the distinction between closing an auto hide dock and
collapsing an auto hide dock. This may lead to situations where they press the
close button (losing the side tab widget) instead of simply clicking outside
-the auto hide dock (collapsing the dock).
+the auto hide dock (collapsing the dock).
![AutoHideCloseButtonCollapsesDock false](cfg_flag_AutoHideCloseButtonCollapsesDock_false.gif)
@@ -704,6 +705,15 @@ If this flag is set (disabled by default), then each auto hide widget has a mini
![AutoHideHasMinimizeButton](cfg_flag_AutoHideHasMinimizeButton.png)
+
+### `AutoHideOpenOnDragHover`
+
+If this flag is set (disabled by default), then holding a dragging cursor hover an auto-hide collapsed dock's tab will open said dock:
+
+![AutoHideOpenOnDragHover](cfg_flag_AutoHideOpenOnDragHover.gif)
+
+Said dock must be set to accept drops to hide when cursor leaves its scope.
+
## DockWidget Feature Flags
### `DockWidgetClosable`
diff --git a/src/AutoHideDockContainer.cpp b/src/AutoHideDockContainer.cpp
index 44af9e2..6a2f59b 100644
--- a/src/AutoHideDockContainer.cpp
+++ b/src/AutoHideDockContainer.cpp
@@ -16,7 +16,6 @@
** License along with this library; If not, see .
******************************************************************************/
-
//============================================================================
/// \file AutoHideDockContainer.cpp
/// \author Syarif Fakhri
@@ -29,24 +28,24 @@
//============================================================================
#include "AutoHideDockContainer.h"
-#include
-#include
-#include
-#include
-#include
#include
+#include
#include
-
-#include "DockManager.h"
-#include "DockAreaWidget.h"
-#include "ResizeHandle.h"
-#include "DockComponentsFactory.h"
-#include "AutoHideSideBar.h"
-#include "AutoHideTab.h"
-
+#include
+#include
+#include
+#include
#include
+#include "AutoHideSideBar.h"
+#include "AutoHideTab.h"
+#include "DockAreaWidget.h"
+#include "DockComponentsFactory.h"
+#include "DockManager.h"
+#include "ResizeHandle.h"
+#include "ads_globals.h"
+
namespace ads
{
static const int ResizeMargin = 30;
@@ -54,453 +53,439 @@ static const int ResizeMargin = 30;
//============================================================================
bool static isHorizontalArea(SideBarLocation Area)
{
- switch (Area)
- {
- case SideBarLocation::SideBarTop:
- case SideBarLocation::SideBarBottom: return true;
- case SideBarLocation::SideBarLeft:
- case SideBarLocation::SideBarRight: return false;
- default:
- return true;
- }
+ switch (Area)
+ {
+ case SideBarLocation::SideBarTop:
+ case SideBarLocation::SideBarBottom: return true;
+ case SideBarLocation::SideBarLeft:
+ case SideBarLocation::SideBarRight: return false;
+ default: return true;
+ }
- return true;
+ return true;
}
-
//============================================================================
Qt::Edge static edgeFromSideTabBarArea(SideBarLocation Area)
{
- switch (Area)
- {
- case SideBarLocation::SideBarTop: return Qt::BottomEdge;
- case SideBarLocation::SideBarBottom: return Qt::TopEdge;
- case SideBarLocation::SideBarLeft: return Qt::RightEdge;
- case SideBarLocation::SideBarRight: return Qt::LeftEdge;
- default:
- return Qt::LeftEdge;
- }
+ switch (Area)
+ {
+ case SideBarLocation::SideBarTop: return Qt::BottomEdge;
+ case SideBarLocation::SideBarBottom: return Qt::TopEdge;
+ case SideBarLocation::SideBarLeft: return Qt::RightEdge;
+ case SideBarLocation::SideBarRight: return Qt::LeftEdge;
+ default: return Qt::LeftEdge;
+ }
- return Qt::LeftEdge;
+ return Qt::LeftEdge;
}
-
//============================================================================
int resizeHandleLayoutPosition(SideBarLocation Area)
{
- switch (Area)
- {
- case SideBarLocation::SideBarBottom:
- case SideBarLocation::SideBarRight: return 0;
+ switch (Area)
+ {
+ case SideBarLocation::SideBarBottom:
+ case SideBarLocation::SideBarRight: return 0;
- case SideBarLocation::SideBarTop:
- case SideBarLocation::SideBarLeft: return 1;
+ case SideBarLocation::SideBarTop:
+ case SideBarLocation::SideBarLeft: return 1;
- default:
- return 0;
- }
+ default: return 0;
+ }
- return 0;
+ return 0;
}
-
/**
* Private data of CAutoHideDockContainer - pimpl
*/
struct AutoHideDockContainerPrivate
{
CAutoHideDockContainer* _this;
- CDockAreaWidget* DockArea{nullptr};
- CDockWidget* DockWidget{nullptr};
- SideBarLocation SideTabBarArea = SideBarNone;
- QBoxLayout* Layout = nullptr;
- CResizeHandle* ResizeHandle = nullptr;
- QSize Size; // creates invalid size
- QPointer SideTab;
- QSize SizeCache;
+ CDockAreaWidget* DockArea{nullptr};
+ CDockWidget* DockWidget{nullptr};
+ SideBarLocation SideTabBarArea = SideBarNone;
+ QBoxLayout* Layout = nullptr;
+ CResizeHandle* ResizeHandle = nullptr;
+ QSize Size; // creates invalid size
+ QPointer SideTab;
+ QSize SizeCache;
- /**
- * Private data constructor
- */
- AutoHideDockContainerPrivate(CAutoHideDockContainer *_public);
+ /**
+ * Private data constructor
+ */
+ AutoHideDockContainerPrivate(CAutoHideDockContainer* _public);
- /**
- * Convenience function to get a dock widget area
- */
- DockWidgetArea getDockWidgetArea(SideBarLocation area)
- {
+ /**
+ * Convenience function to get a dock widget area
+ */
+ DockWidgetArea getDockWidgetArea(SideBarLocation area)
+ {
switch (area)
{
- case SideBarLocation::SideBarLeft: return LeftDockWidgetArea;
- case SideBarLocation::SideBarRight: return RightDockWidgetArea;
- case SideBarLocation::SideBarBottom: return BottomDockWidgetArea;
- case SideBarLocation::SideBarTop: return TopDockWidgetArea;
- default:
- return LeftDockWidgetArea;
+ case SideBarLocation::SideBarLeft: return LeftDockWidgetArea;
+ case SideBarLocation::SideBarRight: return RightDockWidgetArea;
+ case SideBarLocation::SideBarBottom: return BottomDockWidgetArea;
+ case SideBarLocation::SideBarTop: return TopDockWidgetArea;
+ default: return LeftDockWidgetArea;
}
- return LeftDockWidgetArea;
- }
+ return LeftDockWidgetArea;
+ }
- /**
- * Update the resize limit of the resize handle
- */
- void updateResizeHandleSizeLimitMax()
- {
- auto Rect = _this->dockContainer()->contentRect();
- const auto maxResizeHandleSize = ResizeHandle->orientation() == Qt::Horizontal
- ? Rect.width() : Rect.height();
- ResizeHandle->setMaxResizeSize(maxResizeHandleSize - ResizeMargin);
- }
+ /**
+ * Update the resize limit of the resize handle
+ */
+ void updateResizeHandleSizeLimitMax()
+ {
+ auto Rect = _this->dockContainer()->contentRect();
+ const auto maxResizeHandleSize =
+ ResizeHandle->orientation() == Qt::Horizontal ? Rect.width() :
+ Rect.height();
+ ResizeHandle->setMaxResizeSize(maxResizeHandleSize - ResizeMargin);
+ }
- /**
- * Convenience function to check, if this is an horizontal area
- */
- bool isHorizontal() const
- {
- return isHorizontalArea(SideTabBarArea);
- }
+ /**
+ * Convenience function to check, if this is an horizontal area
+ */
+ bool isHorizontal() const { return isHorizontalArea(SideTabBarArea); }
- /**
- * Forward this event to the dock container
- */
- void forwardEventToDockContainer(QEvent* event)
- {
- auto DockContainer = _this->dockContainer();
- if (DockContainer)
- {
- DockContainer->handleAutoHideWidgetEvent(event, _this);
- }
- }
-
-}; // struct AutoHideDockContainerPrivate
+ /**
+ * Forward this event to the dock container
+ */
+ void forwardEventToDockContainer(QEvent* event)
+ {
+ auto DockContainer = _this->dockContainer();
+ if (DockContainer)
+ {
+ DockContainer->handleAutoHideWidgetEvent(event, _this);
+ }
+ }
+}; // struct AutoHideDockContainerPrivate
//============================================================================
AutoHideDockContainerPrivate::AutoHideDockContainerPrivate(
- CAutoHideDockContainer *_public) :
- _this(_public)
-{
-
-}
-
+ CAutoHideDockContainer* _public)
+ : _this(_public)
+{}
//============================================================================
CDockContainerWidget* CAutoHideDockContainer::dockContainer() const
{
- return internal::findParent(this);
+ return internal::findParent(this);
}
-
//============================================================================
-CAutoHideDockContainer::CAutoHideDockContainer(CDockWidget* DockWidget, SideBarLocation area, CDockContainerWidget* parent) :
- Super(parent),
- d(new AutoHideDockContainerPrivate(this))
+CAutoHideDockContainer::CAutoHideDockContainer(CDockWidget* DockWidget,
+ SideBarLocation area,
+ CDockContainerWidget* parent)
+ : Super(parent), d(new AutoHideDockContainerPrivate(this))
{
- hide(); // auto hide dock container is initially always hidden
- d->SideTabBarArea = area;
- d->SideTab = componentsFactory()->createDockWidgetSideTab(nullptr);
- connect(d->SideTab, &CAutoHideTab::pressed, this, &CAutoHideDockContainer::toggleCollapseState);
- d->DockArea = new CDockAreaWidget(DockWidget->dockManager(), parent);
- d->DockArea->setObjectName("autoHideDockArea");
- d->DockArea->setAutoHideDockContainer(this);
+ hide(); // auto hide dock container is initially always hidden
+ d->SideTabBarArea = area;
+ d->SideTab = componentsFactory()->createDockWidgetSideTab(nullptr);
+ connect(d->SideTab, &CAutoHideTab::pressed, this,
+ &CAutoHideDockContainer::toggleCollapseState);
+ d->DockArea = new CDockAreaWidget(DockWidget->dockManager(), parent);
+ d->DockArea->setObjectName("autoHideDockArea");
+ d->DockArea->setAutoHideDockContainer(this);
- setObjectName("autoHideDockContainer");
+ setObjectName("autoHideDockContainer");
- d->Layout = new QBoxLayout(isHorizontalArea(area) ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight);
- d->Layout->setContentsMargins(0, 0, 0, 0);
- d->Layout->setSpacing(0);
- setLayout(d->Layout);
- d->ResizeHandle = new CResizeHandle(edgeFromSideTabBarArea(area), this);
- d->ResizeHandle->setMinResizeSize(64);
- bool OpaqueResize = CDockManager::testConfigFlag(CDockManager::OpaqueSplitterResize);
- d->ResizeHandle->setOpaqueResize(OpaqueResize);
- d->Size = d->DockArea->size();
- d->SizeCache = DockWidget->size();
+ d->Layout = new QBoxLayout(isHorizontalArea(area) ? QBoxLayout::TopToBottom :
+ QBoxLayout::LeftToRight);
+ d->Layout->setContentsMargins(0, 0, 0, 0);
+ d->Layout->setSpacing(0);
+ setLayout(d->Layout);
+ d->ResizeHandle = new CResizeHandle(edgeFromSideTabBarArea(area), this);
+ d->ResizeHandle->setMinResizeSize(64);
+ bool OpaqueResize =
+ CDockManager::testConfigFlag(CDockManager::OpaqueSplitterResize);
+ d->ResizeHandle->setOpaqueResize(OpaqueResize);
+ d->Size = d->DockArea->size();
+ d->SizeCache = DockWidget->size();
- addDockWidget(DockWidget);
- parent->registerAutoHideWidget(this);
- // The dock area should not be added to the layout before it contains the
- // dock widget. If you add it to the layout before it contains the dock widget
- // then you will likely see this warning for OpenGL widgets or QAxWidgets:
- // setGeometry: Unable to set geometry XxY+Width+Height on QWidgetWindow/'WidgetClassWindow
- d->Layout->addWidget(d->DockArea);
- d->Layout->insertWidget(resizeHandleLayoutPosition(area), d->ResizeHandle);
+ addDockWidget(DockWidget);
+ parent->registerAutoHideWidget(this);
+ // The dock area should not be added to the layout before it contains the
+ // dock widget. If you add it to the layout before it contains the dock widget
+ // then you will likely see this warning for OpenGL widgets or QAxWidgets:
+ // setGeometry: Unable to set geometry XxY+Width+Height on
+ // QWidgetWindow/'WidgetClassWindow
+ d->Layout->addWidget(d->DockArea);
+ d->Layout->insertWidget(resizeHandleLayoutPosition(area), d->ResizeHandle);
}
-
//============================================================================
void CAutoHideDockContainer::updateSize()
{
- auto dockContainerParent = dockContainer();
- if (!dockContainerParent)
- {
- return;
- }
+ auto dockContainerParent = dockContainer();
+ if (!dockContainerParent)
+ {
+ return;
+ }
- auto rect = dockContainerParent->contentRect();
- switch (sideBarLocation())
- {
- case SideBarLocation::SideBarTop:
- resize(rect.width(), qMin(rect.height() - ResizeMargin, d->Size.height()));
- move(rect.topLeft());
- break;
+ auto rect = dockContainerParent->contentRect();
+ switch (sideBarLocation())
+ {
+ case SideBarLocation::SideBarTop:
+ resize(rect.width(),
+ qMin(rect.height() - ResizeMargin, d->Size.height()));
+ move(rect.topLeft());
+ break;
- case SideBarLocation::SideBarLeft:
- resize(qMin(d->Size.width(), rect.width() - ResizeMargin), rect.height());
- move(rect.topLeft());
- break;
+ case SideBarLocation::SideBarLeft:
+ resize(qMin(d->Size.width(), rect.width() - ResizeMargin), rect.height());
+ move(rect.topLeft());
+ break;
- case SideBarLocation::SideBarRight:
- {
- resize(qMin(d->Size.width(), rect.width() - ResizeMargin), rect.height());
- QPoint p = rect.topRight();
- p.rx() -= (width() - 1);
- move(p);
- }
- break;
+ case SideBarLocation::SideBarRight:
+ {
+ resize(qMin(d->Size.width(), rect.width() - ResizeMargin), rect.height());
+ QPoint p = rect.topRight();
+ p.rx() -= (width() - 1);
+ move(p);
+ }
+ break;
- case SideBarLocation::SideBarBottom:
- {
- resize(rect.width(), qMin(rect.height() - ResizeMargin, d->Size.height()));
- QPoint p = rect.bottomLeft();
- p.ry() -= (height() - 1);
- move(p);
- }
- break;
+ case SideBarLocation::SideBarBottom:
+ {
+ resize(rect.width(),
+ qMin(rect.height() - ResizeMargin, d->Size.height()));
+ QPoint p = rect.bottomLeft();
+ p.ry() -= (height() - 1);
+ move(p);
+ }
+ break;
- default:
- break;
- }
+ default: break;
+ }
- if (orientation() == Qt::Horizontal)
- {
- d->SizeCache.setHeight(this->height());
- }
- else
- {
- d->SizeCache.setWidth(this->width());
- }
+ if (orientation() == Qt::Horizontal)
+ {
+ d->SizeCache.setHeight(this->height());
+ }
+ else
+ {
+ d->SizeCache.setWidth(this->width());
+ }
}
//============================================================================
CAutoHideDockContainer::~CAutoHideDockContainer()
{
- ADS_PRINT("~CAutoHideDockContainer");
+ ADS_PRINT("~CAutoHideDockContainer");
- // Remove event filter in case there are any queued messages
- qApp->removeEventFilter(this);
- if (dockContainer())
- {
- dockContainer()->removeAutoHideWidget(this);
- }
+ // Remove event filter in case there are any queued messages
+ qApp->removeEventFilter(this);
+ if (dockContainer())
+ {
+ dockContainer()->removeAutoHideWidget(this);
+ }
- if (d->SideTab)
- {
- delete d->SideTab;
- }
+ if (d->SideTab)
+ {
+ delete d->SideTab;
+ }
- delete d;
+ delete d;
}
//============================================================================
CAutoHideSideBar* CAutoHideDockContainer::autoHideSideBar() const
{
- if (d->SideTab)
- {
- return d->SideTab->sideBar();
- }
- else
- {
- auto DockContainer = dockContainer();
- return DockContainer ? DockContainer->autoHideSideBar(d->SideTabBarArea) : nullptr;
- }
+ if (d->SideTab)
+ {
+ return d->SideTab->sideBar();
+ }
+ else
+ {
+ auto DockContainer = dockContainer();
+ return DockContainer ? DockContainer->autoHideSideBar(d->SideTabBarArea) :
+ nullptr;
+ }
}
-
//============================================================================
CAutoHideTab* CAutoHideDockContainer::autoHideTab() const
{
- return d->SideTab;
+ return d->SideTab;
}
-
//============================================================================
CDockWidget* CAutoHideDockContainer::dockWidget() const
{
- return d->DockWidget;
+ return d->DockWidget;
}
//============================================================================
void CAutoHideDockContainer::addDockWidget(CDockWidget* DockWidget)
{
- if (d->DockWidget)
- {
- // Remove the old dock widget at this area
+ if (d->DockWidget)
+ {
+ // Remove the old dock widget at this area
d->DockArea->removeDockWidget(d->DockWidget);
- }
+ }
- d->DockWidget = DockWidget;
- d->SideTab->setDockWidget(DockWidget);
+ d->DockWidget = DockWidget;
+ d->SideTab->setDockWidget(DockWidget);
CDockAreaWidget* OldDockArea = DockWidget->dockAreaWidget();
auto IsRestoringState = DockWidget->dockManager()->isRestoringState();
if (OldDockArea && !IsRestoringState)
{
- // The initial size should be a little bit bigger than the original dock
- // area size to prevent that the resize handle of this auto hid dock area
- // is near of the splitter of the old dock area.
- d->Size = OldDockArea->size() + QSize(16, 16);
+ // The initial size should be a little bit bigger than the original dock
+ // area size to prevent that the resize handle of this auto hid dock area
+ // is near of the splitter of the old dock area.
+ d->Size = OldDockArea->size() + QSize(16, 16);
OldDockArea->removeDockWidget(DockWidget);
}
- d->DockArea->addDockWidget(DockWidget);
- updateSize();
- // The dock area is not visible and will not update the size when updateSize()
- // is called for this auto hide container. Therefore we explicitly resize
- // it here. As soon as it will become visible, it will get the right size
+ d->DockArea->addDockWidget(DockWidget);
+ updateSize();
+ // The dock area is not visible and will not update the size when updateSize()
+ // is called for this auto hide container. Therefore we explicitly resize
+ // it here. As soon as it will become visible, it will get the right size
d->DockArea->resize(size());
}
-
//============================================================================
SideBarLocation CAutoHideDockContainer::sideBarLocation() const
{
- return d->SideTabBarArea;
+ return d->SideTabBarArea;
}
-
//============================================================================
void CAutoHideDockContainer::setSideBarLocation(SideBarLocation SideBarLocation)
{
- if (d->SideTabBarArea == SideBarLocation)
- {
- return;
- }
+ if (d->SideTabBarArea == SideBarLocation)
+ {
+ return;
+ }
- d->SideTabBarArea = SideBarLocation;
- d->Layout->removeWidget(d->ResizeHandle);
- d->Layout->setDirection(isHorizontalArea(SideBarLocation) ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight);
- d->Layout->insertWidget(resizeHandleLayoutPosition(SideBarLocation), d->ResizeHandle);
- d->ResizeHandle->setHandlePosition(edgeFromSideTabBarArea(SideBarLocation));
+ d->SideTabBarArea = SideBarLocation;
+ d->Layout->removeWidget(d->ResizeHandle);
+ d->Layout->setDirection(isHorizontalArea(SideBarLocation) ?
+ QBoxLayout::TopToBottom :
+ QBoxLayout::LeftToRight);
+ d->Layout->insertWidget(resizeHandleLayoutPosition(SideBarLocation),
+ d->ResizeHandle);
+ d->ResizeHandle->setHandlePosition(edgeFromSideTabBarArea(SideBarLocation));
internal::repolishStyle(this, internal::RepolishDirectChildren);
}
-
//============================================================================
CDockAreaWidget* CAutoHideDockContainer::dockAreaWidget() const
{
- return d->DockArea;
+ return d->DockArea;
}
//============================================================================
void CAutoHideDockContainer::moveContentsToParent()
{
- cleanupAndDelete();
- // If we unpin the auto hide dock widget, then we insert it into the same
- // location like it had as a auto hide widget. This brings the least surprise
- // to the user and he does not have to search where the widget was inserted.
- d->DockWidget->setDockArea(nullptr);
- auto DockContainer = dockContainer();
- DockContainer->addDockWidget(d->getDockWidgetArea(d->SideTabBarArea), d->DockWidget);
+ cleanupAndDelete();
+ // If we unpin the auto hide dock widget, then we insert it into the same
+ // location like it had as a auto hide widget. This brings the least surprise
+ // to the user and he does not have to search where the widget was inserted.
+ d->DockWidget->setDockArea(nullptr);
+ auto DockContainer = dockContainer();
+ DockContainer->addDockWidget(d->getDockWidgetArea(d->SideTabBarArea),
+ d->DockWidget);
}
-
//============================================================================
void CAutoHideDockContainer::cleanupAndDelete()
{
- const auto dockWidget = d->DockWidget;
- if (dockWidget)
- {
-
- auto SideTab = d->SideTab;
+ const auto dockWidget = d->DockWidget;
+ if (dockWidget)
+ {
+ auto SideTab = d->SideTab;
SideTab->removeFromSideBar();
SideTab->setParent(nullptr);
SideTab->hide();
- }
+ }
- hide();
- deleteLater();
+ hide();
+ deleteLater();
}
-
//============================================================================
void CAutoHideDockContainer::saveState(QXmlStreamWriter& s)
{
- s.writeStartElement("Widget");
- s.writeAttribute("Name", d->DockWidget->objectName());
- s.writeAttribute("Closed", QString::number(d->DockWidget->isClosed() ? 1 : 0));
- s.writeAttribute("Size", QString::number(d->isHorizontal() ? d->Size.height() : d->Size.width()));
- s.writeEndElement();
+ s.writeStartElement("Widget");
+ s.writeAttribute("Name", d->DockWidget->objectName());
+ s.writeAttribute("Closed",
+ QString::number(d->DockWidget->isClosed() ? 1 : 0));
+ s.writeAttribute(
+ "Size",
+ QString::number(d->isHorizontal() ? d->Size.height() : d->Size.width()));
+ s.writeEndElement();
}
-
//============================================================================
void CAutoHideDockContainer::toggleView(bool Enable)
{
- if (Enable)
- {
+ if (Enable)
+ {
if (d->SideTab)
{
d->SideTab->show();
}
- }
- else
- {
+ }
+ else
+ {
if (d->SideTab)
{
d->SideTab->hide();
}
hide();
qApp->removeEventFilter(this);
- }
+ }
}
-
//============================================================================
void CAutoHideDockContainer::collapseView(bool Enable)
{
- if (Enable)
- {
- hide();
- qApp->removeEventFilter(this);
- }
- else
- {
- updateSize();
- d->updateResizeHandleSizeLimitMax();
- raise();
- show();
- d->DockWidget->dockManager()->setDockWidgetFocused(d->DockWidget);
- qApp->installEventFilter(this);
- }
+ if (Enable)
+ {
+ hide();
+ qApp->removeEventFilter(this);
+ }
+ else
+ {
+ updateSize();
+ d->updateResizeHandleSizeLimitMax();
+ raise();
+ show();
+ d->DockWidget->dockManager()->setDockWidgetFocused(d->DockWidget);
+ qApp->installEventFilter(this);
+ }
- ADS_PRINT("CAutoHideDockContainer::collapseView " << Enable);
+ ADS_PRINT("CAutoHideDockContainer::collapseView " << Enable);
d->SideTab->updateStyle();
}
-
//============================================================================
void CAutoHideDockContainer::toggleCollapseState()
{
- collapseView(isVisible());
+ collapseView(isVisible());
}
-
//============================================================================
void CAutoHideDockContainer::setSize(int Size)
{
- if (d->isHorizontal())
- {
- d->Size.setHeight(Size);
- }
- else
- {
- d->Size.setWidth(Size);
- }
+ if (d->isHorizontal())
+ {
+ d->Size.setHeight(Size);
+ }
+ else
+ {
+ d->Size.setWidth(Size);
+ }
- updateSize();
+ updateSize();
}
-
//============================================================================
/**
* Returns true if the object given in ancestor is an ancestor of the object
@@ -523,190 +508,186 @@ static bool objectIsAncestorOf(const QObject* descendant, const QObject* ancesto
return false;
}
-
//============================================================================
/**
* Returns true if the object given in ancestor is the object given in descendant
* or if it is an ancestor of the object given in descendant
*/
-static bool isObjectOrAncestor(const QObject *descendant, const QObject *ancestor)
+static bool isObjectOrAncestor(const QObject* descendant, const QObject* ancestor)
{
- if (ancestor && (descendant == ancestor))
- {
- return true;
- }
- else
- {
- return objectIsAncestorOf(descendant, ancestor);
- }
+ if (ancestor && (descendant == ancestor))
+ {
+ return true;
+ }
+ else
+ {
+ return objectIsAncestorOf(descendant, ancestor);
+ }
}
-
//============================================================================
bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
{
- // A switch case statement would be nicer here, but we cannot use
- // internal::FloatingWidgetDragStartEvent in a switch case
+ // A switch case statement would be nicer here, but we cannot use
+ // internal::FloatingWidgetDragStartEvent in a switch case
if (event->type() == QEvent::Resize)
- {
- if (!d->ResizeHandle->isResizing())
- {
- updateSize();
- }
- }
- else if (event->type() == QEvent::MouseButtonPress)
- {
- auto widget = qobject_cast(watched);
- // Ignore non widget events
- if (!widget)
- {
- return Super::eventFilter(watched, event);
- }
+ {
+ if (!d->ResizeHandle->isResizing())
+ {
+ updateSize();
+ }
+ }
+ else if (event->type() == QEvent::MouseButtonPress)
+ {
+ auto widget = qobject_cast(watched);
+ // Ignore non widget events
+ if (!widget)
+ {
+ return Super::eventFilter(watched, event);
+ }
- // Now check, if the user clicked into the side tab and ignore this event,
- // because the side tab click handler will call collapseView(). If we
- // do not ignore this here, then we will collapse the container and the side tab
- // click handler will uncollapse it
- if (widget == d->SideTab.data())
- {
- return Super::eventFilter(watched, event);
- }
+ // Now check, if the user clicked into the side tab and ignore this event,
+ // because the side tab click handler will call collapseView(). If we
+ // do not ignore this here, then we will collapse the container and the
+ // side tab click handler will uncollapse it
+ if (widget == d->SideTab.data())
+ {
+ return Super::eventFilter(watched, event);
+ }
- // Now we check, if the user clicked inside of this auto hide container.
- // If the click is inside of this auto hide container, then we can
- // ignore the event, because the auto hide overlay should not get collapsed if
- // user works in it
- if (isObjectOrAncestor(widget, this))
- {
- return Super::eventFilter(watched, event);
- }
+ // Now we check, if the user clicked inside of this auto hide container.
+ // If the click is inside of this auto hide container, then we can
+ // ignore the event, because the auto hide overlay should not get
+ // collapsed if user works in it
+ if (isObjectOrAncestor(widget, this))
+ {
+ return Super::eventFilter(watched, event);
+ }
- // Ignore the mouse click if it is not inside of this container
- if (!isObjectOrAncestor(widget, dockContainer()))
- {
- return Super::eventFilter(watched, event);
- }
+ // Ignore the mouse click if it is not inside of this container
+ if (!isObjectOrAncestor(widget, dockContainer()))
+ {
+ return Super::eventFilter(watched, event);
+ }
- // user clicked into container - collapse the auto hide widget
- collapseView(true);
- }
+ // user clicked into container - collapse the auto hide widget
+ collapseView(true);
+ }
else if (event->type() == internal::FloatingWidgetDragStartEvent)
{
- // If we are dragging our own floating widget, the we do not need to
- // collapse the view
- auto FloatingWidget = dockContainer()->floatingWidget();
- if (FloatingWidget != watched)
- {
- collapseView(true);
- }
+ // If we are dragging our own floating widget, the we do not need to
+ // collapse the view
+ auto FloatingWidget = dockContainer()->floatingWidget();
+ if (FloatingWidget != watched)
+ {
+ collapseView(true);
+ }
}
else if (event->type() == internal::DockedWidgetDragStartEvent)
{
- collapseView(true);
+ collapseView(true);
}
- return Super::eventFilter(watched, event);
+ return Super::eventFilter(watched, event);
}
-
//============================================================================
void CAutoHideDockContainer::resizeEvent(QResizeEvent* event)
{
Super::resizeEvent(event);
- if (d->ResizeHandle->isResizing())
- {
+ if (d->ResizeHandle->isResizing())
+ {
d->Size = this->size();
- d->updateResizeHandleSizeLimitMax();
- }
+ d->updateResizeHandleSizeLimitMax();
+ }
}
-
//============================================================================
-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);
- }
- Super::leaveEvent(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);
}
-
//============================================================================
bool CAutoHideDockContainer::event(QEvent* event)
{
- switch (event->type())
- {
- case QEvent::Enter:
- case QEvent::Hide:
- d->forwardEventToDockContainer(event);
- break;
+ switch (event->type())
+ {
+ case QEvent::Enter:
+ case QEvent::Hide: d->forwardEventToDockContainer(event); break;
- case QEvent::MouseButtonPress:
- return true;
- break;
+ case QEvent::MouseButtonPress: return true; break;
- default:
- break;
- }
+ default: break;
+ }
- return Super::event(event);
+ return Super::event(event);
}
+//============================================================================
+void CAutoHideDockContainer::dragLeaveEvent(QDragLeaveEvent*)
+{
+ if (CDockManager::testAutoHideConfigFlag(
+ CDockManager::AutoHideOpenOnDragHover))
+ {
+ collapseView(true);
+ }
+}
//============================================================================
Qt::Orientation CAutoHideDockContainer::orientation() const
{
- return ads::internal::isHorizontalSideBarLocation(d->SideTabBarArea)
- ? Qt::Horizontal : Qt::Vertical;
+ return ads::internal::isHorizontalSideBarLocation(d->SideTabBarArea) ?
+ Qt::Horizontal :
+ Qt::Vertical;
}
-
//============================================================================
void CAutoHideDockContainer::resetToInitialDockWidgetSize()
{
- if (orientation() == Qt::Horizontal)
- {
- setSize(d->SizeCache.height());
- }
- else
- {
- setSize(d->SizeCache.width());
- }
+ if (orientation() == Qt::Horizontal)
+ {
+ setSize(d->SizeCache.height());
+ }
+ else
+ {
+ setSize(d->SizeCache.width());
+ }
}
-
//============================================================================
-void CAutoHideDockContainer::moveToNewSideBarLocation(SideBarLocation NewSideBarLocation,
- int TabIndex)
+void CAutoHideDockContainer::moveToNewSideBarLocation(
+ SideBarLocation NewSideBarLocation, int TabIndex)
{
- if (NewSideBarLocation == sideBarLocation() && TabIndex == this->tabIndex())
- {
- return;
- }
+ if (NewSideBarLocation == sideBarLocation() && TabIndex == this->tabIndex())
+ {
+ return;
+ }
- auto OldOrientation = orientation();
- auto SideBar = dockContainer()->autoHideSideBar(NewSideBarLocation);
- SideBar->addAutoHideWidget(this, TabIndex);
- // If we move a horizontal auto hide container to a vertical position
- // then we resize it to the original dock widget size, to avoid
- // an extremely stretched dock widget after insertion
- if (SideBar->orientation() != OldOrientation)
- {
- resetToInitialDockWidgetSize();
- }
+ auto OldOrientation = orientation();
+ auto SideBar = dockContainer()->autoHideSideBar(NewSideBarLocation);
+ SideBar->addAutoHideWidget(this, TabIndex);
+ // If we move a horizontal auto hide container to a vertical position
+ // then we resize it to the original dock widget size, to avoid
+ // an extremely stretched dock widget after insertion
+ if (SideBar->orientation() != OldOrientation)
+ {
+ resetToInitialDockWidgetSize();
+ }
}
-
//============================================================================
int CAutoHideDockContainer::tabIndex() const
{
- return d->SideTab->tabIndex();
-}
-
+ return d->SideTab->tabIndex();
}
+} // namespace ads
diff --git a/src/AutoHideDockContainer.h b/src/AutoHideDockContainer.h
index 2fdce37..fb9b504 100644
--- a/src/AutoHideDockContainer.h
+++ b/src/AutoHideDockContainer.h
@@ -18,7 +18,6 @@
** License along with this library; If not, see .
******************************************************************************/
-
//============================================================================
/// \file AutoHideDockContainer.h
/// \author Syarif Fakhri
@@ -29,10 +28,10 @@
//============================================================================
// INCLUDES
//============================================================================
-#include "ads_globals.h"
-
#include
+
#include "AutoHideTab.h"
+#include "ads_globals.h"
QT_FORWARD_DECLARE_CLASS(QXmlStreamWriter)
@@ -52,151 +51,153 @@ struct SideTabBarPrivate;
*/
class ADS_EXPORT CAutoHideDockContainer : public QFrame
{
- Q_OBJECT
+ Q_OBJECT
Q_PROPERTY(int sideBarLocation READ sideBarLocation)
private:
- AutoHideDockContainerPrivate* d; ///< private data (pimpl)
- friend struct AutoHideDockContainerPrivate;
- friend CAutoHideSideBar;
- friend SideTabBarPrivate;
+ AutoHideDockContainerPrivate* d; ///< private data (pimpl)
+ friend struct AutoHideDockContainerPrivate;
+ friend CAutoHideSideBar;
+ friend SideTabBarPrivate;
protected:
- virtual bool eventFilter(QObject* watched, QEvent* event) override;
- virtual void resizeEvent(QResizeEvent* event) override;
- virtual void leaveEvent(QEvent *event) override;
- virtual bool event(QEvent* event) override;
+ virtual bool eventFilter(QObject* watched, QEvent* event) override;
+ virtual void resizeEvent(QResizeEvent* event) override;
+ virtual void leaveEvent(QEvent* event) override;
+ virtual bool event(QEvent* event) override;
+ virtual void dragLeaveEvent(QDragLeaveEvent* ev) override;
- /**
- * Updates the size considering the size limits and the resize margins
- */
- void updateSize();
+ /**
+ * Updates the size considering the size limits and the resize margins
+ */
+ void updateSize();
- /*
- * Saves the state and size
- */
- void saveState(QXmlStreamWriter& Stream);
+ /*
+ * Saves the state and size
+ */
+ void saveState(QXmlStreamWriter& Stream);
public:
- using Super = QFrame;
+ using Super = QFrame;
/**
- * Create Auto Hide widget with the given dock widget
- */
- CAutoHideDockContainer(CDockWidget* DockWidget, SideBarLocation area,
- CDockContainerWidget* parent);
-
- /**
- * Virtual Destructor
- */
- virtual ~CAutoHideDockContainer();
-
- /**
- * Gets the side tab bar
- */
- CAutoHideSideBar* autoHideSideBar() const;
-
- /**
- * Returns the side tab
- */
- CAutoHideTab* autoHideTab() const;
-
- /**
- * Gets the dock widget in this dock container
- */
- CDockWidget* dockWidget() const;
-
- /**
- * Returns the index of this container in the sidebar
- */
- int tabIndex() const;
-
- /**
- * Adds a dock widget and removes the previous dock widget
- */
- void addDockWidget(CDockWidget* DockWidget);
+ * Create Auto Hide widget with the given dock widget
+ */
+ CAutoHideDockContainer(CDockWidget* DockWidget, SideBarLocation area,
+ CDockContainerWidget* parent);
/**
- * Returns the side tab bar area of this Auto Hide dock container
- */
- SideBarLocation sideBarLocation() const;
+ * Virtual Destructor
+ */
+ virtual ~CAutoHideDockContainer();
- /**
- * Sets a new SideBarLocation.
- * If a new side bar location is set, the auto hide dock container needs
- * to update its resize handle position
- */
- void setSideBarLocation(SideBarLocation SideBarLocation);
+ /**
+ * Gets the side tab bar
+ */
+ CAutoHideSideBar* autoHideSideBar() const;
- /**
- * Returns the dock area widget of this Auto Hide dock container
- */
- CDockAreaWidget* dockAreaWidget() const;
+ /**
+ * Returns the side tab
+ */
+ CAutoHideTab* autoHideTab() const;
- /**
- * Returns the parent container that hosts this auto hide container
- */
- CDockContainerWidget* dockContainer() const;
+ /**
+ * Gets the dock widget in this dock container
+ */
+ CDockWidget* dockWidget() const;
- /**
- * Moves the contents to the parent container widget
- * Used before removing this Auto Hide dock container
- */
+ /**
+ * Returns the index of this container in the sidebar
+ */
+ int tabIndex() const;
+
+ /**
+ * Adds a dock widget and removes the previous dock widget
+ */
+ void addDockWidget(CDockWidget* DockWidget);
+
+ /**
+ * Returns the side tab bar area of this Auto Hide dock container
+ */
+ SideBarLocation sideBarLocation() const;
+
+ /**
+ * Sets a new SideBarLocation.
+ * If a new side bar location is set, the auto hide dock container needs
+ * to update its resize handle position
+ */
+ void setSideBarLocation(SideBarLocation SideBarLocation);
+
+ /**
+ * Returns the dock area widget of this Auto Hide dock container
+ */
+ CDockAreaWidget* dockAreaWidget() const;
+
+ /**
+ * Returns the parent container that hosts this auto hide container
+ */
+ CDockContainerWidget* dockContainer() const;
+
+ /**
+ * Moves the contents to the parent container widget
+ * Used before removing this Auto Hide dock container
+ */
void moveContentsToParent();
- /**
- * Cleanups up the side tab widget and then deletes itself
- */
- void cleanupAndDelete();
+ /**
+ * Cleanups up the side tab widget and then deletes itself
+ */
+ void cleanupAndDelete();
- /*
- * Toggles the auto Hide dock container widget
- * This will also hide the side tab widget
- */
- void toggleView(bool Enable);
+ /*
+ * Toggles the auto Hide dock container widget
+ * This will also hide the side tab widget
+ */
+ void toggleView(bool Enable);
- /*
- * Collapses the auto hide dock container widget
- * Does not hide the side tab widget
- */
- void collapseView(bool Enable);
+ /*
+ * Collapses the auto hide dock container widget
+ * Does not hide the side tab widget
+ */
+ void collapseView(bool Enable);
- /**
- * Toggles the current collapse state
- */
- void toggleCollapseState();
+ /**
+ * Toggles the current collapse state
+ */
+ void toggleCollapseState();
- /**
- * Use this instead of resize.
- * Depending on the sidebar location this will set the width or height
- * of this auto hide container.
- */
- void setSize(int Size);
+ /**
+ * Use this instead of resize.
+ * Depending on the sidebar location this will set the width or height
+ * of this auto hide container.
+ */
+ void setSize(int Size);
- /**
- * Resets the width or height to the initial dock widget size dependinng on
- * the orientation.
- * If the orientation is Qt::Horizontal, then the height is reset to
- * the initial size and if orientation is Qt::Vertical, then the width is
- * reset to the initial size
- */
- void resetToInitialDockWidgetSize();
+ /**
+ * Resets the width or height to the initial dock widget size dependinng on
+ * the orientation.
+ * If the orientation is Qt::Horizontal, then the height is reset to
+ * the initial size and if orientation is Qt::Vertical, then the width is
+ * reset to the initial size
+ */
+ void resetToInitialDockWidgetSize();
- /**
- * Returns orientation of this container.
- * Left and right containers have a Qt::Vertical orientation and top / bottom
- * containers have a Qt::Horizontal orientation.
- * The function returns the orientation of the corresponding auto hide
- * side bar.
- */
- Qt::Orientation orientation() const;
+ /**
+ * Returns orientation of this container.
+ * Left and right containers have a Qt::Vertical orientation and top / bottom
+ * containers have a Qt::Horizontal orientation.
+ * The function returns the orientation of the corresponding auto hide
+ * side bar.
+ */
+ Qt::Orientation orientation() const;
- /**
- * Removes the AutoHide container from the current side bar and adds
- * it to the new side bar given in SideBarLocation
- */
- void moveToNewSideBarLocation(SideBarLocation SideBarLocation, int TabIndex = -1);
+ /**
+ * Removes the AutoHide container from the current side bar and adds
+ * it to the new side bar given in SideBarLocation
+ */
+ void moveToNewSideBarLocation(SideBarLocation SideBarLocation,
+ int TabIndex = -1);
};
-} // namespace ads
+} // namespace ads
//-----------------------------------------------------------------------------
#endif
diff --git a/src/AutoHideTab.cpp b/src/AutoHideTab.cpp
index e2d6265..23fee07 100644
--- a/src/AutoHideTab.cpp
+++ b/src/AutoHideTab.cpp
@@ -33,6 +33,8 @@
#include
#include
#include
+#include
+#include
#include "AutoHideDockContainer.h"
#include "AutoHideSideBar.h"
@@ -41,6 +43,7 @@
#include "DockWidget.h"
#include "FloatingDragPreview.h"
#include "DockOverlay.h"
+#include "ads_globals.h"
namespace ads
{
@@ -55,6 +58,7 @@ struct AutoHideTabPrivate
CAutoHideSideBar* SideBar = nullptr;
Qt::Orientation Orientation{Qt::Vertical};
QElapsedTimer TimeSinceHoverMousePress;
+ QElapsedTimer TimeSinceDragOver;
bool MousePressed = false;
eDragState DragState = DraggingInactive;
QPoint GlobalDragStartMousePosition;
@@ -252,6 +256,9 @@ CAutoHideTab::CAutoHideTab(QWidget* parent) :
{
setAttribute(Qt::WA_NoMousePropagation);
setFocusPolicy(Qt::NoFocus);
+ if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideOpenOnDragHover)) {
+ setAcceptDrops(true);
+ }
}
@@ -355,7 +362,6 @@ bool CAutoHideTab::event(QEvent* event)
case QEvent::Leave:
d->forwardEventToDockContainer(event);
break;
-
default:
break;
}
@@ -537,6 +543,37 @@ void CAutoHideTab::mouseMoveEvent(QMouseEvent* ev)
Super::mouseMoveEvent(ev);
}
+//============================================================================
+void CAutoHideTab::dragEnterEvent(QDragEnterEvent* ev) {
+ if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideOpenOnDragHover)) {
+ if (!d->TimeSinceDragOver.isValid()) {
+ d->TimeSinceDragOver.restart();
+ ev->accept();
+ }
+ else if (d->TimeSinceDragOver.hasExpired(500)) {
+ ev->accept();
+ }
+ }
+}
+
+//============================================================================
+void CAutoHideTab::dragLeaveEvent(QDragLeaveEvent* ev) {
+ if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideOpenOnDragHover)) {
+ d->TimeSinceDragOver.invalidate();
+ d->forwardEventToDockContainer(ev);
+ }
+}
+
+//============================================================================
+void CAutoHideTab::dragMoveEvent(QDragMoveEvent* ev) {
+ if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideOpenOnDragHover)
+ && d->TimeSinceDragOver.isValid()
+ && d->TimeSinceDragOver.hasExpired(500)) {
+ d->TimeSinceDragOver.invalidate();
+ d->DockWidget->autoHideDockContainer()->collapseView(false);
+ ev->accept();
+ }
+}
//============================================================================
void CAutoHideTab::requestCloseDockWidget()
diff --git a/src/AutoHideTab.h b/src/AutoHideTab.h
index 3a42df8..07d4344 100644
--- a/src/AutoHideTab.h
+++ b/src/AutoHideTab.h
@@ -55,7 +55,7 @@ class ADS_EXPORT CAutoHideTab : public CPushButton
Q_PROPERTY(bool activeTab READ isActiveTab)
Q_PROPERTY(bool iconOnly READ iconOnly)
-private:
+private:
AutoHideTabPrivate* d; ///< private data (pimpl)
friend struct AutoHideTabPrivate;
friend class CDockWidget;
@@ -76,6 +76,9 @@ protected:
virtual void mousePressEvent(QMouseEvent* ev) override;
virtual void mouseReleaseEvent(QMouseEvent* ev) override;
virtual void mouseMoveEvent(QMouseEvent* ev) override;
+ virtual void dragEnterEvent(QDragEnterEvent* ev) override;
+ virtual void dragLeaveEvent(QDragLeaveEvent* ev) override;
+ virtual void dragMoveEvent(QDragMoveEvent* ev) override;
public:
using Super = CPushButton;
diff --git a/src/DockManager.h b/src/DockManager.h
index dcb2356..e56e9ac 100644
--- a/src/DockManager.h
+++ b/src/DockManager.h
@@ -254,6 +254,7 @@ public:
AutoHideCloseButtonCollapsesDock = 0x40, ///< Close button of an auto hide container collapses the dock instead of hiding it completely
AutoHideHasCloseButton = 0x80, //< If the flag is set an auto hide title bar has a close button
AutoHideHasMinimizeButton = 0x100, ///< if this flag is set, the auto hide title bar has a minimize button to collapse the dock widget
+ AutoHideOpenOnDragHover = 0x200, ///< if this flag is set, dragging hover the tab bar will open the dock
DefaultAutoHideConfig = AutoHideFeatureEnabled
| DockAreaHasAutoHideButton