Subversion Repositories public

Rev

Rev 100 | Rev 149 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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>
28
 
29
settingsWidget::settingsWidget ( QWidget* parent, const char* name, bool modal, WFlags fl )
30
		: settingsWidgetBase ( parent,name, modal,fl )
31
{
32
KComboBox *cb;
33
QDir dir = QDir::home();
34
QString path = dir.absPath();
35
 
36
	// Load the config parameters
37
	cbDevice->setShowLocalProtocol(false);
38
	cb = cbDevice->comboBox();
39
	cb->insertURL(KURL("/dev/ttyUSB0"));
100 andreas 40
	cb->insertURL(KURL("/dev/ttyUSB1"));
88 andreas 41
	cb->insertURL(KURL("/dev/ttyS0"));
42
	cb->insertURL(KURL("/dev/ttyS1"));
43
	KSimpleConfig *cfg = new KSimpleConfig(QString("sportwatcher.rc"), true);
44
	cfg->setGroup(QString("SportWatcher"));
45
	intLower1->setValue(cfg->readNumEntry("lower1"));
46
	intLower2->setValue(cfg->readNumEntry("lower2"));
47
	intLower3->setValue(cfg->readNumEntry("lower3"));
48
	intUpper1->setValue(cfg->readNumEntry("upper1"));
49
	intUpper2->setValue(cfg->readNumEntry("upper2"));
50
	intUpper3->setValue(cfg->readNumEntry("upper3"));
51
	intMaxHr->setValue(cfg->readNumEntry("maxHr"));
52
	intRestHr->setValue(cfg->readNumEntry("restHr"));
53
	intVO2max->setValue(cfg->readNumEntry("vo2max"));
54
	intWeight->setValue(cfg->readNumEntry("weight"));
55
	cbSampleTime->setCurrentItem(cfg->readNumEntry("seconds"));
56
	cb->insertItem(cfg->readEntry("Device"));
57
	lnData->setURL(cfg->readEntry("Data", path + "/.sportwatcher"));
58
	lnHRM->setURL(cfg->readEntry("HRM", path + "/polar"));
143 andreas 59
	lnMapFile->setURL(cfg->readEntry("MAP", cfg->readEntry("Data", path + "/.sportwatcher")));
88 andreas 60
	delete cfg;
61
}
62
 
63
settingsWidget::~settingsWidget()
64
{
65
}
66
 
67
/*$SPECIALIZATION$*/
68
void settingsWidget::btCancelSlot()
69
{
70
	done(QDialog::Rejected);
71
}
72
 
73
void settingsWidget::btSaveSlot()
74
{
75
	KSimpleConfig *cfg = new KSimpleConfig(QString("sportwatcher.rc"));
76
	cfg->setGroup(QString("SportWatcher"));
77
	// Put the data into the config file
78
	cfg->writeEntry("lower1", intLower1->value());
79
	cfg->writeEntry("lower2", intLower2->value());
80
	cfg->writeEntry("lower3", intLower3->value());
81
	cfg->writeEntry("upper1", intUpper1->value());
82
	cfg->writeEntry("upper2", intUpper2->value());
83
	cfg->writeEntry("upper3", intUpper3->value());
84
	cfg->writeEntry("maxHr", intMaxHr->value());
85
	cfg->writeEntry("restHr", intRestHr->value());
86
	cfg->writeEntry("vo2max", intVO2max->value());
87
	cfg->writeEntry("weight", intWeight->value());
88
	cfg->writeEntry("seconds", cbSampleTime->currentItem());
89
	cfg->writeEntry("Device", cbDevice->comboBox()->currentText());
90
	cfg->writeEntry("Data", lnData->lineEdit()->text());
91
	cfg->writeEntry("HRM", lnHRM->lineEdit()->text());
143 andreas 92
	cfg->writeEntry("MAP", lnMapFile->lineEdit()->text());
88 andreas 93
	cfg->sync();
94
	delete cfg;
95
	done(QDialog::Accepted);
96
}
97
 
98
 
99
 
100
#include "settingswidget.moc"
101