Skip to content

Commit

Permalink
Fix using escape button when dragging non-opaque preview to cancel dr…
Browse files Browse the repository at this point in the history
…ag operation (#114)

* Added missing overrides.

* Escape button to cancel dragging was not working in Windows either. Using the event filter added for Linux works.
  • Loading branch information
rolivav authored Feb 7, 2020
1 parent 8a16230 commit a4ef161
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
21 changes: 3 additions & 18 deletions src/FloatingDragPreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,9 @@ CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) :
connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
SLOT(onApplicationStateChanged(Qt::ApplicationState)));

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


Expand Down Expand Up @@ -355,18 +352,6 @@ void CFloatingDragPreview::paintEvent(QPaintEvent* event)
}
}


//============================================================================
void CFloatingDragPreview::keyPressEvent(QKeyEvent *event)
{
Super::keyPressEvent(event);
if (event->key() == Qt::Key_Escape)
{
d->cancelDragging();
}
}


//============================================================================
void CFloatingDragPreview::onApplicationStateChanged(Qt::ApplicationState state)
{
Expand Down
5 changes: 0 additions & 5 deletions src/FloatingDragPreview.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ private slots:
*/
virtual void paintEvent(QPaintEvent *e) override;

/**
* Cancel non opaque undocking with escape key
*/
virtual void keyPressEvent(QKeyEvent *event) override;

/**
* The content is a DockArea or a DockWidget
*/
Expand Down

0 comments on commit a4ef161

Please sign in to comment.