Skip to content

Commit 6f9153d

Browse files
mergify[bot]marip8
andauthored
Replace ESC shortcut for exiting full screen with solution from ros-visualization/rviz#1416 (#1205) (#1211)
(cherry picked from commit 526f251) Co-authored-by: Michael Ripperger <[email protected]>
1 parent 9c4a7aa commit 6f9153d

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

rviz_common/include/rviz_common/visualization_manager.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,9 @@ public Q_SLOTS:
316316
/// Emitted during file-loading and initialization to indicate progress.
317317
void statusUpdate(const QString & message);
318318

319+
/// Emmited when ESC key is pressed
320+
void escapePressed();
321+
319322
protected Q_SLOTS:
320323
/// Call update() on all managed objects.
321324
/**

rviz_common/src/rviz_common/visualization_frame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ void VisualizationFrame::initialize(
343343
ToolManager * tool_man = manager_->getToolManager();
344344

345345
connect(manager_, SIGNAL(configChanged()), this, SLOT(setDisplayConfigModified()));
346+
connect(manager_, SIGNAL(escapePressed()), this, SLOT(exitFullScreen()));
346347
connect(tool_man, SIGNAL(toolAdded(Tool*)), this, SLOT(addTool(Tool*)));
347348
connect(tool_man, SIGNAL(toolRemoved(Tool*)), this, SLOT(removeTool(Tool*)));
348349
connect(tool_man, SIGNAL(toolRefreshed(Tool*)), this, SLOT(refreshTool(Tool*)));
@@ -498,7 +499,6 @@ void VisualizationFrame::initMenus()
498499
this->addAction(fullscreen_action); // Also add to window, or the shortcut doest work
499500
// when the menu is hidden.
500501
connect(this, SIGNAL(fullScreenChange(bool)), fullscreen_action, SLOT(setChecked(bool)));
501-
new QShortcut(Qt::Key_Escape, this, SLOT(exitFullScreen()));
502502
view_menu_->addSeparator();
503503

504504
QMenu * help_menu = menuBar()->addMenu("&Help");

rviz_common/src/rviz_common/visualization_manager.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151

5252
#include <QApplication> // NOLINT: cpplint cannot handle include order here
5353
#include <QCursor> // NOLINT: cpplint cannot handle include order here
54+
#include <QKeyEvent> // NOLINT: cpplint cannot handle include order here
5455
#include <QTimer> // NOLINT: cpplint cannot handle include order here
5556
#include <QWindow> // NOLINT: cpplint cannot handle include order here
5657

@@ -692,6 +693,9 @@ void VisualizationManager::handleMouseEvent(const ViewportMouseEvent & vme)
692693

693694
void VisualizationManager::handleChar(QKeyEvent * event, RenderPanel * panel)
694695
{
696+
if (event->key() == Qt::Key_Escape) {
697+
Q_EMIT escapePressed();
698+
}
695699
tool_manager_->handleChar(event, panel);
696700
}
697701

0 commit comments

Comments
 (0)