From 1fe044777ebf3424509cd13a7415d0a44c5e387f Mon Sep 17 00:00:00 2001 From: Felix Date: Mon, 11 Jun 2018 20:58:49 +0200 Subject: [PATCH 1/3] keep track of fullscreen state so we don't accidentally hide the toolbar --- src/rviz/visualization_frame.cpp | 6 +++++- src/rviz/visualization_frame.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/rviz/visualization_frame.cpp b/src/rviz/visualization_frame.cpp index 8f8658fd5b..5770c71257 100644 --- a/src/rviz/visualization_frame.cpp +++ b/src/rviz/visualization_frame.cpp @@ -126,6 +126,8 @@ VisualizationFrame::VisualizationFrame( QWidget* parent ) , loading_( false ) , post_load_timer_( new QTimer( this )) , frame_count_(0) + , toolbar_visible_(true) + , is_fullscreen_(false) { panel_factory_ = new PanelFactory(); @@ -1247,6 +1249,7 @@ void VisualizationFrame::onDeletePanel() void VisualizationFrame::setFullScreen( bool full_screen ) { + is_fullscreen_ = full_screen; Q_EMIT( fullScreenChange( full_screen ) ); if (full_screen) @@ -1265,7 +1268,8 @@ void VisualizationFrame::setFullScreen( bool full_screen ) void VisualizationFrame::exitFullScreen() { - setFullScreen( false ); + if (is_fullscreen_) + setFullScreen( false ); } QDockWidget* VisualizationFrame::addPanelByName( const QString& name, diff --git a/src/rviz/visualization_frame.h b/src/rviz/visualization_frame.h index 00bfd2176d..9c1215f690 100644 --- a/src/rviz/visualization_frame.h +++ b/src/rviz/visualization_frame.h @@ -362,6 +362,8 @@ protected Q_SLOTS: /// Indicates if the toolbar should be visible outside of fullscreen mode. bool toolbar_visible_; + /// Prevent exiting fullscreen if not in fullscreen + bool is_fullscreen_; }; } From 6ff2aefd8894836baa453f7c5443be31bf799a48 Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Wed, 6 Mar 2019 16:05:19 +0100 Subject: [PATCH 2/3] cleanup --- src/rviz/visualization_frame.cpp | 15 ++++++--------- src/rviz/visualization_frame.h | 2 -- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/rviz/visualization_frame.cpp b/src/rviz/visualization_frame.cpp index 5770c71257..28da1c30fa 100644 --- a/src/rviz/visualization_frame.cpp +++ b/src/rviz/visualization_frame.cpp @@ -127,7 +127,6 @@ VisualizationFrame::VisualizationFrame( QWidget* parent ) , post_load_timer_( new QTimer( this )) , frame_count_(0) , toolbar_visible_(true) - , is_fullscreen_(false) { panel_factory_ = new PanelFactory(); @@ -1249,27 +1248,25 @@ void VisualizationFrame::onDeletePanel() void VisualizationFrame::setFullScreen( bool full_screen ) { - is_fullscreen_ = full_screen; + Qt::WindowStates state = windowState(); + if (full_screen == state.testFlag(Qt::WindowFullScreen)) + return; Q_EMIT( fullScreenChange( full_screen ) ); + // when switching to fullscreen, remember visibility state of toolbar if (full_screen) toolbar_visible_ = toolbar_->isVisible(); menuBar()->setVisible(!full_screen); toolbar_->setVisible(!full_screen && toolbar_visible_); statusBar()->setVisible(!full_screen); setHideButtonVisibility(!full_screen); - - if (full_screen) - setWindowState(windowState() | Qt::WindowFullScreen); - else - setWindowState(windowState() & ~Qt::WindowFullScreen); + setWindowState(state.setFlag(Qt::WindowFullScreen, full_screen)); show(); } void VisualizationFrame::exitFullScreen() { - if (is_fullscreen_) - setFullScreen( false ); + setFullScreen( false ); } QDockWidget* VisualizationFrame::addPanelByName( const QString& name, diff --git a/src/rviz/visualization_frame.h b/src/rviz/visualization_frame.h index 9c1215f690..00bfd2176d 100644 --- a/src/rviz/visualization_frame.h +++ b/src/rviz/visualization_frame.h @@ -362,8 +362,6 @@ protected Q_SLOTS: /// Indicates if the toolbar should be visible outside of fullscreen mode. bool toolbar_visible_; - /// Prevent exiting fullscreen if not in fullscreen - bool is_fullscreen_; }; } From c7e73d0b4a0a0f2c6013d69820ef11c75332f023 Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Wed, 6 Mar 2019 20:43:30 +0100 Subject: [PATCH 3/3] setFlag() was only introduced in Qt 5.7 --- src/rviz/visualization_frame.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rviz/visualization_frame.cpp b/src/rviz/visualization_frame.cpp index 28da1c30fa..9b8616d2a4 100644 --- a/src/rviz/visualization_frame.cpp +++ b/src/rviz/visualization_frame.cpp @@ -1260,7 +1260,11 @@ void VisualizationFrame::setFullScreen( bool full_screen ) toolbar_->setVisible(!full_screen && toolbar_visible_); statusBar()->setVisible(!full_screen); setHideButtonVisibility(!full_screen); - setWindowState(state.setFlag(Qt::WindowFullScreen, full_screen)); + + if (full_screen) + setWindowState(state | Qt::WindowFullScreen); + else + setWindowState(state & ~Qt::WindowFullScreen); show(); }