Skip to content

Commit 2b9377b

Browse files
Fixed drag canceling via ESC key
1 parent d4a1800 commit 2b9377b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/FloatingDragPreview.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,6 @@ CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) :
206206

207207
connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
208208
SLOT(onApplicationStateChanged(Qt::ApplicationState)));
209-
210-
// We need to install an event filter for the given Content
211-
// widget to receive the escape key press
212-
Content->installEventFilter(this);
213209
}
214210

215211

@@ -224,6 +220,10 @@ CFloatingDragPreview::CFloatingDragPreview(CDockWidget* Content)
224220
d->ContenSourceContainer = Content->dockContainer();
225221
}
226222
setWindowTitle(Content->windowTitle());
223+
224+
// We need to install an event filter for the given Content
225+
// widget to receive the escape key press
226+
Content->dockAreaWidget()->installEventFilter(this);
227227
}
228228

229229

@@ -235,6 +235,10 @@ CFloatingDragPreview::CFloatingDragPreview(CDockAreaWidget* Content)
235235
d->ContentSourceArea = Content;
236236
d->ContenSourceContainer = Content->dockContainer();
237237
setWindowTitle(Content->currentDockWidget()->windowTitle());
238+
239+
// We need to install an event filter for the given Content
240+
// widget to receive the escape key press
241+
Content->installEventFilter(this);
238242
}
239243

240244

@@ -381,7 +385,7 @@ bool CFloatingDragPreview::eventFilter(QObject *watched, QEvent *event)
381385
QKeyEvent* e = static_cast<QKeyEvent*>(event);
382386
if (e->key() == Qt::Key_Escape)
383387
{
384-
d->Content->removeEventFilter(this);
388+
watched->removeEventFilter(this);
385389
d->cancelDragging();
386390
}
387391
}

0 commit comments

Comments
 (0)