@@ -40,6 +40,7 @@ struct FloatingDragPreviewPrivate
40
40
qreal WindowOpacity;
41
41
bool Hidden = false ;
42
42
QPixmap ContentPreviewPixmap;
43
+ bool Canceled = false ;
43
44
44
45
45
46
/* *
@@ -59,6 +60,7 @@ struct FloatingDragPreviewPrivate
59
60
*/
60
61
void cancelDragging ()
61
62
{
63
+ Canceled = true ;
62
64
emit _this->draggingCanceled ();
63
65
DockManager->containerOverlay ()->hideOverlay ();
64
66
DockManager->dockAreaOverlay ()->hideOverlay ();
@@ -85,11 +87,6 @@ void FloatingDragPreviewPrivate::updateDropOverlays(const QPoint &GlobalPos)
85
87
continue ;
86
88
}
87
89
88
- /* if (DockContainer == ContainerWidget)
89
- {
90
- continue;
91
- }*/
92
-
93
90
QPoint MappedPos = ContainerWidget->mapFromGlobal (GlobalPos);
94
91
if (ContainerWidget->rect ().contains (MappedPos))
95
92
{
@@ -207,10 +204,9 @@ CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) :
207
204
connect (qApp, SIGNAL (applicationStateChanged (Qt::ApplicationState)),
208
205
SLOT (onApplicationStateChanged (Qt::ApplicationState)));
209
206
210
- // The focused object will receive key press events and therefore we
211
- // install the event filter on it to receive escape key press for drag
212
- // canceling
213
- qApp->focusObject ()->installEventFilter (this );
207
+ // The only safe way to receive escape key presses is to install an event
208
+ // filter for the application object
209
+ qApp->installEventFilter (this );
214
210
}
215
211
216
212
@@ -377,7 +373,7 @@ void CFloatingDragPreview::onApplicationStateChanged(Qt::ApplicationState state)
377
373
bool CFloatingDragPreview::eventFilter (QObject *watched, QEvent *event)
378
374
{
379
375
Q_UNUSED (watched);
380
- if (event->type () == QEvent::KeyPress)
376
+ if (!d-> Canceled && event->type () == QEvent::KeyPress)
381
377
{
382
378
QKeyEvent* e = static_cast <QKeyEvent*>(event);
383
379
if (e->key () == Qt::Key_Escape)
0 commit comments