From 767911c8f415d1140b577ade9e02b506c1706700 Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Sat, 16 Sep 2023 10:38:07 +0200 Subject: [PATCH] ImageDisplay: toggle fullscreen button --- src/rviz/default_plugin/image_display.cpp | 27 +++++++++++++++++++++++ src/rviz/default_plugin/image_display.h | 1 + 2 files changed, 28 insertions(+) diff --git a/src/rviz/default_plugin/image_display.cpp b/src/rviz/default_plugin/image_display.cpp index 91847beddd..3b05a858cf 100644 --- a/src/rviz/default_plugin/image_display.cpp +++ b/src/rviz/default_plugin/image_display.cpp @@ -42,8 +42,12 @@ #include #include +#include +#include + #include #include +#include #include #include #include @@ -126,6 +130,14 @@ void ImageDisplay::onInitialize() setAssociatedWidget(render_panel_); + // fullscreen button + QToolButton* fullscreen_button = new QToolButton(); + fullscreen_button->setText("FullScreen"); + fullscreen_button->setIconSize(QSize(10, 10)); + connect(fullscreen_button, &QToolButton::clicked, this, &ImageDisplay::toggleFullScreen); + dynamic_cast(getAssociatedWidgetPanel()->titleBarWidget()->layout()) + ->insertWidget(2, fullscreen_button); + render_panel_->setAutoRender(false); render_panel_->setOverlaysEnabled(false); render_panel_->getCamera()->setNearClipDistance(0.01f); @@ -156,6 +168,21 @@ void ImageDisplay::onDisable() reset(); } +void ImageDisplay::toggleFullScreen() +{ + auto* panel = getAssociatedWidgetPanel(); + if (panel->windowState() & Qt::WindowFullScreen) + { + panel->setFloating(false); + panel->showNormal(); + } + else + { + panel->setFloating(true); + panel->showFullScreen(); + } +} + void ImageDisplay::updateNormalizeOptions() { if (got_float_image_) diff --git a/src/rviz/default_plugin/image_display.h b/src/rviz/default_plugin/image_display.h index 88492c191e..8e3d601809 100644 --- a/src/rviz/default_plugin/image_display.h +++ b/src/rviz/default_plugin/image_display.h @@ -73,6 +73,7 @@ class ImageDisplay : public ImageDisplayBase public Q_SLOTS: virtual void updateNormalizeOptions(); + virtual void toggleFullScreen(); protected: // overrides from Display