Skip to content

Commit

Permalink
Replace ESC shortcut for exiting full screen with solution from ros-v…
Browse files Browse the repository at this point in the history
  • Loading branch information
marip8 authored May 27, 2024
1 parent b2d4546 commit 526f251
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions rviz_common/include/rviz_common/visualization_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ public Q_SLOTS:
/// Emitted during file-loading and initialization to indicate progress.
void statusUpdate(const QString & message);

/// Emmited when ESC key is pressed
void escapePressed();

protected Q_SLOTS:
/// Call update() on all managed objects.
/**
Expand Down
2 changes: 1 addition & 1 deletion rviz_common/src/rviz_common/visualization_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ void VisualizationFrame::initialize(
ToolManager * tool_man = manager_->getToolManager();

connect(manager_, SIGNAL(configChanged()), this, SLOT(setDisplayConfigModified()));
connect(manager_, SIGNAL(escapePressed()), this, SLOT(exitFullScreen()));
connect(tool_man, SIGNAL(toolAdded(Tool*)), this, SLOT(addTool(Tool*)));
connect(tool_man, SIGNAL(toolRemoved(Tool*)), this, SLOT(removeTool(Tool*)));
connect(tool_man, SIGNAL(toolRefreshed(Tool*)), this, SLOT(refreshTool(Tool*)));
Expand Down Expand Up @@ -486,7 +487,6 @@ void VisualizationFrame::initMenus()
this->addAction(fullscreen_action); // Also add to window, or the shortcut doest work
// when the menu is hidden.
connect(this, SIGNAL(fullScreenChange(bool)), fullscreen_action, SLOT(setChecked(bool)));
new QShortcut(Qt::Key_Escape, this, SLOT(exitFullScreen()));
view_menu_->addSeparator();

QMenu * help_menu = menuBar()->addMenu("&Help");
Expand Down
4 changes: 4 additions & 0 deletions rviz_common/src/rviz_common/visualization_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

#include <QApplication> // NOLINT: cpplint cannot handle include order here
#include <QCursor> // NOLINT: cpplint cannot handle include order here
#include <QKeyEvent> // NOLINT: cpplint cannot handle include order here
#include <QTimer> // NOLINT: cpplint cannot handle include order here
#include <QWindow> // NOLINT: cpplint cannot handle include order here

Expand Down Expand Up @@ -636,6 +637,9 @@ void VisualizationManager::handleMouseEvent(const ViewportMouseEvent & vme)

void VisualizationManager::handleChar(QKeyEvent * event, RenderPanel * panel)
{
if (event->key() == Qt::Key_Escape) {
Q_EMIT escapePressed();
}
tool_manager_->handleChar(event, panel);
}

Expand Down

0 comments on commit 526f251

Please sign in to comment.