Skip to content

Commit

Permalink
View sidebar controls
Browse files Browse the repository at this point in the history
.. when enter/leave full screen mode the view sidebar is
   hidden and shown to increase screen real estate (and
   especially useful in train view).

.. since the user may want to show/hide for other reasons
   the view menu now also has an option to show/hide the
   view sidebar selector too.
  • Loading branch information
liversedge committed Nov 18, 2021
1 parent b12e1fa commit 20201c1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/Gui/MainWindow.cpp
Expand Up @@ -626,6 +626,9 @@ MainWindow::MainWindow(const QDir &home)
#else
viewMenu->addAction(tr("Toggle Full Screen"), this, SLOT(toggleFullScreen()));
#endif
showhideViewbar = viewMenu->addAction(tr("Show View Sidebar"), this, SLOT(showViewbar(bool)));
showhideViewbar->setCheckable(true);
showhideViewbar->setChecked(true);
showhideSidebar = viewMenu->addAction(tr("Show Left Sidebar"), this, SLOT(showSidebar(bool)));
showhideSidebar->setCheckable(true);
showhideSidebar->setChecked(true);
Expand Down Expand Up @@ -793,7 +796,13 @@ MainWindow::toggleSidebar()
currentAthleteTab->toggleSidebar();
setToolButtons();
}

void
MainWindow::showViewbar(bool want)
{
want ? sidebar->show() : sidebar->hide();
showhideViewbar->setChecked(want);
setToolButtons();
}
void
MainWindow::showSidebar(bool want)
{
Expand Down Expand Up @@ -1071,7 +1080,14 @@ bool
MainWindow::eventFilter(QObject *o, QEvent *e)
{
if (o == this) {
if (e->type() == QEvent::WindowStateChange) resizeEvent(NULL); // see below
if (e->type() == QEvent::WindowStateChange) {

// if we are entering full screen mode we hide the sidebar
if (windowState()&Qt::WindowFullScreen) showViewbar(false);
else showViewbar(true);

resizeEvent(NULL); // see below
}
}
return false;
}
Expand All @@ -1081,6 +1097,7 @@ MainWindow::resizeEvent(QResizeEvent*)
{
//appsettings->setValue(GC_SETTINGS_MAIN_GEOM, saveGeometry());
//appsettings->setValue(GC_SETTINGS_MAIN_STATE, saveState());

}

void
Expand Down
2 changes: 2 additions & 0 deletions src/Gui/MainWindow.h
Expand Up @@ -210,6 +210,7 @@ class MainWindow : public QMainWindow
void showOptions();

void toggleSidebar();
void showViewbar(bool want);
void showSidebar(bool want);
void showToolbar(bool want);
void showTabbar(bool want);
Expand Down Expand Up @@ -337,6 +338,7 @@ class MainWindow : public QMainWindow

// Toolbar state checkables in View menu / context
QAction *styleAction;
QAction *showhideViewbar;
QAction *showhideLowbar;
QAction *showhideToolbar;
QAction *showhideTabbar;
Expand Down

0 comments on commit 20201c1

Please sign in to comment.