88 |
andreas |
1 |
/***************************************************************************
|
|
|
2 |
* Copyright (C) 2008 by Andreas Theofilu *
|
|
|
3 |
* andreas@theosys.at *
|
|
|
4 |
* *
|
|
|
5 |
* This program is free software; you can redistribute it and/or modify *
|
|
|
6 |
* it under the terms of the GNU General Public License as published by *
|
|
|
7 |
* the Free Software Foundation version 3 of the License. *
|
|
|
8 |
* *
|
|
|
9 |
* This program is distributed in the hope that it will be useful, *
|
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
12 |
* GNU General Public License for more details. *
|
|
|
13 |
* *
|
|
|
14 |
* You should have received a copy of the GNU General Public License *
|
|
|
15 |
* along with this program; if not, write to the *
|
|
|
16 |
* Free Software Foundation, Inc., *
|
|
|
17 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
18 |
***************************************************************************/
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
#include "settingswidget.h"
|
|
|
22 |
#include <ksimpleconfig.h>
|
|
|
23 |
#include <knuminput.h>
|
|
|
24 |
#include <kcombobox.h>
|
|
|
25 |
#include <kurlrequester.h>
|
|
|
26 |
#include <klineedit.h>
|
|
|
27 |
#include <qdir.h>
|
149 |
andreas |
28 |
#include <qcheckbox.h>
|
88 |
andreas |
29 |
|
|
|
30 |
settingsWidget::settingsWidget ( QWidget* parent, const char* name, bool modal, WFlags fl )
|
|
|
31 |
: settingsWidgetBase ( parent,name, modal,fl )
|
|
|
32 |
{
|
|
|
33 |
KComboBox *cb;
|
|
|
34 |
QDir dir = QDir::home();
|
|
|
35 |
QString path = dir.absPath();
|
|
|
36 |
|
|
|
37 |
// Load the config parameters
|
|
|
38 |
cbDevice->setShowLocalProtocol(false);
|
|
|
39 |
cb = cbDevice->comboBox();
|
|
|
40 |
cb->insertURL(KURL("/dev/ttyUSB0"));
|
100 |
andreas |
41 |
cb->insertURL(KURL("/dev/ttyUSB1"));
|
88 |
andreas |
42 |
cb->insertURL(KURL("/dev/ttyS0"));
|
|
|
43 |
cb->insertURL(KURL("/dev/ttyS1"));
|
|
|
44 |
KSimpleConfig *cfg = new KSimpleConfig(QString("sportwatcher.rc"), true);
|
|
|
45 |
cfg->setGroup(QString("SportWatcher"));
|
|
|
46 |
intLower1->setValue(cfg->readNumEntry("lower1"));
|
|
|
47 |
intLower2->setValue(cfg->readNumEntry("lower2"));
|
|
|
48 |
intLower3->setValue(cfg->readNumEntry("lower3"));
|
|
|
49 |
intUpper1->setValue(cfg->readNumEntry("upper1"));
|
|
|
50 |
intUpper2->setValue(cfg->readNumEntry("upper2"));
|
|
|
51 |
intUpper3->setValue(cfg->readNumEntry("upper3"));
|
|
|
52 |
intMaxHr->setValue(cfg->readNumEntry("maxHr"));
|
|
|
53 |
intRestHr->setValue(cfg->readNumEntry("restHr"));
|
|
|
54 |
intVO2max->setValue(cfg->readNumEntry("vo2max"));
|
|
|
55 |
intWeight->setValue(cfg->readNumEntry("weight"));
|
|
|
56 |
cbSampleTime->setCurrentItem(cfg->readNumEntry("seconds"));
|
149 |
andreas |
57 |
cbSerial->setChecked(cfg->readBoolEntry("Serial", false));
|
168 |
andreas |
58 |
cbContour->setChecked(cfg->readBoolEntry("Contour", false));
|
149 |
andreas |
59 |
cbDevice->setURL(cfg->readEntry("Device"));
|
88 |
andreas |
60 |
lnData->setURL(cfg->readEntry("Data", path + "/.sportwatcher"));
|
|
|
61 |
lnHRM->setURL(cfg->readEntry("HRM", path + "/polar"));
|
151 |
andreas |
62 |
lnMapFile->setURL(cfg->readEntry("MAP", cfg->readEntry("Data", path + "/.sportwatcher/track.wms")));
|
149 |
andreas |
63 |
cbUnit->setCurrentItem(cfg->readNumEntry("Units", 0));
|
158 |
andreas |
64 |
cbMapType->setCurrentItem(cfg->readNumEntry("MapType", 7));
|
88 |
andreas |
65 |
delete cfg;
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
settingsWidget::~settingsWidget()
|
|
|
69 |
{
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
/*$SPECIALIZATION$*/
|
|
|
73 |
void settingsWidget::btCancelSlot()
|
|
|
74 |
{
|
|
|
75 |
done(QDialog::Rejected);
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
void settingsWidget::btSaveSlot()
|
|
|
79 |
{
|
|
|
80 |
KSimpleConfig *cfg = new KSimpleConfig(QString("sportwatcher.rc"));
|
|
|
81 |
cfg->setGroup(QString("SportWatcher"));
|
|
|
82 |
// Put the data into the config file
|
|
|
83 |
cfg->writeEntry("lower1", intLower1->value());
|
|
|
84 |
cfg->writeEntry("lower2", intLower2->value());
|
|
|
85 |
cfg->writeEntry("lower3", intLower3->value());
|
|
|
86 |
cfg->writeEntry("upper1", intUpper1->value());
|
|
|
87 |
cfg->writeEntry("upper2", intUpper2->value());
|
|
|
88 |
cfg->writeEntry("upper3", intUpper3->value());
|
|
|
89 |
cfg->writeEntry("maxHr", intMaxHr->value());
|
|
|
90 |
cfg->writeEntry("restHr", intRestHr->value());
|
|
|
91 |
cfg->writeEntry("vo2max", intVO2max->value());
|
|
|
92 |
cfg->writeEntry("weight", intWeight->value());
|
|
|
93 |
cfg->writeEntry("seconds", cbSampleTime->currentItem());
|
149 |
andreas |
94 |
cfg->writeEntry("Serial", cbSerial->isChecked());
|
168 |
andreas |
95 |
cfg->writeEntry("Contour", cbContour->isChecked());
|
149 |
andreas |
96 |
cfg->writeEntry("Device", cbDevice->url());
|
88 |
andreas |
97 |
cfg->writeEntry("Data", lnData->lineEdit()->text());
|
|
|
98 |
cfg->writeEntry("HRM", lnHRM->lineEdit()->text());
|
143 |
andreas |
99 |
cfg->writeEntry("MAP", lnMapFile->lineEdit()->text());
|
149 |
andreas |
100 |
cfg->writeEntry("Units", cbUnit->currentItem());
|
158 |
andreas |
101 |
cfg->writeEntry("MapType", cbMapType->currentItem());
|
88 |
andreas |
102 |
cfg->sync();
|
|
|
103 |
delete cfg;
|
|
|
104 |
done(QDialog::Accepted);
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
|
109 |
#include "settingswidget.moc"
|
|
|
110 |
|