Skip to content

Commit 34cb2ae

Browse files
Fixed escape key press detection
1 parent 8cc9cc2 commit 34cb2ae

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/FloatingDragPreview.cpp

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

207207
connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
208208
SLOT(onApplicationStateChanged(Qt::ApplicationState)));
209+
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);
209214
}
210215

211216

@@ -220,10 +225,6 @@ CFloatingDragPreview::CFloatingDragPreview(CDockWidget* Content)
220225
d->ContenSourceContainer = Content->dockContainer();
221226
}
222227
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);
227228
}
228229

229230

@@ -235,10 +236,6 @@ CFloatingDragPreview::CFloatingDragPreview(CDockAreaWidget* Content)
235236
d->ContentSourceArea = Content;
236237
d->ContenSourceContainer = Content->dockContainer();
237238
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);
242239
}
243240

244241

@@ -395,7 +392,6 @@ bool CFloatingDragPreview::eventFilter(QObject *watched, QEvent *event)
395392

396393

397394

398-
399395
} // namespace ads
400396

401397
//---------------------------------------------------------------------------

0 commit comments

Comments
 (0)