Subversion Repositories public

Rev

Rev 88 | Rev 143 | 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"));
59
	delete cfg;
60
}
61
 
62
settingsWidget::~settingsWidget()
63
{
64
}
65
 
66
/*$SPECIALIZATION$*/
67
void settingsWidget::btCancelSlot()
68
{
69
	done(QDialog::Rejected);
70
}
71
 
72
void settingsWidget::btSaveSlot()
73
{
74
	KSimpleConfig *cfg = new KSimpleConfig(QString("sportwatcher.rc"));
75
	cfg->setGroup(QString("SportWatcher"));
76
	// Put the data into the config file
77
	cfg->writeEntry("lower1", intLower1->value());
78
	cfg->writeEntry("lower2", intLower2->value());
79
	cfg->writeEntry("lower3", intLower3->value());
80
	cfg->writeEntry("upper1", intUpper1->value());
81
	cfg->writeEntry("upper2", intUpper2->value());
82
	cfg->writeEntry("upper3", intUpper3->value());
83
	cfg->writeEntry("maxHr", intMaxHr->value());
84
	cfg->writeEntry("restHr", intRestHr->value());
85
	cfg->writeEntry("vo2max", intVO2max->value());
86
	cfg->writeEntry("weight", intWeight->value());
87
	cfg->writeEntry("seconds", cbSampleTime->currentItem());
88
	cfg->writeEntry("Device", cbDevice->comboBox()->currentText());
89
	cfg->writeEntry("Data", lnData->lineEdit()->text());
90
	cfg->writeEntry("HRM", lnHRM->lineEdit()->text());
91
	cfg->sync();
92
	delete cfg;
93
	done(QDialog::Accepted);
94
}
95
 
96
 
97
 
98
#include "settingswidget.moc"
99