Subversion Repositories public

Rev

Rev 230 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 230 Rev 232
Line 17... Line 17...
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18
 ***************************************************************************/
18
 ***************************************************************************/
19
 
19
 
20
 
20
 
21
#include "settingswidget.h"
21
#include "settingswidget.h"
22
#include <ksimpleconfig.h>
22
#include <KConfig>
23
#include <knuminput.h>
23
#include <knuminput.h>
24
#include <kcombobox.h>
24
#include <kcombobox.h>
25
#include <kurlrequester.h>
25
#include <kurlrequester.h>
26
#include <klineedit.h>
26
#include <klineedit.h>
27
#include <qdir.h>
27
#include <qdir.h>
28
#include <qcheckbox.h>
28
#include <qcheckbox.h>
29
#include <qradiobutton.h>
29
#include <qradiobutton.h>
30
 
30
 
31
settingsWidget::settingsWidget ( QWidget* parent, const char* name, bool modal, WFlags fl )
31
settingsWidget::settingsWidget ( QWidget* parent, Qt::WFlags fl )
32
		: settingsWidgetBase ( parent,name, modal,fl )
32
		: QDialog(parent, fl), Ui::settingsWidgetBase ()
33
{
33
{
34
KComboBox *cb;
34
KComboBox *cb;
35
QDir dir = QDir::home();
35
QDir dir = QDir::home();
36
QString path = dir.absPath();
36
QString path = dir.absolutePath();
37
 
37
 
-
 
38
	setupUi (this);
38
	// Load the config parameters
39
	// Load the config parameters
39
	cbDevice->setShowLocalProtocol(false);
40
	cbDevice->setMode(KFile::ExistingOnly | KFile::LocalOnly);
40
	cb = cbDevice->comboBox();
41
	cb = cbDevice->comboBox();
41
	cb->insertURL(KURL("/dev/ttyUSB0"));
42
	cb->insertUrl(1, KUrl("/dev/ttyUSB0"));
42
	cb->insertURL(KURL("/dev/ttyUSB1"));
43
	cb->insertUrl(2, KUrl("/dev/ttyUSB1"));
43
	cb->insertURL(KURL("/dev/ttyS0"));
44
	cb->insertUrl(3, KUrl("/dev/ttyS0"));
44
	cb->insertURL(KURL("/dev/ttyS1"));
45
	cb->insertUrl(4, KUrl("/dev/ttyS1"));
45
	KSimpleConfig *cfg = new KSimpleConfig(QString("sportwatcher.rc"), true);
46
	KConfig cfg (QString("sportwatcher.rc"), KConfig::SimpleConfig);
46
	cfg->setGroup(QString("SportWatcher"));
47
	KConfigGroup ic (&cfg, "SportWatcher");
47
	intLower1->setValue(cfg->readNumEntry("lower1"));
48
	intLower1->setValue(ic.readEntry("lower1", 0));
48
	intLower2->setValue(cfg->readNumEntry("lower2"));
49
	intLower2->setValue(ic.readEntry("lower2", 0));
49
	intLower3->setValue(cfg->readNumEntry("lower3"));
50
	intLower3->setValue(ic.readEntry("lower3", 0));
50
	intUpper1->setValue(cfg->readNumEntry("upper1"));
51
	intUpper1->setValue(ic.readEntry("upper1", 0));
51
	intUpper2->setValue(cfg->readNumEntry("upper2"));
52
	intUpper2->setValue(ic.readEntry("upper2", 0));
52
	intUpper3->setValue(cfg->readNumEntry("upper3"));
53
	intUpper3->setValue(ic.readEntry("upper3", 0));
53
	intMaxHr->setValue(cfg->readNumEntry("maxHr"));
54
	intMaxHr->setValue(ic.readEntry("maxHr", 0));
54
	intRestHr->setValue(cfg->readNumEntry("restHr"));
55
	intRestHr->setValue(ic.readEntry("restHr", 0));
55
	intVO2max->setValue(cfg->readNumEntry("vo2max"));
56
	intVO2max->setValue(ic.readEntry("vo2max", 0));
56
	intWeight->setValue(cfg->readNumEntry("weight"));
57
	intWeight->setValue(ic.readEntry("weight", 0));
57
	cbSampleTime->setCurrentItem(cfg->readNumEntry("seconds"));
58
	cbSampleTime->setCurrentIndex(ic.readEntry("seconds", 1));
58
	// If serial device is selected, activate the radio buttons
59
	// If serial device is selected, activate the radio buttons
59
	// to select the type of Forerunner used.
60
	// to select the type of Forerunner used.
60
	cbSerial->setChecked(cfg->readBoolEntry("Serial", false));
61
	cbSerial->setChecked(ic.readEntry("Serial", false));
61
 
62
 
62
	if (cfg->readBoolEntry("Serial", false))
63
	if (ic.readEntry("Serial", false))
63
	{
64
	{
64
	   rbFr50->setEnabled (true);
65
	   rbFr50->setEnabled (true);
65
//	   rbFr405->setEnabled (true);
66
//	   rbFr405->setEnabled (true);
66
	   cbDevice->setEnabled (true);
67
	   cbDevice->setEnabled (true);
67
 
68
 
68
	   // If "Forerunner" == false, Forerunner 405 is set.
69
	   // If "Forerunner" == false, Forerunner 405 is set.
69
	   if (cfg->readBoolEntry("Forerunner", false))
70
	   if (ic.readEntry("Forerunner", false))
70
	   {
71
	   {
71
	      rbFr50->setChecked(false);
72
	      rbFr50->setChecked(false);
72
	      rbFr405->setChecked(true);
73
	      rbFr405->setChecked(true);
73
	   }
74
	   }
74
	   else
75
	   else
Line 82... Line 83...
82
	   rbFr50->setEnabled (false);
83
	   rbFr50->setEnabled (false);
83
	   rbFr405->setEnabled (false);
84
	   rbFr405->setEnabled (false);
84
	   cbDevice->setEnabled (false);
85
	   cbDevice->setEnabled (false);
85
	}
86
	}
86
 
87
 
87
	cbContour->setChecked(cfg->readBoolEntry("Contour", false));
88
	cbContour->setChecked(ic.readEntry("Contour", false));
88
	cbDevice->setURL(cfg->readEntry("Device"));
89
	cbDevice->setUrl(ic.readEntry("Device", QString("/dev/ttyUSB0")));
89
	lnData->setURL(cfg->readEntry("Data", path + "/.sportwatcher"));
90
	lnData->setUrl(ic.readEntry("Data", path + "/.sportwatcher"));
90
	lnHRM->setURL(cfg->readEntry("HRM", path + "/polar"));
91
	lnHRM->setUrl(ic.readEntry("HRM", path + "/polar"));
91
	lnMapFile->setURL(cfg->readEntry("MAP", cfg->readEntry("Data", path + "/.sportwatcher/track.wms")));
92
	lnMapFile->setUrl(ic.readEntry("MAP", ic.readEntry("Data", path + "/.sportwatcher/track.wms")));
92
	cbUnit->setCurrentItem(cfg->readNumEntry("Units", 0));
93
	cbUnit->setCurrentIndex(ic.readEntry("Units", 0));
93
	cbMapType->setCurrentItem(cfg->readNumEntry("MapType", 7));
94
	cbMapType->setCurrentIndex(ic.readEntry("MapType", 7));
94
	delete cfg;
-
 
95
}
95
}
96
 
96
 
97
settingsWidget::~settingsWidget()
97
settingsWidget::~settingsWidget()
98
{
98
{
99
}
99
}
Line 136... Line 136...
136
	done(QDialog::Rejected);
136
	done(QDialog::Rejected);
137
}
137
}
138
 
138
 
139
void settingsWidget::btSaveSlot()
139
void settingsWidget::btSaveSlot()
140
{
140
{
141
	KSimpleConfig *cfg = new KSimpleConfig(QString("sportwatcher.rc"));
141
	KConfig cfg (QString("sportwatcher.rc"), KConfig::SimpleConfig);
142
	cfg->setGroup(QString("SportWatcher"));
142
	KConfigGroup ic (&cfg, "SportWatcher");
143
	// Put the data into the config file
143
	// Put the data into the config file
144
	cfg->writeEntry("lower1", intLower1->value());
144
	ic.writeEntry("lower1", intLower1->value());
145
	cfg->writeEntry("lower2", intLower2->value());
145
	ic.writeEntry("lower2", intLower2->value());
146
	cfg->writeEntry("lower3", intLower3->value());
146
	ic.writeEntry("lower3", intLower3->value());
147
	cfg->writeEntry("upper1", intUpper1->value());
147
	ic.writeEntry("upper1", intUpper1->value());
148
	cfg->writeEntry("upper2", intUpper2->value());
148
	ic.writeEntry("upper2", intUpper2->value());
149
	cfg->writeEntry("upper3", intUpper3->value());
149
	ic.writeEntry("upper3", intUpper3->value());
150
	cfg->writeEntry("maxHr", intMaxHr->value());
150
	ic.writeEntry("maxHr", intMaxHr->value());
151
	cfg->writeEntry("restHr", intRestHr->value());
151
	ic.writeEntry("restHr", intRestHr->value());
152
	cfg->writeEntry("vo2max", intVO2max->value());
152
	ic.writeEntry("vo2max", intVO2max->value());
153
	cfg->writeEntry("weight", intWeight->value());
153
	ic.writeEntry("weight", intWeight->value());
154
	cfg->writeEntry("seconds", cbSampleTime->currentItem());
154
	ic.writeEntry("seconds", cbSampleTime->currentIndex());
155
	cfg->writeEntry("Serial", cbSerial->isChecked());
155
	ic.writeEntry("Serial", cbSerial->isChecked());
156
	cfg->writeEntry("Contour", cbContour->isChecked());
156
	ic.writeEntry("Contour", cbContour->isChecked());
157
	cfg->writeEntry("Device", cbDevice->url());
157
	ic.writeEntry("Device", cbDevice->url());
158
	cfg->writeEntry("Data", lnData->lineEdit()->text());
158
	ic.writeEntry("Data", lnData->lineEdit()->text());
159
	cfg->writeEntry("HRM", lnHRM->lineEdit()->text());
159
	ic.writeEntry("HRM", lnHRM->lineEdit()->text());
160
	cfg->writeEntry("MAP", lnMapFile->lineEdit()->text());
160
	ic.writeEntry("MAP", lnMapFile->lineEdit()->text());
161
	cfg->writeEntry("Units", cbUnit->currentItem());
161
	ic.writeEntry("Units", cbUnit->currentIndex());
162
	cfg->writeEntry("MapType", cbMapType->currentItem());
162
	ic.writeEntry("MapType", cbMapType->currentIndex());
163
	cfg->writeEntry("Forerunner", rbFr50->isChecked());
163
	ic.writeEntry("Forerunner", rbFr50->isChecked());
164
	cfg->sync();
164
	cfg.sync();
165
	delete cfg;
-
 
166
	done(QDialog::Accepted);
165
	done(QDialog::Accepted);
167
}
166
}
168
 
167
 
169
 
168
 
170
 
169