Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fullscreen option. #1017

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/rviz/panel_dock_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ void PanelDockWidget::setCollapsed( bool collapse )
{
if ( isVisible() )
{
QDockWidget::setVisible( false );
PanelDockWidget::setVisible( false );
collapsed_ = collapse;
}
}
else
{
QDockWidget::setVisible( true );
PanelDockWidget::setVisible( true );
collapsed_ = collapse;
}
}
Expand Down Expand Up @@ -144,4 +144,16 @@ void PanelDockWidget::load( Config config )
config.mapGetBool( "collapsed", &collapsed_ );
}

void PanelDockWidget::setVisible( bool visible )
{
requested_visibility_ = visible;
QDockWidget::setVisible(requested_visibility_ && !forced_hidden_);
}

void PanelDockWidget::overrideVisibility( bool hidden )
{
forced_hidden_ = hidden;
setVisible(requested_visibility_);
}

} // end namespace rviz
8 changes: 8 additions & 0 deletions src/rviz/panel_dock_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ Q_OBJECT
virtual void save( Config config );
virtual void load( Config config );

/** @brief Override setVisible to respect the visibility override, */
virtual void setVisible( bool visible );

protected:

virtual void closeEvent ( QCloseEvent * event );
Expand All @@ -66,6 +69,9 @@ public Q_SLOTS:

void setWindowTitle( QString title );

/** @ Override the visibility of the widget. **/
virtual void overrideVisibility( bool hide );

private Q_SLOTS:
void onChildDestroyed( QObject* );

Expand All @@ -76,6 +82,8 @@ private Q_SLOTS:
private:
// set to true if this panel was collapsed
bool collapsed_;
bool requested_visibility_;
bool forced_hidden_;
QLabel *icon_label_;
QLabel *title_label_;
};
Expand Down
31 changes: 31 additions & 0 deletions src/rviz/visualization_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <fstream>

#include <QAction>
#include <QShortcut>
#include <QApplication>
#include <QCloseEvent>
#include <QDesktopServices>
Expand Down Expand Up @@ -463,6 +464,12 @@ void VisualizationFrame::initMenus()
view_menu_->addAction( "Add &New Panel", this, SLOT( openNewPanelDialog() ));
delete_view_menu_ = view_menu_->addMenu( "&Delete Panel" );
delete_view_menu_->setEnabled( false );

QAction * fullscreen_action = view_menu_->addAction("&Fullscreen", this, SLOT( setFullScreen(bool) ), Qt::Key_F11);
fullscreen_action->setCheckable(true);
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 Expand Up @@ -1211,6 +1218,29 @@ void VisualizationFrame::onDeletePanel()
}
}

void VisualizationFrame::setFullScreen( bool full_screen )
{
Q_EMIT( fullScreenChange( full_screen ) );

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);
show();
}

void VisualizationFrame::exitFullScreen()
{
setFullScreen( false );
}

QDockWidget* VisualizationFrame::addPanelByName( const QString& name,
const QString& class_id,
Qt::DockWidgetArea area,
Expand Down Expand Up @@ -1251,6 +1281,7 @@ PanelDockWidget* VisualizationFrame::addPane( const QString& name, QWidget* pane

// we want to know when that panel becomes visible
connect( dock, SIGNAL( visibilityChanged( bool )), this, SLOT( onDockPanelVisibilityChange( bool ) ));
connect( this, SIGNAL( fullScreenChange(bool) ), dock, SLOT( overrideVisibility(bool) ));

QAction* toggle_action = dock->toggleViewAction();
view_menu_->addAction( toggle_action );
Expand Down
13 changes: 12 additions & 1 deletion src/rviz/visualization_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ public Q_SLOTS:
/** @brief Emitted during file-loading and initialization to indicate progress. */
void statusUpdate( const QString& message );

/** @brief Emitted when the interface enters or leaves full screen mode. */
void fullScreenChange( bool hidden );

protected Q_SLOTS:
void onOpen();
void onSave();
Expand Down Expand Up @@ -219,6 +222,12 @@ protected Q_SLOTS:
* the name of the panel. */
void onDeletePanel();

/** @brief Set full screen mode. */
void setFullScreen( bool full_screen );

/** @brief Exit full screen mode. */
void exitFullScreen();

protected Q_SLOTS:
/** @brief Set loading_ to false. */
void markLoadingDone();
Expand Down Expand Up @@ -299,7 +308,6 @@ protected Q_SLOTS:
QMenu* view_menu_;
QMenu* delete_view_menu_;
QMenu* plugins_menu_;
QList<QAction*> view_menu_actions_;

QToolBar* toolbar_;

Expand Down Expand Up @@ -350,6 +358,9 @@ protected Q_SLOTS:
ros::WallTime last_fps_calc_time_;

QString error_message_; ///< Error message (if any) from most recent saveDisplayConfig() call.

/// Indicates if the toolbar should be visible outside of fullscreen mode.
bool toolbar_visible_;
};

}
Expand Down