mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 08:08:42 +00:00
Configurable initial startup view (#4718)
This commit is contained in:
@@ -164,6 +164,7 @@
|
||||
#define GC_TELEMETRY_UPDATE_COUNTER "<global-general>telemetryUpdateCounter"
|
||||
#define GC_LAST_VERSION_CHECKED "<global-general>lastVersionChecked"
|
||||
#define GC_LAST_VERSION_CHECK_DATE "<global-general>lastVersionCheckDate"
|
||||
#define GC_STARTUP_VIEW "<global-general>startupView"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -737,11 +737,9 @@ AbstractView::setPerspectives(QComboBox *perspectiveSelector, bool selectChart)
|
||||
if (!loaded || selectChart) {
|
||||
loaded = true;
|
||||
|
||||
// generally we just go to the first perspective
|
||||
perspectiveSelected(0);
|
||||
|
||||
// allow views to override the default perspective (if required)
|
||||
setViewSpecificPerspective();
|
||||
// generally we just go to the first perspective, but we allow
|
||||
// the views to override the default perspective (if required)
|
||||
perspectiveSelected(getViewSpecificPerspective());
|
||||
|
||||
// due to visibility optimisation we need to force the first tab to be selected in tab mode
|
||||
if (perspective_->currentStyle == 0 && perspective_->charts.count()) perspective_->tabSelected(0);
|
||||
|
||||
@@ -188,7 +188,7 @@ class AbstractView : public QWidget
|
||||
virtual void notifyViewStateRestored();
|
||||
virtual void notifyViewPerspectiveAdded(Perspective* page);
|
||||
virtual void notifyViewSidebarChanged() {}
|
||||
virtual void setViewSpecificPerspective() {}
|
||||
virtual int getViewSpecificPerspective() { return 0; }
|
||||
virtual void notifyViewSplitterMoved() {}
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -169,7 +169,11 @@ AthleteTab::view(int index)
|
||||
void
|
||||
AthleteTab::selectView(int index)
|
||||
{
|
||||
if (views->currentIndex() == index) return; // not changing
|
||||
// ensure an initial viewChanged() event occurs for the navigation model, otherwise if the
|
||||
// startup view is trends (value zero) the guard rejects the selection as views->currentIndex() is zero
|
||||
static bool startupView = true;
|
||||
if (!startupView && views->currentIndex() == index) return; // not changing
|
||||
startupView = false;
|
||||
|
||||
emit viewChanged(index);
|
||||
|
||||
|
||||
@@ -707,7 +707,15 @@ MainWindow::MainWindow(const QDir &home)
|
||||
//connect(this, SIGNAL(rideClean()), this, SLOT(enableSaveButton()));
|
||||
|
||||
saveGCState(currentAthleteTab->context); // set to whatever we started with
|
||||
selectAnalysis();
|
||||
|
||||
// switch to the startup view, default is analysis.
|
||||
switch (appsettings->value(NULL, GC_STARTUP_VIEW, "1").toInt()) {
|
||||
case 0: selectTrends(); break;
|
||||
case 1: selectAnalysis(); break;
|
||||
case 2: selectDiary(); break;
|
||||
case 3: selectTrain(); break;
|
||||
default: selectAnalysis(); qDebug() << "Unknown startup view"; break;
|
||||
}
|
||||
|
||||
//grab focus
|
||||
currentAthleteTab->setFocus();
|
||||
|
||||
@@ -227,7 +227,7 @@ NavigationModel::forward()
|
||||
stack[stackpointer+2].after.toInt() == 1) { // switch to analysis
|
||||
|
||||
stackpointer++;
|
||||
action(false, stack[stackpointer]);
|
||||
action(true, stack[stackpointer]);
|
||||
}
|
||||
|
||||
// redo
|
||||
@@ -235,4 +235,5 @@ NavigationModel::forward()
|
||||
action(true, stack[stackpointer]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -243,6 +243,16 @@ GeneralPage::GeneralPage(Context *context) : context(context)
|
||||
|
||||
connect(athleteBrowseButton, SIGNAL(clicked()), this, SLOT(browseAthleteDir()));
|
||||
|
||||
startupView = new QComboBox();
|
||||
startupView->addItem(tr("Trends"));
|
||||
startupView->addItem(tr("Analysis"));
|
||||
startupView->addItem(tr("Train"));
|
||||
|
||||
// map view indexes to combo box values, given that plan/diary is not available
|
||||
int startView = appsettings->value(NULL, GC_STARTUP_VIEW, "1").toInt();
|
||||
if (startView == 3) startView = 2;
|
||||
startupView->setCurrentIndex(startView);
|
||||
|
||||
QFormLayout *form = newQFormLayout();
|
||||
form->addRow(new QLabel(HLO + tr("Localization") + HLC));
|
||||
form->addRow(tr("Language"), langCombo);
|
||||
@@ -252,6 +262,7 @@ GeneralPage::GeneralPage(Context *context) : context(context)
|
||||
form->addItem(new QSpacerItem(0, 15 * dpiYFactor));
|
||||
form->addRow(new QLabel(HLO + tr("Application Behaviour") + HLC));
|
||||
form->addRow(tr("Athlete Library"), athleteDirectoryLayout);
|
||||
form->addRow(tr("Startup View"), startupView);
|
||||
form->addRow("", warnOnExit);
|
||||
form->addRow("", openLastAthlete);
|
||||
form->addRow("", opendata);
|
||||
@@ -305,6 +316,11 @@ GeneralPage::saveClicked()
|
||||
};
|
||||
appsettings->setValue(GC_LANG, langs[langCombo->currentIndex()]);
|
||||
|
||||
// map combo box values to view indexes, given that plan/diary is not available
|
||||
int startView = startupView->currentIndex();
|
||||
if (startView == 2) startView = 3;
|
||||
appsettings->setValue(GC_STARTUP_VIEW, startView);
|
||||
|
||||
// Garmin and cranks
|
||||
appsettings->setValue(GC_GARMIN_HWMARK, garminHWMarkedit->value());
|
||||
appsettings->setValue(GC_GARMIN_SMARTRECORD, garminSmartRecord->checkState());
|
||||
|
||||
@@ -98,6 +98,7 @@ class GeneralPage : public QWidget
|
||||
Context *context;
|
||||
|
||||
QComboBox *langCombo;
|
||||
QComboBox* startupView;
|
||||
QComboBox *wbalForm;
|
||||
QCheckBox *garminSmartRecord;
|
||||
QCheckBox *warnOnExit;
|
||||
|
||||
@@ -77,23 +77,12 @@ AnalysisView::setRide(RideItem *ride)
|
||||
// then lets go find one to switch to..
|
||||
if (context->mainWindow->athleteTab()->currentView() == 1 && page()->relevant(ride) != true) {
|
||||
|
||||
// lets find one to switch to
|
||||
Perspective *found=page();
|
||||
foreach(Perspective *p, perspectives_){
|
||||
if (p->relevant(ride)) {
|
||||
found =p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// none of them want to be selected, so we can stay on the current one
|
||||
// so long as it doesn't have an expression that failed...
|
||||
if (found == page() && page()->expression() != "")
|
||||
found = perspectives_[0];
|
||||
// lets find a perspective to switch to
|
||||
int ridePerspectiveIdx = findRidesPerspective(ride);
|
||||
|
||||
// if we need to switch, i.e. not already on it
|
||||
if (found != page()) {
|
||||
context->mainWindow->switchPerspective(perspectives_.indexOf(found));
|
||||
if (ridePerspectiveIdx != perspectives_.indexOf(page())) {
|
||||
context->mainWindow->switchPerspective(ridePerspectiveIdx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,6 +90,24 @@ AnalysisView::setRide(RideItem *ride)
|
||||
page()->setProperty("ride", QVariant::fromValue<RideItem*>(dynamic_cast<RideItem*>(ride)));
|
||||
}
|
||||
|
||||
int
|
||||
AnalysisView::findRidesPerspective(RideItem* ride)
|
||||
{
|
||||
// lets find one to switch to
|
||||
foreach(Perspective *p, perspectives_) {
|
||||
if (p->relevant(ride)) {
|
||||
return perspectives_.indexOf(p);
|
||||
}
|
||||
}
|
||||
|
||||
// none of them want to be selected, so we can stay on the current one
|
||||
// so long as it doesn't have an expression that failed...
|
||||
if (page()->expression() != "") return 0;
|
||||
|
||||
// we can just return the current one
|
||||
return perspectives_.indexOf(page());
|
||||
}
|
||||
|
||||
void
|
||||
AnalysisView::addIntervals()
|
||||
{
|
||||
@@ -137,12 +144,11 @@ AnalysisView::notifyViewSidebarChanged() {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AnalysisView::setViewSpecificPerspective() {
|
||||
int
|
||||
AnalysisView::getViewSpecificPerspective() {
|
||||
|
||||
// Setting the ride for analysis view also sets the perspective.
|
||||
RideItem* ride = (RideItem*)context->currentRideItem();
|
||||
if (ride != NULL) setRide(ride);
|
||||
return findRidesPerspective(const_cast<RideItem*>(context->currentRideItem()));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -50,9 +50,12 @@ class AnalysisView : public AbstractView
|
||||
protected:
|
||||
|
||||
void notifyViewSidebarChanged() override;
|
||||
void setViewSpecificPerspective() override;
|
||||
int getViewSpecificPerspective() override;
|
||||
void notifyViewSplitterMoved() override;
|
||||
|
||||
private:
|
||||
|
||||
int findRidesPerspective(RideItem* ride);
|
||||
};
|
||||
|
||||
class DiarySidebar;
|
||||
|
||||
Reference in New Issue
Block a user