mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-07 03:30:44 +00:00
Switching metric/english units does change height stored.
This commit is contained in:
parent
ab52d51fe0
commit
b9960b702c
@ -7,6 +7,9 @@
|
|||||||
* License. See the file COPYING in the main directory of the source code
|
* License. See the file COPYING in the main directory of the source code
|
||||||
* for more details. */
|
* for more details. */
|
||||||
|
|
||||||
|
#define TEST_MACROS_ENABLED
|
||||||
|
#include <test_macros.h>
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
@ -137,6 +140,17 @@ QString NewProfile::getIntroHTML()
|
|||||||
"</html>";
|
"</html>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int cmToFeetInch( double cm, double& inches ) {
|
||||||
|
inches = cm * inches_per_cm;
|
||||||
|
int feet = inches / 12;
|
||||||
|
inches -= (double)(feet *12);
|
||||||
|
return feet;
|
||||||
|
}
|
||||||
|
|
||||||
|
double feetInchToCm( int feet , double inches ) {
|
||||||
|
return cms_per_inch*(inches + (double)(feet *12));
|
||||||
|
}
|
||||||
|
|
||||||
void NewProfile::on_nextButton_clicked()
|
void NewProfile::on_nextButton_clicked()
|
||||||
{
|
{
|
||||||
const QString xmlext = ".xml";
|
const QString xmlext = ".xml";
|
||||||
@ -237,31 +251,18 @@ void NewProfile::on_nextButton_clicked()
|
|||||||
ui->timezoneCombo->currentIndex()).toString());
|
ui->timezoneCombo->currentIndex()).toString());
|
||||||
profile->user->setCountry(ui->countryCombo->currentText());
|
profile->user->setCountry(ui->countryCombo->currentText());
|
||||||
profile->user->setDaylightSaving(ui->DSTcheckbox->isChecked());
|
profile->user->setDaylightSaving(ui->DSTcheckbox->isChecked());
|
||||||
UnitSystem us;
|
|
||||||
|
|
||||||
if (ui->heightCombo->currentIndex() == 0) { us = US_Metric; }
|
|
||||||
else if (ui->heightCombo->currentIndex() == 1) { us = US_English; }
|
|
||||||
else { us = US_Metric; }
|
|
||||||
|
|
||||||
|
UnitSystem us = US_Metric;
|
||||||
|
if (ui->heightCombo->currentIndex() == 1) { us = US_English; };
|
||||||
if (profile->general->unitSystem() != us) {
|
if (profile->general->unitSystem() != us) {
|
||||||
profile->general->setUnitSystem(us);
|
profile->general->setUnitSystem(us);
|
||||||
|
|
||||||
if (mainwin && mainwin->getDaily()) { mainwin->getDaily()->UnitsChanged(); }
|
if (mainwin && mainwin->getDaily()) { mainwin->getDaily()->UnitsChanged(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
double v = 0;
|
if (m_height_modified) {
|
||||||
|
profile->user->setHeight(m_tmp_height_cm);
|
||||||
if (us == US_English) {
|
|
||||||
// convert to metric
|
|
||||||
v = (ui->heightEdit->value() * 30.48);
|
|
||||||
v += ui->heightEdit2->value() * 2.54;
|
|
||||||
} else {
|
|
||||||
v = ui->heightEdit->value();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
profile->user->setHeight(v);
|
|
||||||
|
|
||||||
//profile->user->setUserName(username);
|
|
||||||
AppSetting->setProfileName(username);
|
AppSetting->setProfileName(username);
|
||||||
|
|
||||||
profile->Save();
|
profile->Save();
|
||||||
@ -322,6 +323,7 @@ void NewProfile::skipWelcomeScreen()
|
|||||||
ui->backButton->setEnabled(false);
|
ui->backButton->setEnabled(false);
|
||||||
ui->nextButton->setEnabled(true);
|
ui->nextButton->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewProfile::edit(const QString name)
|
void NewProfile::edit(const QString name)
|
||||||
{
|
{
|
||||||
skipWelcomeScreen();
|
skipWelcomeScreen();
|
||||||
@ -388,25 +390,9 @@ void NewProfile::edit(const QString name)
|
|||||||
|
|
||||||
ui->heightCombo->setCurrentIndex(i);
|
ui->heightCombo->setCurrentIndex(i);
|
||||||
|
|
||||||
double v = profile->user->height();
|
m_tmp_height_cm = profile->user->height();
|
||||||
|
m_height_modified = false;
|
||||||
if (us == US_English) { // evil non-metric
|
on_heightCombo_currentIndexChanged(i);
|
||||||
int ti = v / 2.54;
|
|
||||||
int feet = ti / 12;
|
|
||||||
int inches = ti % 12;
|
|
||||||
ui->heightEdit->setValue(feet);
|
|
||||||
ui->heightEdit2->setValue(inches);
|
|
||||||
ui->heightEdit2->setVisible(true);
|
|
||||||
ui->heightEdit->setDecimals(0);
|
|
||||||
ui->heightEdit2->setDecimals(0);
|
|
||||||
ui->heightEdit->setSuffix(STR_UNIT_FOOT); // foot
|
|
||||||
ui->heightEdit2->setSuffix(STR_UNIT_INCH); // inches
|
|
||||||
} else { // good wholesome metric
|
|
||||||
ui->heightEdit->setValue(v);
|
|
||||||
ui->heightEdit2->setVisible(false);
|
|
||||||
ui->heightEdit->setDecimals(0);
|
|
||||||
ui->heightEdit->setSuffix(STR_UNIT_CM);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewProfile::on_passwordEdit1_editingFinished()
|
void NewProfile::on_passwordEdit1_editingFinished()
|
||||||
@ -421,26 +407,40 @@ void NewProfile::on_passwordEdit2_editingFinished()
|
|||||||
|
|
||||||
void NewProfile::on_heightCombo_currentIndexChanged(int index)
|
void NewProfile::on_heightCombo_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
|
ui->heightEdit->blockSignals(true);
|
||||||
|
ui->heightEdit2->blockSignals(true);
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
//metric
|
//metric
|
||||||
ui->heightEdit2->setVisible(false);
|
ui->heightEdit->setDecimals(1);
|
||||||
ui->heightEdit->setDecimals(0);
|
|
||||||
ui->heightEdit->setSuffix(STR_UNIT_CM);
|
ui->heightEdit->setSuffix(STR_UNIT_CM);
|
||||||
double v = ui->heightEdit->value() * 30.48;
|
ui->heightEdit->setValue(m_tmp_height_cm);
|
||||||
v += ui->heightEdit2->value() * 2.54;
|
ui->heightEdit2->setVisible(false);
|
||||||
ui->heightEdit->setValue(v);
|
|
||||||
} else { //evil
|
} else { //evil
|
||||||
ui->heightEdit->setDecimals(0);
|
ui->heightEdit->setDecimals(0); // feet are always a whole number.
|
||||||
ui->heightEdit2->setDecimals(0);
|
ui->heightEdit2->setDecimals(1); // inches can be seen as double.
|
||||||
ui->heightEdit->setSuffix(STR_UNIT_FOOT);
|
ui->heightEdit->setSuffix(STR_UNIT_FOOT);
|
||||||
ui->heightEdit2->setVisible(true);
|
ui->heightEdit2->setVisible(true);
|
||||||
ui->heightEdit2->setSuffix(STR_UNIT_INCH);
|
ui->heightEdit2->setSuffix(STR_UNIT_INCH);
|
||||||
int v = ui->heightEdit->value() / 2.54;
|
double inches=0;
|
||||||
int feet = v / 12;
|
ui->heightEdit->setValue(cmToFeetInch(m_tmp_height_cm,inches));
|
||||||
int inches = v % 12;
|
|
||||||
ui->heightEdit->setValue(feet);
|
|
||||||
ui->heightEdit2->setValue(inches);
|
ui->heightEdit2->setValue(inches);
|
||||||
}
|
}
|
||||||
|
ui->heightEdit->blockSignals(false);
|
||||||
|
ui->heightEdit2->blockSignals(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewProfile::on_heightEdit_valueChanged(double ) {
|
||||||
|
m_height_modified = true;
|
||||||
|
double cm = ui->heightEdit->value();
|
||||||
|
if (ui->heightCombo->currentIndex() == 1) {
|
||||||
|
//US_English;
|
||||||
|
cm = feetInchToCm (cm,ui->heightEdit2->value());
|
||||||
|
};
|
||||||
|
m_tmp_height_cm = cm;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewProfile::on_heightEdit2_valueChanged(double value) {
|
||||||
|
on_heightEdit_valueChanged(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewProfile::on_textBrowser_anchorClicked(const QUrl &arg1)
|
void NewProfile::on_textBrowser_anchorClicked(const QUrl &arg1)
|
||||||
|
@ -53,12 +53,16 @@ class NewProfile : public QDialog
|
|||||||
void on_heightCombo_currentIndexChanged(int index);
|
void on_heightCombo_currentIndexChanged(int index);
|
||||||
|
|
||||||
void on_textBrowser_anchorClicked(const QUrl &arg1);
|
void on_textBrowser_anchorClicked(const QUrl &arg1);
|
||||||
|
void on_heightEdit_valueChanged(double height);
|
||||||
|
void on_heightEdit2_valueChanged(double inches);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString getIntroHTML();
|
QString getIntroHTML();
|
||||||
|
|
||||||
Ui::NewProfile *ui;
|
Ui::NewProfile *ui;
|
||||||
bool m_editMode;
|
bool m_editMode;
|
||||||
|
bool m_height_modified;
|
||||||
|
double m_tmp_height_cm;
|
||||||
int m_firstPage;
|
int m_firstPage;
|
||||||
bool m_passwordHashed;
|
bool m_passwordHashed;
|
||||||
};
|
};
|
||||||
|
@ -444,6 +444,9 @@
|
|||||||
<property name="decimals">
|
<property name="decimals">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>11.9</double>
|
||||||
|
</property>
|
||||||
<property name="singleStep">
|
<property name="singleStep">
|
||||||
<double>1.000000000000000</double>
|
<double>1.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
|
Loading…
Reference in New Issue
Block a user