mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-26 16:01:36 +08:00
CHanged DockAreaTabBar to handle the dragging state via DragState member variable instead of testing for FloatingWidget nullptr
This commit is contained in:
parent
5af6b4e324
commit
8c1f065f3f
@ -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);
|
||||||
|
@ -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,11 +206,12 @@ void CDockAreaTabBar::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->FloatingWidget)
|
// move floating window
|
||||||
{
|
if (d->isDraggingState(DraggingFloatingWidget))
|
||||||
d->FloatingWidget->moveFloating();
|
{
|
||||||
return;
|
d->FloatingWidget->moveFloating();
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If this is the last dock area in a dock container it does not make
|
// If this is the last dock area in a dock container it does not make
|
||||||
// sense to move it to a new floating widget and leave this one
|
// sense to move it to a new floating widget and leave this one
|
||||||
@ -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;
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user