add language selector and French translations

This commit is contained in:
Damien Grauser
2009-11-30 20:47:42 +01:00
committed by Sean Rhea
parent 29a9e41444
commit 216bc6ef4b
11 changed files with 2262 additions and 115 deletions

View File

@@ -470,13 +470,13 @@ AllPlot::setYMax()
setAxisLabelAlignment(yLeft2,Qt::AlignVCenter);
}
if (speedCurve->isVisible()) {
setAxisTitle(yRight, (useMetricUnits ? "KPH" : "MPH"));
setAxisTitle(yRight, (useMetricUnits ? tr("KPH") : tr("MPH")));
setAxisScale(yRight, 0.0, 1.05 * speedCurve->maxYValue());
setAxisLabelRotation(yRight,90);
setAxisLabelAlignment(yRight,Qt::AlignVCenter);
}
if (altCurve->isVisible()) {
setAxisTitle(yRight2, useMetricUnits ? "Meters" : "Feet");
setAxisTitle(yRight2, useMetricUnits ? tr("Meters") : tr("Feet"));
double ymin = altCurve->minYValue();
double ymax = qMax(ymin + 100, 1.05 * altCurve->maxYValue());
setAxisScale(yRight2, ymin, ymax);
@@ -495,9 +495,9 @@ void
AllPlot::setXTitle()
{
if (bydist)
setAxisTitle(xBottom, "Distance "+QString(unit.toString() == "Metric"?"(km)":"(miles)"));
setAxisTitle(xBottom, tr("Distance ")+QString(unit.toString() == "Metric"?"(km)":"(miles)"));
else
setAxisTitle(xBottom, "Time (minutes)");
setAxisTitle(xBottom, tr("Time (minutes)"));
}
void

View File

@@ -147,8 +147,18 @@ void ConfigDialog::changePage(QListWidgetItem *current, QListWidgetItem *previou
// ! new mode: change the CP associated with the present mode
void ConfigDialog::save_Clicked()
{
boost::shared_ptr<QSettings> settings = GetApplicationSettings();
settings->setValue(GC_UNIT, configPage->unitCombo->currentText());
boost::shared_ptr<QSettings> settings = GetApplicationSettings();
if (configPage->langCombo->currentIndex()==0)
settings->setValue(GC_LANG, "en");
else if (configPage->langCombo->currentIndex()==1)
settings->setValue(GC_LANG, "fr");
if (configPage->unitCombo->currentIndex()==0)
settings->setValue(GC_UNIT, "Metric");
else if (configPage->unitCombo->currentIndex()==1)
settings->setValue(GC_UNIT, "English");
settings->setValue(GC_ALLRIDES_ASCENDING, configPage->allRidesAscending->checkState());
settings->setValue(GC_CRANKLENGTH, configPage->crankLengthCombo->currentText());
settings->setValue(GC_BIKESCOREDAYS, configPage->BSdaysEdit->text());

View File

@@ -49,8 +49,8 @@ CpintPlot::CpintPlot(QString p, const Zones *zones) :
insertLegend(new QwtLegend(), QwtPlot::BottomLegend);
setCanvasBackground(Qt::white);
setAxisTitle(yLeft, "Average Power (watts)");
setAxisTitle(xBottom, "Interval Length");
setAxisTitle(yLeft, tr("Average Power (watts)"));
setAxisTitle(xBottom, tr("Interval Length"));
setAxisScaleDraw(xBottom, new LogTimeScaleDraw);
setAxisScaleEngine(xBottom, new LogTimeScaleEngine);
setAxisScale(xBottom, 1.0 / 60.0, 60);
@@ -272,16 +272,16 @@ CpintPlot::setEnergyMode(bool value)
{
energyMode_ = value;
if (energyMode_) {
setAxisTitle(yLeft, "Total work (kJ)");
setAxisTitle(yLeft, tr("Total work (kJ)"));
setAxisScaleEngine(xBottom, new QwtLinearScaleEngine);
setAxisScaleDraw(xBottom, new QwtScaleDraw);
setAxisTitle(xBottom, "Interval Length (minutes)");
setAxisTitle(xBottom, tr("Interval Length (minutes)"));
}
else {
setAxisTitle(yLeft, "Average Power (watts)");
setAxisTitle(yLeft, tr("Average Power (watts)"));
setAxisScaleEngine(xBottom, new LogTimeScaleEngine);
setAxisScaleDraw(xBottom, new LogTimeScaleDraw);
setAxisTitle(xBottom, "Interval Length");
setAxisTitle(xBottom, tr("Interval Length"));
}
delete CPCurve;
CPCurve = NULL;
@@ -546,7 +546,7 @@ CpintPlot::plot_allCurve(CpintPlot *thisPlot,
}
// no zones available: just plot the curve without zones
else {
QwtPlotCurve *curve = new QwtPlotCurve("maximal power");
QwtPlotCurve *curve = new QwtPlotCurve(tr("maximal power"));
curve->setRenderHint(QwtPlotItem::RenderAntialiased);
QPen pen(Qt::red);
pen.setWidth(2.0);

View File

@@ -75,8 +75,8 @@ CriticalPowerWindow::CriticalPowerWindow(const QDir &home, MainWindow *parent) :
otherLayout->addWidget(cpintSetCPButton);
otherLayout->addWidget(cComboSeason);
QComboBox *yAxisCombo = new QComboBox(this);
yAxisCombo->addItem("Y Axis Shows Power");
yAxisCombo->addItem("Y Axis Shows Energy");
yAxisCombo->addItem(tr("Y Axis Shows Power"));
yAxisCombo->addItem(tr("Y Axis Shows Energy"));
otherLayout->addWidget(yAxisCombo);
bottomLayout->addLayout(otherLayout);
@@ -223,7 +223,7 @@ CriticalPowerWindow::pickerMoved(const QPoint &pos)
label = QString("%1 kJ (%2)").arg(watts * minutes * 60.0 / 1000.0, 0, 'f', 0);
else
label = QString("%1 watts (%2)").arg(watts);
label = label.arg(date.isValid() ? date.toString("MM/dd/yyyy") : "no date");
label = label.arg(date.isValid() ? date.toString("MM/dd/yyyy") : tr("no date"));
}
else
label = tr("no data");
@@ -245,7 +245,7 @@ void CriticalPowerWindow::addSeasons()
seasons = handler.getSeasons();
Season season;
season.setName("All Seasons");
season.setName(tr("All Seasons"));
seasons.insert(0,season);
foreach (Season season, seasons)

View File

@@ -10,10 +10,13 @@
ConfigurationPage::~ConfigurationPage()
{
delete configGroup;
delete langLabel;
delete langCombo;
delete unitLabel;
delete unitCombo;
delete allRidesAscending;
delete warningLabel;
delete langLayout;
delete unitLayout;
delete warningLayout;
delete configLayout;
@@ -24,14 +27,29 @@ ConfigurationPage::ConfigurationPage()
{
configGroup = new QGroupBox(tr("Golden Cheetah Configuration"));
boost::shared_ptr<QSettings> settings = GetApplicationSettings();
langLabel = new QLabel(tr("Language:"));
langCombo = new QComboBox();
langCombo->addItem(tr("English"));
langCombo->addItem(tr("French"));
QVariant lang = settings->value(GC_LANG);
if(lang.toString() == "en")
langCombo->setCurrentIndex(0);
else if(lang.toString() == "fr")
langCombo->setCurrentIndex(1);
else // default : English
langCombo->setCurrentIndex(0);
unitLabel = new QLabel(tr("Unit of Measurement:"));
unitCombo = new QComboBox();
unitCombo->addItem(tr("Metric"));
unitCombo->addItem(tr("English"));
boost::shared_ptr<QSettings> settings = GetApplicationSettings();
QVariant unit = settings->value(GC_UNIT);
if(unit.toString() == "Metric")
@@ -88,6 +106,10 @@ ConfigurationPage::ConfigurationPage()
warningLabel = new QLabel(tr("Requires Restart To Take Effect"));
langLayout = new QHBoxLayout;
langLayout->addWidget(langLabel);
langLayout->addWidget(langCombo);
unitLayout = new QHBoxLayout;
unitLayout->addWidget(unitLabel);
unitLayout->addWidget(unitCombo);
@@ -131,6 +153,7 @@ ConfigurationPage::ConfigurationPage()
configLayout = new QVBoxLayout;
configLayout->addLayout(langLayout);
configLayout->addLayout(unitLayout);
configLayout->addWidget(allRidesAscending);
configLayout->addLayout(crankLengthLayout);

View File

@@ -27,30 +27,35 @@ class QVBoxLayout;
class ConfigurationPage : public QWidget
{
Q_OBJECT
public:
~ConfigurationPage();
ConfigurationPage();
QComboBox *langCombo;
QComboBox *unitCombo;
QComboBox *crankLengthCombo;
QCheckBox *allRidesAscending;
QLineEdit *BSdaysEdit;
QComboBox *bsModeCombo;
QLineEdit *BSdaysEdit;
QComboBox *bsModeCombo;
private:
QGroupBox *configGroup;
QLabel *unitLabel;
QLabel *warningLabel;
QHBoxLayout *unitLayout;
QHBoxLayout *warningLayout;
QVBoxLayout *configLayout;
QVBoxLayout *mainLayout;
QGridLayout *bsDaysLayout;
QHBoxLayout *bsModeLayout;
QGroupBox *configGroup;
QLabel *langLabel;
QLabel *unitLabel;
QLabel *warningLabel;
QHBoxLayout *langLayout;
QHBoxLayout *unitLayout;
QHBoxLayout *warningLayout;
QVBoxLayout *configLayout;
QVBoxLayout *mainLayout;
QGridLayout *bsDaysLayout;
QHBoxLayout *bsModeLayout;
};
class CyclistPage : public QWidget
{
Q_OBJECT
public:
~CyclistPage();
CyclistPage(const Zones *_zones);
@@ -70,118 +75,120 @@ class CyclistPage : public QWidget
QLabel *txtEndDate;
QLabel *lblStartDate;
QLabel *lblEndDate;
QLabel *perfManLabel;
QLabel *perfManStartLabel;
QLabel *perfManSTSLabel;
QLabel *perfManLTSLabel;
QLineEdit *perfManStart;
QLineEdit *perfManSTSavg;
QLineEdit *perfManLTSavg;
QLabel *perfManLabel;
QLabel *perfManStartLabel;
QLabel *perfManSTSLabel;
QLabel *perfManLTSLabel;
QLineEdit *perfManStart;
QLineEdit *perfManSTSavg;
QLineEdit *perfManLTSavg;
int getCurrentRange();
bool isNewMode();
bool isNewMode();
inline void setCPFocus() {
txtThreshold->setFocus();
}
inline void setCPFocus() {
txtThreshold->setFocus();
}
inline QDate selectedDate() {
return calendar->selectedDate();
}
inline QDate selectedDate() {
return calendar->selectedDate();
}
private:
QGroupBox *cyclistGroup;
QGroupBox *cyclistGroup;
const Zones *zones;
int currentRange;
QLabel *lblThreshold;
QLabel *lblThreshold;
QLineEdit *txtThreshold;
QIntValidator *txtThresholdValidator;
QVBoxLayout *perfManLayout;
QHBoxLayout *perfManStartValLayout;
QHBoxLayout *perfManSTSavgLayout;
QHBoxLayout *perfManLTSavgLayout;
QHBoxLayout *powerLayout;
QHBoxLayout *rangeLayout;
QHBoxLayout *dateRangeLayout;
QHBoxLayout *zoneLayout;
QHBoxLayout *calendarLayout;
QVBoxLayout *cyclistLayout;
QVBoxLayout *mainLayout;
QIntValidator *perfManStartValidator;
QIntValidator *perfManSTSavgValidator;
QIntValidator *perfManLTSavgValidator;
QIntValidator *txtThresholdValidator;
QVBoxLayout *perfManLayout;
QHBoxLayout *perfManStartValLayout;
QHBoxLayout *perfManSTSavgLayout;
QHBoxLayout *perfManLTSavgLayout;
QHBoxLayout *powerLayout;
QHBoxLayout *rangeLayout;
QHBoxLayout *dateRangeLayout;
QHBoxLayout *zoneLayout;
QHBoxLayout *calendarLayout;
QVBoxLayout *cyclistLayout;
QVBoxLayout *mainLayout;
QIntValidator *perfManStartValidator;
QIntValidator *perfManSTSavgValidator;
QIntValidator *perfManLTSavgValidator;
};
class deviceModel : public QAbstractTableModel
{
Q_OBJECT
public:
deviceModel(QObject *parent=0);
QObject *parent;
public:
deviceModel(QObject *parent=0);
QObject *parent;
// sets up the headers
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
// sets up the headers
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
// how much data do we have?
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
// how much data do we have?
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
// manipulate the data - data() gets and setData() sets (set/get might be better?)
QVariant data(const QModelIndex &index, int role) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
// manipulate the data - data() gets and setData() sets (set/get might be better?)
QVariant data(const QModelIndex &index, int role) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
// insert/remove and update
void add(DeviceConfiguration &); // add a new DeviceConfiguration
void del(); // add a new DeviceConfiguration
bool insertRows(int position, int rows, const QModelIndex &index=QModelIndex());
bool removeRows(int position, int rows, const QModelIndex &index=QModelIndex());
// insert/remove and update
void add(DeviceConfiguration &); // add a new DeviceConfiguration
void del(); // add a new DeviceConfiguration
bool insertRows(int position, int rows, const QModelIndex &index=QModelIndex());
bool removeRows(int position, int rows, const QModelIndex &index=QModelIndex());
QList<DeviceConfiguration> Configuration; // the actual data
QList<DeviceConfiguration> Configuration; // the actual data
};
class DevicePage : public QWidget
{
Q_OBJECT
public:
~DevicePage();
DevicePage(QWidget *parent = 0);
void setConfigPane();
void pairClicked(DeviceConfiguration *, QProgressDialog *);
QList<DeviceType> devices;
QList<DeviceType> devices;
// GUI Elements
QGroupBox *deviceGroup;
QLabel *nameLabel;
QLineEdit *deviceName;
// GUI Elements
QGroupBox *deviceGroup;
QLabel *nameLabel;
QLineEdit *deviceName;
QLabel *typeLabel;
QComboBox *typeSelector;
QLabel *typeLabel;
QComboBox *typeSelector;
QLabel *specLabel;
QLabel *specHint; // hints at the format for a port spec
QLabel *profHint; // hints at the format for profile info
QLineEdit *deviceSpecifier;
QLabel *specLabel;
QLabel *specHint; // hints at the format for a port spec
QLabel *profHint; // hints at the format for profile info
QLineEdit *deviceSpecifier;
QLabel *profLabel;
QLineEdit *deviceProfile;
QLabel *profLabel;
QLineEdit *deviceProfile;
QCheckBox *isDefaultDownload;
QCheckBox *isDefaultRealtime;
QCheckBox *isDefaultDownload;
QCheckBox *isDefaultRealtime;
QTableView *deviceList;
QTableView *deviceList;
QPushButton *addButton;
QPushButton *delButton;
QPushButton *pairButton;
QPushButton *addButton;
QPushButton *delButton;
QPushButton *pairButton;
QGridLayout *leftLayout;
QVBoxLayout *rightLayout;
QGridLayout *leftLayout;
QVBoxLayout *rightLayout;
QGridLayout *inLayout;
QVBoxLayout *mainLayout;
QGridLayout *inLayout;
QVBoxLayout *mainLayout;
deviceModel *deviceListModel;
deviceModel *deviceListModel;
};

View File

@@ -1,16 +1,16 @@
/*
/*
* Copyright (c) 2006 Sean C. Rhea (srhea@srhea.net)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -18,7 +18,7 @@
#ifndef _GC_Settings_h
#define _GC_Settings_h 1
#define GC_SETTINGS_CO "goldencheetah.org"
#define GC_SETTINGS_APP "GoldenCheetah"
#define GC_SETTINGS_LAST "mainwindow/lastOpened"
@@ -31,6 +31,7 @@
#define GC_SETTINGS_CALENDAR_SIZES "mainwindow/calendarSizes"
#define GC_DATETIME_FORMAT "ddd MMM dd, yyyy, hh:mm AP"
#define GC_UNIT "unit"
#define GC_LANG "lang"
#define GC_SETTINGS_LAST_IMPORT_PATH "mainwindow/lastImportPath"
#define GC_ALLRIDES_ASCENDING "allRidesAscending"
#define GC_CRANKLENGTH "crankLength"
@@ -64,7 +65,7 @@
#include <boost/shared_ptr.hpp>
inline boost::shared_ptr<QSettings> GetApplicationSettings()
{
{
boost::shared_ptr<QSettings> settings;
QDir home = QDir();
//First check to see if the Library folder exists where the executable is (for USB sticks)
@@ -72,7 +73,7 @@ inline boost::shared_ptr<QSettings> GetApplicationSettings()
settings = boost::shared_ptr<QSettings>(new QSettings(GC_SETTINGS_CO, GC_SETTINGS_APP));
else
settings = boost::shared_ptr<QSettings>(new QSettings(home.absolutePath()+"/gc", QSettings::IniFormat));
return settings;
}

View File

@@ -7,5 +7,6 @@
<file>images/update.png</file>
<file>images/gc.png</file>
<file>images/config.png</file>
<file>translations/gc_fr.qm</file>
</qresource>
</RCC>

View File

@@ -1,16 +1,16 @@
/*
/*
* Copyright (c) 2006 Sean C. Rhea (srhea@srhea.net)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -23,16 +23,16 @@
#include "MainWindow.h"
#include "Settings.h"
// BLECK - homedir passing via global becuase ridefile is pure virtual and
// BLECK - homedir passing via global becuase ridefile is pure virtual and
// cannot pass with current definition -- Sean can advise!!
extern QString WKO_HOMEDIR;
MainWindow *mainwindow;
int
int
main(int argc, char *argv[])
{
QApplication app(argc, argv);
//this is the path within the current directory where GC will look for
//files to allow USB stick support
QString localLibraryPath="Library/GoldenCheetah";
@@ -87,6 +87,14 @@ main(int argc, char *argv[])
}
boost::shared_ptr<QSettings> settings;
settings = GetApplicationSettings();
// Language setting
QVariant lang = settings->value(GC_LANG);
// Load specific translation
QTranslator gcTranslator;
gcTranslator.load(":translations/gc_" + lang.toString() + ".qm");
app.installTranslator(&gcTranslator);
QVariant lastOpened = settings->value(GC_SETTINGS_LAST);
QVariant unit = settings->value(GC_UNIT);
double crankLength = settings->value(GC_CRANKLENGTH).toDouble();

BIN
src/translations/gc_fr.qm Normal file

Binary file not shown.

2097
src/translations/gc_fr.ts Normal file

File diff suppressed because it is too large Load Diff