From 9ae771084bf80342121e05062ba0f8a085b26f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Fri, 8 Jul 2022 02:09:03 +0200 Subject: [PATCH] Make the graph tabs display configurable on Android --- src/GUI/gui.cpp | 29 ++++++++++++++++++++++++++++- src/GUI/gui.h | 8 ++++++-- src/GUI/settings.h | 2 ++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/GUI/gui.cpp b/src/GUI/gui.cpp index 46572bba..f8ce63cc 100644 --- a/src/GUI/gui.cpp +++ b/src/GUI/gui.cpp @@ -473,6 +473,13 @@ void GUI::createActions() _showGraphSliderInfoAction->setCheckable(true); connect(_showGraphSliderInfoAction, &QAction::triggered, this, &GUI::showGraphSliderInfo); +#ifdef Q_OS_ANDROID + _showGraphTabsAction = new QAction(tr("Show tabs"), this); + _showGraphTabsAction->setMenuRole(QAction::NoRole); + _showGraphTabsAction->setCheckable(true); + connect(_showGraphTabsAction, &QAction::triggered, this, + &GUI::showGraphTabs); +#endif // Q_OS_ANDROID // Settings actions #ifndef Q_OS_ANDROID @@ -631,6 +638,9 @@ void GUI::createMenus() graphMenu->addSeparator(); graphMenu->addAction(_showGraphGridAction); graphMenu->addAction(_showGraphSliderInfoAction); +#ifdef Q_OS_ANDROID + graphMenu->addAction(_showGraphTabsAction); +#endif // Q_OS_ANDROID graphMenu->addSeparator(); graphMenu->addAction(_showGraphsAction); @@ -1637,7 +1647,12 @@ void GUI::showGraphs(bool show) _graphTabWidget->setHidden(!show); } -#ifndef Q_OS_ANDROID +#ifdef Q_OS_ANDROID +void GUI::showGraphTabs(bool show) +{ + _graphTabWidget->tabBar()->setVisible(show); +} +#else // Q_OS_ANDROID void GUI::showToolbars(bool show) { if (show) { @@ -2407,6 +2422,11 @@ void GUI::writeSettings() != SHOW_GRAPH_SLIDER_INFO_DEFAULT) settings.setValue(SHOW_GRAPH_SLIDER_INFO_SETTING, _showGraphSliderInfoAction->isChecked()); +#ifdef Q_OS_ANDROID + if (_showGraphTabsAction->isChecked() != SHOW_GRAPH_TABS_DEFAULT) + settings.setValue(SHOW_GRAPH_TABS_SETTING, + _showGraphTabsAction->isChecked()); +#endif // Q_OS_ANDROID settings.endGroup(); settings.beginGroup(POI_SETTINGS_GROUP); @@ -2746,6 +2766,13 @@ void GUI::readSettings(QString &activeMap, QStringList &disabledPOIs) showGraphSliderInfo(false); else _showGraphSliderInfoAction->setChecked(true); +#ifdef Q_OS_ANDROID + if (!settings.value(SHOW_GRAPH_TABS_SETTING, SHOW_GRAPH_TABS_DEFAULT) + .toBool()) + showGraphTabs(false); + else + _showGraphTabsAction->setChecked(true); +#endif // Q_OS_ANDROID settings.endGroup(); settings.beginGroup(POI_SETTINGS_GROUP); diff --git a/src/GUI/gui.h b/src/GUI/gui.h index 26fc01fa..a41a32aa 100644 --- a/src/GUI/gui.h +++ b/src/GUI/gui.h @@ -71,7 +71,9 @@ private slots: void showGraphGrids(bool show); void showGraphSliderInfo(bool show); void showPathMarkerInfo(QAction *action); -#ifndef Q_OS_ANDROID +#ifdef Q_OS_ANDROID + void showGraphTabs(bool show); +#else // Q_OS_ANDROID void showToolbars(bool show); void showFullscreen(bool show); #endif // Q_OS_ANDROID @@ -231,7 +233,9 @@ private: QAction *_showGraphSliderInfoAction; QAction *_distanceGraphAction; QAction *_timeGraphAction; -#ifndef Q_OS_ANDROID +#ifdef Q_OS_ANDROID + QAction *_showGraphTabsAction; +#else // Q_OS_ANDROID QAction *_keysAction; QAction *_fullscreenAction; QAction *_showToolbarsAction; diff --git a/src/GUI/settings.h b/src/GUI/settings.h index 40d27bff..db4cea31 100644 --- a/src/GUI/settings.h +++ b/src/GUI/settings.h @@ -32,6 +32,8 @@ #define SHOW_GRAPH_GRIDS_DEFAULT true #define SHOW_GRAPH_SLIDER_INFO_SETTING "sliderInfo" #define SHOW_GRAPH_SLIDER_INFO_DEFAULT true +#define SHOW_GRAPH_TABS_SETTING "tabs" +#define SHOW_GRAPH_TABS_DEFAULT true #define SHOW_TICKS_SETTING "pathTicks" #define SHOW_TICKS_DEFAULT false