Add DragController::isIdle()

This commit is contained in:
Sergio Martins
2022-02-04 17:47:59 +00:00
parent 4f8aac7df3
commit faf93fe597
2 changed files with 15 additions and 7 deletions

View File

@@ -592,26 +592,26 @@ DragController::DragController(QObject *parent)
{
qCDebug(creation) << "DragController()";
auto stateNone = new StateNone(this);
m_stateNone = new StateNone(this);
auto statepreDrag = new StatePreDrag(this);
auto stateDragging = isWayland() ? new StateDraggingWayland(this)
: new StateDragging(this);
m_stateDraggingMDI = new StateInternalMDIDragging(this);
stateNone->addTransition(this, &DragController::mousePressed, statepreDrag);
statepreDrag->addTransition(this, &DragController::dragCanceled, stateNone);
m_stateNone->addTransition(this, &DragController::mousePressed, statepreDrag);
statepreDrag->addTransition(this, &DragController::dragCanceled, m_stateNone);
statepreDrag->addTransition(this, &DragController::manhattanLengthMove, stateDragging);
statepreDrag->addTransition(this, &DragController::manhattanLengthMoveMDI, m_stateDraggingMDI);
stateDragging->addTransition(this, &DragController::dragCanceled, stateNone);
stateDragging->addTransition(this, &DragController::dropped, stateNone);
stateDragging->addTransition(this, &DragController::dragCanceled, m_stateNone);
stateDragging->addTransition(this, &DragController::dropped, m_stateNone);
m_stateDraggingMDI->addTransition(this, &DragController::dragCanceled, stateNone);
m_stateDraggingMDI->addTransition(this, &DragController::dragCanceled, m_stateNone);
m_stateDraggingMDI->addTransition(this, &DragController::mdiPopOut, stateDragging);
if (usesFallbackMouseGrabber())
enableFallbackMouseGrabber();
setCurrentState(stateNone);
setCurrentState(m_stateNone);
}
DragController *DragController::instance()
@@ -647,6 +647,11 @@ bool DragController::isInClientDrag() const
return isDragging() && !m_nonClientDrag;
}
bool DragController::isIdle() const
{
return activeState() == m_stateNone;
}
void DragController::grabMouseFor(QWidgetOrQuick *target)
{
if (isWayland())

View File

@@ -26,6 +26,7 @@
namespace KDDockWidgets {
class StateBase;
class StateNone;
class StateInternalMDIDragging;
class DropArea;
class Draggable;
@@ -85,6 +86,7 @@ public:
bool isDragging() const;
bool isInNonClientDrag() const;
bool isInClientDrag() const;
bool isIdle() const;
void grabMouseFor(QWidgetOrQuick *);
void releaseMouse(QWidgetOrQuick *);
@@ -133,6 +135,7 @@ private:
DropArea *m_currentDropArea = nullptr;
bool m_nonClientDrag = false;
FallbackMouseGrabber *m_fallbackMouseGrabber = nullptr;
StateNone *m_stateNone = nullptr;
StateInternalMDIDragging *m_stateDraggingMDI = nullptr;
};