mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 23:51:33 +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
|
||||
// moevements
|
||||
CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig);
|
||||
CDockManager::setConfigFlag(CDockManager::DragPreviewHasWindowFrame, true);
|
||||
|
||||
// Now create the dock manager and its content
|
||||
d->DockManager = new CDockManager(this);
|
||||
|
@ -60,6 +60,7 @@ struct DockAreaTabBarPrivate
|
||||
QWidget* TabsContainerWidget;
|
||||
QBoxLayout* TabsLayout;
|
||||
int CurrentIndex = -1;
|
||||
eDragState DragState = DraggingInactive;
|
||||
|
||||
/**
|
||||
* Private data constructor
|
||||
@ -71,6 +72,14 @@ struct DockAreaTabBarPrivate
|
||||
* The function reassigns the stylesheet to update the tabs
|
||||
*/
|
||||
void updateTabs();
|
||||
|
||||
/**
|
||||
* Test function for current drag state
|
||||
*/
|
||||
bool isDraggingState(eDragState dragState) const
|
||||
{
|
||||
return this->DragState == dragState;
|
||||
}
|
||||
};
|
||||
// struct DockAreaTabBarPrivate
|
||||
|
||||
@ -161,6 +170,7 @@ void CDockAreaTabBar::mousePressEvent(QMouseEvent* ev)
|
||||
{
|
||||
ev->accept();
|
||||
d->DragStartMousePos = ev->pos();
|
||||
d->DragState = DraggingMousePressed;
|
||||
return;
|
||||
}
|
||||
QScrollArea::mousePressEvent(ev);
|
||||
@ -174,12 +184,12 @@ void CDockAreaTabBar::mouseReleaseEvent(QMouseEvent* ev)
|
||||
{
|
||||
ADS_PRINT("CDockAreaTabBar::mouseReleaseEvent");
|
||||
ev->accept();
|
||||
auto CurrentDragState = d->DragState;
|
||||
d->DragStartMousePos = QPoint();
|
||||
if (d->FloatingWidget)
|
||||
d->DragState = DraggingInactive;
|
||||
if (DraggingFloatingWidget == CurrentDragState)
|
||||
{
|
||||
auto FloatingWidget = d->FloatingWidget;
|
||||
d->FloatingWidget = nullptr;
|
||||
FloatingWidget->finishDragging();
|
||||
d->FloatingWidget->finishDragging();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -196,7 +206,8 @@ void CDockAreaTabBar::mouseMoveEvent(QMouseEvent* ev)
|
||||
return;
|
||||
}
|
||||
|
||||
if (d->FloatingWidget)
|
||||
// move floating window
|
||||
if (d->isDraggingState(DraggingFloatingWidget))
|
||||
{
|
||||
d->FloatingWidget->moveFloating();
|
||||
return;
|
||||
@ -254,6 +265,7 @@ void CDockAreaTabBar::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
IFloatingWidget* CDockAreaTabBar::makeAreaFloating(const QPoint& Offset, eDragState DragState)
|
||||
{
|
||||
QSize Size = d->DockArea->size();
|
||||
d->DragState = DragState;
|
||||
bool OpaqueUndocking = CDockManager::configFlags().testFlag(CDockManager::OpaqueUndocking) ||
|
||||
(DraggingFloatingWidget != DragState);
|
||||
CFloatingDockContainer* FloatingDockContainer = nullptr;
|
||||
|
@ -95,7 +95,7 @@ struct DockWidgetTabPrivate
|
||||
/**
|
||||
* Test function for current drag state
|
||||
*/
|
||||
bool isDraggingState(eDragState dragState)
|
||||
bool isDraggingState(eDragState dragState) const
|
||||
{
|
||||
return this->DragState == dragState;
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ struct FloatingOverlayPrivate;
|
||||
*/
|
||||
class CFloatingOverlay : public QWidget, public IFloatingWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
FloatingOverlayPrivate* d;
|
||||
friend class FloatingOverlayPrivate;
|
||||
|
Loading…
Reference in New Issue
Block a user