remember chosen PM metric across restarts

This commit is contained in:
Sean Rhea
2010-02-07 09:02:21 -08:00
parent fae1ea3f92
commit f930c6f272
3 changed files with 18 additions and 1 deletions

View File

@@ -50,6 +50,13 @@ PerformanceManagerWindow::PerformanceManagerWindow(MainWindow *mainWindow) :
metricCombo = new QComboBox(this);
metricCombo->addItem(tr("Use BikeScore"), "skiba_bike_score");
metricCombo->addItem(tr("Use DanielsPoints"), "daniels_points");
boost::shared_ptr<QSettings> settings = GetApplicationSettings();
QString metricName =
settings->value(GC_PERF_MAN_METRIC, "skiba_bike_score").toString();
for (int i = 0; i < metricCombo->count(); ++i) {
if (metricCombo->itemData(i).toString() == metricName)
metricCombo->setCurrentIndex(i);
}
metric = metricCombo->itemData(metricCombo->currentIndex()).toString();
PMPickerLayout->addWidget(metricCombo);
@@ -92,7 +99,7 @@ PerformanceManagerWindow::PerformanceManagerWindow(MainWindow *mainWindow) :
connect(PMpicker, SIGNAL(moved(const QPoint &)),
SLOT(PMpickerMoved(const QPoint &)));
connect(metricCombo, SIGNAL(currentIndexChanged(int)),
this, SLOT(replot()));
this, SLOT(metricChanged()));
connect(mainWindow, SIGNAL(configChanged()), this, SLOT(configChanged()));
}
@@ -109,6 +116,14 @@ void PerformanceManagerWindow::configChanged()
replot();
}
void PerformanceManagerWindow::metricChanged()
{
QString newMetric = metricCombo->itemData(metricCombo->currentIndex()).toString();
boost::shared_ptr<QSettings> settings = GetApplicationSettings();
settings->setValue(GC_PERF_MAN_METRIC, newMetric);
replot();
}
void PerformanceManagerWindow::setActive(bool value)
{
if (value)

View File

@@ -53,6 +53,7 @@ class PerformanceManagerWindow : public QWidget
void setPMSizeFromSlider();
void replot();
void configChanged();
void metricChanged();
protected:

View File

@@ -31,6 +31,7 @@
#define GC_SETTINGS_CALENDAR_SIZES "mainwindow/calendarSizes"
#define GC_SETTINGS_INTERVAL_METRICS "rideSummaryWindow/intervalMetrics"
#define GC_RIDE_PLOT_SMOOTHING "ridePlot/Smoothing"
#define GC_PERF_MAN_METRIC "performanceManager/metric"
#define GC_SETTINGS_INTERVAL_METRICS_DEFAULT "workout_time,total_distance,total_work,average_power,skiba_xpower,max_power,average_hr,ninety_five_percent_hr,average_cad,average_speed"
#define GC_DATETIME_FORMAT "ddd MMM dd, yyyy, hh:mm AP"
#define GC_UNIT "unit"