CHanged DockAreaTabBar to handle the dragging state via DragState member variable instead of testing for FloatingWidget nullptr

This commit is contained in:
Uwe Kindler 2019-12-16 08:41:15 +01:00
parent 5af6b4e324
commit 8c1f065f3f
4 changed files with 24 additions and 10 deletions

View File

@ -385,6 +385,7 @@ CMainWindow::CMainWindow(QWidget *parent) :
// uncomment the follwing line if you want to use non opaque undocking and splitter // uncomment the follwing line if you want to use non opaque undocking and splitter
// moevements // moevements
CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig); CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig);
CDockManager::setConfigFlag(CDockManager::DragPreviewHasWindowFrame, true);
// Now create the dock manager and its content // Now create the dock manager and its content
d->DockManager = new CDockManager(this); d->DockManager = new CDockManager(this);

View File

@ -60,6 +60,7 @@ struct DockAreaTabBarPrivate
QWidget* TabsContainerWidget; QWidget* TabsContainerWidget;
QBoxLayout* TabsLayout; QBoxLayout* TabsLayout;
int CurrentIndex = -1; int CurrentIndex = -1;
eDragState DragState = DraggingInactive;
/** /**
* Private data constructor * Private data constructor
@ -71,6 +72,14 @@ struct DockAreaTabBarPrivate
* The function reassigns the stylesheet to update the tabs * The function reassigns the stylesheet to update the tabs
*/ */
void updateTabs(); void updateTabs();
/**
* Test function for current drag state
*/
bool isDraggingState(eDragState dragState) const
{
return this->DragState == dragState;
}
}; };
// struct DockAreaTabBarPrivate // struct DockAreaTabBarPrivate
@ -161,6 +170,7 @@ void CDockAreaTabBar::mousePressEvent(QMouseEvent* ev)
{ {
ev->accept(); ev->accept();
d->DragStartMousePos = ev->pos(); d->DragStartMousePos = ev->pos();
d->DragState = DraggingMousePressed;
return; return;
} }
QScrollArea::mousePressEvent(ev); QScrollArea::mousePressEvent(ev);
@ -174,12 +184,12 @@ void CDockAreaTabBar::mouseReleaseEvent(QMouseEvent* ev)
{ {
ADS_PRINT("CDockAreaTabBar::mouseReleaseEvent"); ADS_PRINT("CDockAreaTabBar::mouseReleaseEvent");
ev->accept(); ev->accept();
auto CurrentDragState = d->DragState;
d->DragStartMousePos = QPoint(); d->DragStartMousePos = QPoint();
if (d->FloatingWidget) d->DragState = DraggingInactive;
if (DraggingFloatingWidget == CurrentDragState)
{ {
auto FloatingWidget = d->FloatingWidget; d->FloatingWidget->finishDragging();
d->FloatingWidget = nullptr;
FloatingWidget->finishDragging();
} }
return; return;
} }
@ -196,7 +206,8 @@ void CDockAreaTabBar::mouseMoveEvent(QMouseEvent* ev)
return; return;
} }
if (d->FloatingWidget) // move floating window
if (d->isDraggingState(DraggingFloatingWidget))
{ {
d->FloatingWidget->moveFloating(); d->FloatingWidget->moveFloating();
return; return;
@ -254,6 +265,7 @@ void CDockAreaTabBar::mouseDoubleClickEvent(QMouseEvent *event)
IFloatingWidget* CDockAreaTabBar::makeAreaFloating(const QPoint& Offset, eDragState DragState) IFloatingWidget* CDockAreaTabBar::makeAreaFloating(const QPoint& Offset, eDragState DragState)
{ {
QSize Size = d->DockArea->size(); QSize Size = d->DockArea->size();
d->DragState = DragState;
bool OpaqueUndocking = CDockManager::configFlags().testFlag(CDockManager::OpaqueUndocking) || bool OpaqueUndocking = CDockManager::configFlags().testFlag(CDockManager::OpaqueUndocking) ||
(DraggingFloatingWidget != DragState); (DraggingFloatingWidget != DragState);
CFloatingDockContainer* FloatingDockContainer = nullptr; CFloatingDockContainer* FloatingDockContainer = nullptr;

View File

@ -95,7 +95,7 @@ struct DockWidgetTabPrivate
/** /**
* Test function for current drag state * Test function for current drag state
*/ */
bool isDraggingState(eDragState dragState) bool isDraggingState(eDragState dragState) const
{ {
return this->DragState == dragState; return this->DragState == dragState;
} }

View File

@ -27,6 +27,7 @@ struct FloatingOverlayPrivate;
*/ */
class CFloatingOverlay : public QWidget, public IFloatingWidget class CFloatingOverlay : public QWidget, public IFloatingWidget
{ {
Q_OBJECT
private: private:
FloatingOverlayPrivate* d; FloatingOverlayPrivate* d;
friend class FloatingOverlayPrivate; friend class FloatingOverlayPrivate;