Remove bool trap in QDockWidgetPrivate::endDrag()
endDrag(false) meant to end a drag with a dock location change. endDrag(true) meant to abort a drag without a dock location change. Replace this with a meaningful enumeration. Define a dummy enum for builds w/o QDockWidget. Task-number: QTBUG-118578 Task-number: QTBUG-118579 Pick-to: 6.6 6.5 Change-Id: I786f4210f5a3ee67ffcf0dc9285f77a480148569 Reviewed-by: David Faure <david.faure@kdab.com>bb10
parent
4c36bb854c
commit
17372faf3f
|
|
@ -792,7 +792,7 @@ void QDockWidgetPrivate::startDrag(DragScope scope)
|
|||
delete state;
|
||||
state = nullptr;
|
||||
} else {
|
||||
endDrag();
|
||||
endDrag(QDockWidgetPrivate::EndDragMode::LocationChange);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -803,7 +803,7 @@ void QDockWidgetPrivate::startDrag(DragScope scope)
|
|||
The \a abort parameter specifies that it ends because of programmatic state
|
||||
reset rather than mouse release event.
|
||||
*/
|
||||
void QDockWidgetPrivate::endDrag(bool abort)
|
||||
void QDockWidgetPrivate::endDrag(EndDragMode mode)
|
||||
{
|
||||
Q_Q(QDockWidget);
|
||||
Q_ASSERT(state != nullptr);
|
||||
|
|
@ -815,7 +815,7 @@ void QDockWidgetPrivate::endDrag(bool abort)
|
|||
Q_ASSERT(mainWindow != nullptr);
|
||||
QMainWindowLayout *mwLayout = qt_mainwindow_layout(mainWindow);
|
||||
|
||||
if (abort || !mwLayout->plug(state->widgetItem)) {
|
||||
if (mode == EndDragMode::Abort || !mwLayout->plug(state->widgetItem)) {
|
||||
if (hasFeature(this, QDockWidget::DockWidgetFloatable)) {
|
||||
// This QDockWidget will now stay in the floating state.
|
||||
if (state->ownWidgetItem) {
|
||||
|
|
@ -1050,7 +1050,7 @@ bool QDockWidgetPrivate::mouseReleaseEvent(QMouseEvent *event)
|
|||
#endif
|
||||
|
||||
if (event->button() == Qt::LeftButton && state && !state->nca) {
|
||||
endDrag();
|
||||
endDrag(EndDragMode::LocationChange);
|
||||
return true; //filter out the event
|
||||
}
|
||||
|
||||
|
|
@ -1096,15 +1096,14 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
|
|||
break;
|
||||
|
||||
#if !defined(Q_OS_MAC) && !defined(Q_OS_WASM)
|
||||
if (state->nca) {
|
||||
endDrag();
|
||||
}
|
||||
if (state->nca)
|
||||
endDrag(EndDragMode::LocationChange);
|
||||
#endif
|
||||
break;
|
||||
case QEvent::NonClientAreaMouseButtonRelease:
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_WASM)
|
||||
if (state)
|
||||
endDrag();
|
||||
endDrag(EndDragMode::LocationChange);
|
||||
#endif
|
||||
break;
|
||||
case QEvent::NonClientAreaMouseButtonDblClick:
|
||||
|
|
@ -1432,7 +1431,7 @@ void QDockWidget::setFloating(bool floating)
|
|||
|
||||
// the initial click of a double-click may have started a drag...
|
||||
if (d->state != nullptr)
|
||||
d->endDrag(true);
|
||||
d->endDrag(QDockWidgetPrivate::EndDragMode::Abort);
|
||||
|
||||
QRect r = d->undockedGeometry;
|
||||
// Keep position when undocking for the first time.
|
||||
|
|
@ -1520,7 +1519,7 @@ void QDockWidget::closeEvent(QCloseEvent *event)
|
|||
{
|
||||
Q_D(QDockWidget);
|
||||
if (d->state)
|
||||
d->endDrag(true);
|
||||
d->endDrag(QDockWidgetPrivate::EndDragMode::Abort);
|
||||
|
||||
// For non-closable widgets, don't allow closing, except when the mainwindow
|
||||
// is hidden, as otherwise an application wouldn't be able to be shut down.
|
||||
|
|
|
|||
|
|
@ -56,6 +56,11 @@ public:
|
|||
Widget
|
||||
};
|
||||
|
||||
enum class EndDragMode {
|
||||
LocationChange,
|
||||
Abort
|
||||
};
|
||||
|
||||
void init();
|
||||
void toggleView(bool);
|
||||
void toggleTopLevel();
|
||||
|
|
@ -92,7 +97,7 @@ public:
|
|||
void nonClientAreaMouseEvent(QMouseEvent *event);
|
||||
void initDrag(const QPoint &pos, bool nca);
|
||||
void startDrag(DragScope scope);
|
||||
void endDrag(bool abort = false);
|
||||
void endDrag(EndDragMode mode);
|
||||
void moveEvent(QMoveEvent *event);
|
||||
void recalculatePressPos(QResizeEvent *event);
|
||||
|
||||
|
|
|
|||
|
|
@ -1821,9 +1821,9 @@ void QMainWindowTabBar::mouseReleaseEvent(QMouseEvent *e)
|
|||
{
|
||||
if (draggingDock && e->button() == Qt::LeftButton) {
|
||||
QDockWidgetPrivate *dockPriv = static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(draggingDock));
|
||||
if (dockPriv->state && dockPriv->state->dragging) {
|
||||
dockPriv->endDrag();
|
||||
}
|
||||
if (dockPriv->state && dockPriv->state->dragging)
|
||||
dockPriv->endDrag(QDockWidgetPrivate::EndDragMode::LocationChange);
|
||||
|
||||
draggingDock = nullptr;
|
||||
}
|
||||
QTabBar::mouseReleaseEvent(e);
|
||||
|
|
|
|||
Loading…
Reference in New Issue