diff --git a/src/Core/Settings.h b/src/Core/Settings.h index 68c054ef8..104b974b4 100644 --- a/src/Core/Settings.h +++ b/src/Core/Settings.h @@ -110,6 +110,7 @@ #define GC_SETTINGS_LAST "mainwindow/lastOpened" #define GC_SETTINGS_MAIN_GEOM "mainwindow/geometry" #define GC_SETTINGS_MAIN_STATE "mainwindow/state" +#define GC_SETTINGS_MAIN_SIDEBAR "mainwindow/sidebar/" #define GC_SETTINGS_LAST_IMPORT_PATH "mainwindow/lastImportPath" #define GC_SETTINGS_LAST_WORKOUT_PATH "mainwindow/lastWorkoutPath" #define GC_LAST_DOWNLOAD_DEVICE "mainwindow/lastDownloadDevice" diff --git a/src/Gui/MainWindow.h b/src/Gui/MainWindow.h index 83d79dd98..0fe214e67 100644 --- a/src/Gui/MainWindow.h +++ b/src/Gui/MainWindow.h @@ -95,6 +95,9 @@ class MainWindow : public QMainWindow Tab *athleteTab() { return currentTab; } NewSideBar *newSidebar() { return sidebar; } + // tab view keeps this up to date + QAction *showhideSidebar; + protected: // used by ChooseCyclistDialog to see which athletes @@ -306,7 +309,6 @@ class MainWindow : public QMainWindow // Toolbar state checkables in View menu / context QAction *styleAction; - QAction *showhideSidebar; QAction *showhideLowbar; QAction *showhideToolbar; QAction *showhideTabbar; diff --git a/src/Gui/TabView.cpp b/src/Gui/TabView.cpp index a42dc2fdb..f1a9e0543 100644 --- a/src/Gui/TabView.cpp +++ b/src/Gui/TabView.cpp @@ -367,8 +367,12 @@ TabView::setBlank(BlankStatePage *blank) void TabView::sidebarChanged() { + // wait for main window to catch up if (sidebar_ == NULL) return; + // tell main window qmenu we changed + if (context->mainWindow->init) context->mainWindow->showhideSidebar->setChecked(_sidebar); + if (sidebarEnabled()) { setUpdatesEnabled(false); @@ -386,8 +390,8 @@ TabView::sidebarChanged() // if it was collapsed we need set to at least 200 // unless the mainwindow isn't big enough if (sidebar_->width()<10) { - int size = width() - 200; - if (size>200) size = 200; + int size = width() - 200 * dpiXFactor; + if (size>(200* dpiXFactor)) size = 200* dpiXFactor; QList sizes; sizes.append(size); @@ -399,7 +403,7 @@ TabView::sidebarChanged() // we are the analysis view // all a bit of a hack to stop the column widths from // being adjusted as the splitter gets resized and reset - if (type == VIEW_ANALYSIS && active == false && context->tab->rideNavigator()->geometry().width() != 100) + if (context->mainWindow->init && type == VIEW_ANALYSIS && active == false && context->tab->rideNavigator()->geometry().width() != 100) context->tab->rideNavigator()->setWidth(context->tab->rideNavigator()->geometry().width()); setUpdatesEnabled(true); @@ -418,6 +422,9 @@ TabView::selectionChanged() // we got selected.. if (isSelected()) { + // makes sure menu now reflects our setting + context->mainWindow->showhideSidebar->setChecked(_sidebar); + // or do we need to show blankness? if (isBlank() && blank_ && page_ && blank_->canShow()) { diff --git a/src/Gui/Views.cpp b/src/Gui/Views.cpp index 2714508aa..8901edae9 100644 --- a/src/Gui/Views.cpp +++ b/src/Gui/Views.cpp @@ -43,6 +43,8 @@ AnalysisView::AnalysisView(Context *context, QStackedWidget *controls) : TabView setBlank(b); setBottom(new ComparePane(context, this, ComparePane::interval)); + setSidebarEnabled(appsettings->value(this, GC_SETTINGS_MAIN_SIDEBAR "analysis", true).toBool()); + connect(bottomSplitter(), SIGNAL(compareChanged(bool)), this, SLOT(compareChanged(bool))); connect(bottomSplitter(), SIGNAL(compareClear()), bottom(), SLOT(clear())); } @@ -54,6 +56,7 @@ RideNavigator *AnalysisView::rideNavigator() AnalysisView::~AnalysisView() { + appsettings->setValue(GC_SETTINGS_MAIN_SIDEBAR "analysis", _sidebar); } void @@ -100,11 +103,13 @@ DiaryView::DiaryView(Context *context, QStackedWidget *controls) : TabView(conte setPage(d); setBlank(b); + setSidebarEnabled(appsettings->value(this, GC_SETTINGS_MAIN_SIDEBAR "diary", true).toBool()); connect(s, SIGNAL(dateRangeChanged(DateRange)), this, SLOT(dateRangeChanged(DateRange))); } DiaryView::~DiaryView() { + appsettings->setValue(GC_SETTINGS_MAIN_SIDEBAR "diary", _sidebar); } void @@ -141,6 +146,7 @@ HomeView::HomeView(Context *context, QStackedWidget *controls) : TabView(context setBlank(b); setBottom(new ComparePane(context, this, ComparePane::season)); + setSidebarEnabled(appsettings->value(this, GC_SETTINGS_MAIN_SIDEBAR "trend", true).toBool()); connect(sidebar, SIGNAL(dateRangeChanged(DateRange)), this, SLOT(dateRangeChanged(DateRange))); connect(this, SIGNAL(onSelectionChanged()), this, SLOT(justSelected())); connect(bottomSplitter(), SIGNAL(compareChanged(bool)), this, SLOT(compareChanged(bool))); @@ -149,6 +155,7 @@ HomeView::HomeView(Context *context, QStackedWidget *controls) : TabView(context HomeView::~HomeView() { + appsettings->setValue(GC_SETTINGS_MAIN_SIDEBAR "trend", _sidebar); } void @@ -199,6 +206,7 @@ TrainView::TrainView(Context *context, QStackedWidget *controls) : TabView(conte setBottom(trainBottom); setHideBottomOnIdle(false); + setSidebarEnabled(appsettings->value(NULL, GC_SETTINGS_MAIN_SIDEBAR "train").toBool()); connect(this, SIGNAL(onSelectionChanged()), this, SLOT(onSelectionChanged())); connect(trainBottom, SIGNAL(autoHideChanged(bool)), this, SLOT(onAutoHideChanged(bool))); } @@ -210,6 +218,7 @@ void TrainView::onAutoHideChanged(bool enabled) TrainView::~TrainView() { + appsettings->setValue(GC_SETTINGS_MAIN_SIDEBAR "train", _sidebar); } void