Skip to content

Commit a4ef161

Browse files
authored
Fix using escape button when dragging non-opaque preview to cancel drag operation (#114)
* Added missing overrides. * Escape button to cancel dragging was not working in Windows either. Using the event filter added for Linux works.
1 parent 8a16230 commit a4ef161

File tree

2 files changed

+3
-23
lines changed

2 files changed

+3
-23
lines changed

src/FloatingDragPreview.cpp

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,9 @@ CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) :
207207
connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
208208
SLOT(onApplicationStateChanged(Qt::ApplicationState)));
209209

210-
#ifdef Q_OS_LINUX
211-
// In Windows this widget directly receives the escape key press events
212-
// in Linux we need to install an event filter for the given Content
213-
// widget to receive the escape key press
214-
Content->installEventFilter(this);
215-
#endif
210+
// We need to install an event filter for the given Content
211+
// widget to receive the escape key press
212+
Content->installEventFilter(this);
216213
}
217214

218215

@@ -355,18 +352,6 @@ void CFloatingDragPreview::paintEvent(QPaintEvent* event)
355352
}
356353
}
357354

358-
359-
//============================================================================
360-
void CFloatingDragPreview::keyPressEvent(QKeyEvent *event)
361-
{
362-
Super::keyPressEvent(event);
363-
if (event->key() == Qt::Key_Escape)
364-
{
365-
d->cancelDragging();
366-
}
367-
}
368-
369-
370355
//============================================================================
371356
void CFloatingDragPreview::onApplicationStateChanged(Qt::ApplicationState state)
372357
{

src/FloatingDragPreview.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ private slots:
4949
*/
5050
virtual void paintEvent(QPaintEvent *e) override;
5151

52-
/**
53-
* Cancel non opaque undocking with escape key
54-
*/
55-
virtual void keyPressEvent(QKeyEvent *event) override;
56-
5752
/**
5853
* The content is a DockArea or a DockWidget
5954
*/

0 commit comments

Comments
 (0)