From 93cb686f0890a2f3098a28f0da84fb841ce964ff Mon Sep 17 00:00:00 2001 From: David Sansome Date: Sun, 6 Jun 2010 22:39:01 +0000 Subject: [PATCH] Ctrl+W and Esc close the visualisation window --- src/visualisations/visualisationcontainer.cpp | 13 +++++++++++++ src/visualisations/visualisationcontainer.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/visualisations/visualisationcontainer.cpp b/src/visualisations/visualisationcontainer.cpp index 8461731b7..31ec64cf2 100644 --- a/src/visualisations/visualisationcontainer.cpp +++ b/src/visualisations/visualisationcontainer.cpp @@ -192,6 +192,19 @@ void VisualisationContainer::contextMenuEvent(QContextMenuEvent *event) { ShowPopupMenu(event->pos()); } +void VisualisationContainer::keyReleaseEvent(QKeyEvent *event) { + if (event->matches(QKeySequence::Close) || + event->key() == Qt::Key_Escape) { + if (isFullScreen()) + ToggleFullscreen(); + else + hide(); + event->accept(); + } + + QGraphicsView::keyReleaseEvent(event); +} + void VisualisationContainer::ToggleFullscreen() { setWindowState(windowState() ^ Qt::WindowFullScreen); } diff --git a/src/visualisations/visualisationcontainer.h b/src/visualisations/visualisationcontainer.h index c3084b38b..5cc3ba8ad 100644 --- a/src/visualisations/visualisationcontainer.h +++ b/src/visualisations/visualisationcontainer.h @@ -60,6 +60,7 @@ protected: void leaveEvent(QEvent* e); void mouseDoubleClickEvent(QMouseEvent* e); void contextMenuEvent(QContextMenuEvent *event); + void keyReleaseEvent(QKeyEvent *event); private: void SizeChanged();