summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sound/soundsettings.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/noncore/settings/sound/soundsettings.cpp b/noncore/settings/sound/soundsettings.cpp
index 6fea3ed..a163d38 100644
--- a/noncore/settings/sound/soundsettings.cpp
+++ b/noncore/settings/sound/soundsettings.cpp
@@ -1,289 +1,293 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "soundsettings.h" 21#include "soundsettings.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qpe/config.h> 24#include <qpe/config.h>
25#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
26#include <qpe/storage.h> 26#include <qpe/storage.h>
27 27
28#include <qapplication.h> 28#include <qapplication.h>
29#include <qslider.h> 29#include <qslider.h>
30#include <qcheckbox.h> 30#include <qcheckbox.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qcombobox.h> 32#include <qcombobox.h>
33 33
34#include <sys/utsname.h> 34#include <sys/utsname.h>
35#include <sys/time.h> 35#include <sys/time.h>
36#include <sys/types.h> 36#include <sys/types.h>
37#include <unistd.h> 37#include <unistd.h>
38#include <stdio.h> 38#include <stdio.h>
39#include <sys/stat.h> 39#include <sys/stat.h>
40 40
41SoundSettings::SoundSettings( QWidget* parent, const char* objname, WFlags fl ) 41SoundSettings::SoundSettings( QWidget* parent, const char* objname, WFlags fl )
42 : SoundSettingsBase( parent, objname, TRUE, fl ) 42 : SoundSettingsBase( parent, objname, TRUE, fl )
43{ 43{
44 keyReset=FALSE; 44 keyReset=FALSE;
45 45
46 Config config( "qpe"); 46 Config config( "qpe");
47 config.setGroup( "Volume" ); 47 config.setGroup( "Volume" );
48 volume->setValue(100-config.readNumEntry("VolumePercent")); 48 volume->setValue(100-config.readNumEntry("VolumePercent"));
49 mic->setValue(100-config.readNumEntry("Mic")); 49 mic->setValue(100-config.readNumEntry("Mic"));
50// touchsound->setChecked(config.readBoolEntry("TouchSound")); 50// touchsound->setChecked(config.readBoolEntry("TouchSound"));
51// keysound->setChecked(config.readBoolEntry("KeySound")); 51// keysound->setChecked(config.readBoolEntry("KeySound"));
52 Config cfg("Vmemo"); 52 Config cfg("Vmemo");
53 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 53 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
54 AlertCheckBox->setChecked(cfg.readBoolEntry("Alert")); 54 AlertCheckBox->setChecked(cfg.readBoolEntry("Alert"));
55 55
56 cfg.setGroup("Record"); 56 cfg.setGroup("Record");
57 int rate=config.readNumEntry("SampleRate", 22050); 57 int rate=config.readNumEntry("SampleRate", 22050);
58 if(rate == 8000) 58 if(rate == 8000)
59 sampleRate->setCurrentItem(0); 59 sampleRate->setCurrentItem(0);
60 else if(rate == 11025) 60 else if(rate == 11025)
61 sampleRate->setCurrentItem(1); 61 sampleRate->setCurrentItem(1);
62 else if(rate == 22050) 62 else if(rate == 22050)
63 sampleRate->setCurrentItem(2); 63 sampleRate->setCurrentItem(2);
64 else if(rate == 33075) 64 else if(rate == 33075)
65 sampleRate->setCurrentItem(3); 65 sampleRate->setCurrentItem(3);
66 else if(rate==44100) 66 else if(rate==44100)
67 sampleRate->setCurrentItem(4); 67 sampleRate->setCurrentItem(4);
68 68
69 stereoCheckBox->setChecked(cfg.readNumEntry("Stereo", 0)); //TODO hide if zaurus- mono only 69 stereoCheckBox->setChecked(cfg.readNumEntry("Stereo", 0)); //TODO hide if zaurus- mono only
70 70
71#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) //since ipaq and zaurus have particular 71#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) //since ipaq and zaurus have particular
72 //devices 72 //devices
73 bool systemZaurus=FALSE; 73 bool systemZaurus=FALSE;
74 struct utsname name; /* check for embedix kernel running on the zaurus*/ 74 struct utsname name; /* check for embedix kernel running on the zaurus*/
75 if (uname(&name) != -1) {// TODO change this here,... 75 if (uname(&name) != -1) {// TODO change this here,...
76 QString release=name.release; 76 QString release=name.release;
77 if( release.find("embedix",0,TRUE) != -1) { 77 if( release.find("embedix",0,TRUE) != -1) {
78 qDebug("IS System Zaurus"); 78 qDebug("IS System Zaurus");
79 systemZaurus=TRUE; 79 systemZaurus=TRUE;
80 } 80 }
81 } 81 }
82 if(!systemZaurus) { 82 if(!systemZaurus) {
83 stereoCheckBox->setChecked(TRUE); 83 stereoCheckBox->setChecked(TRUE);
84 } 84 }
85 stereoCheckBox->setEnabled(FALSE); 85 stereoCheckBox->setEnabled(FALSE);
86 sixteenBitCheckBox->setEnabled(FALSE); 86 sixteenBitCheckBox->setEnabled(FALSE);
87#else 87#else
88#endif 88#endif
89 int sRate=cfg.readNumEntry("SizeLimit", 30); 89 int sRate=cfg.readNumEntry("SizeLimit", 30);
90 qDebug("%d",sRate); 90 qDebug("%d",sRate);
91 91
92 if(sRate ==30) 92 if(sRate ==30)
93 timeLimitComboBox->setCurrentItem(0); 93 timeLimitComboBox->setCurrentItem(0);
94 else if(sRate==20) 94 else if(sRate==20)
95 timeLimitComboBox->setCurrentItem(1); 95 timeLimitComboBox->setCurrentItem(1);
96 else if(sRate == 15) 96 else if(sRate == 15)
97 timeLimitComboBox->setCurrentItem(2); 97 timeLimitComboBox->setCurrentItem(2);
98 else if(sRate == 10) 98 else if(sRate == 10)
99 timeLimitComboBox->setCurrentItem(3); 99 timeLimitComboBox->setCurrentItem(3);
100 else 100 else
101 timeLimitComboBox->setCurrentItem(4); 101 timeLimitComboBox->setCurrentItem(4);
102 102
103 103
104 sixteenBitCheckBox->setChecked(cfg.readNumEntry("SixteenBit", 1)); 104 sixteenBitCheckBox->setChecked(cfg.readNumEntry("SixteenBit", 1));
105 105
106 cfg.setGroup("Defaults"); 106 cfg.setGroup("Defaults");
107 keyComboBox->setCurrentItem(cfg.readNumEntry("toggleKey") ); 107 keyComboBox->setCurrentItem(cfg.readNumEntry("toggleKey") );
108 108
109 updateStorageCombo(); 109 updateStorageCombo();
110 110
111 connect(volume, SIGNAL(valueChanged(int)), this, SLOT(setVolume(int))); 111 connect(volume, SIGNAL(valueChanged(int)), this, SLOT(setVolume(int)));
112 connect(mic, SIGNAL(valueChanged(int)), this, SLOT(setMic(int))); 112 connect(mic, SIGNAL(valueChanged(int)), this, SLOT(setMic(int)));
113 connect(qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); 113 connect(qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) );
114 connect(qApp, SIGNAL( micChanged(bool) ), this, SLOT ( micChanged(bool) ) ); 114 connect(qApp, SIGNAL( micChanged(bool) ), this, SLOT ( micChanged(bool) ) );
115 115
116 connect( LocationComboBox,SIGNAL(activated(const QString &)),this,SLOT( setLocation(const QString &))); 116 connect( LocationComboBox,SIGNAL(activated(const QString &)),this,SLOT( setLocation(const QString &)));
117 connect( keyComboBox,SIGNAL(activated(const QString &)),this,SLOT( setKeyButton(const QString &))); 117 connect( keyComboBox,SIGNAL(activated(const QString &)),this,SLOT( setKeyButton(const QString &)));
118 connect( timeLimitComboBox,SIGNAL(activated( const QString &)),this,SLOT( setSizeLimitButton(const QString &))); 118 connect( timeLimitComboBox,SIGNAL(activated( const QString &)),this,SLOT( setSizeLimitButton(const QString &)));
119// connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 119// connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
120} 120}
121 121
122// void SoundSettings::reject() 122// void SoundSettings::reject()
123// { 123// {
124// qDebug("reject"); 124// qDebug("reject");
125// Config config( "qpe"); 125// Config config( "qpe");
126// config.setGroup( "Volume"); 126// config.setGroup( "Volume");
127 127
128// setVolume(100-config.readNumEntry("VolumePercent")); 128// setVolume(100-config.readNumEntry("VolumePercent"));
129// setMic(100-config.readNumEntry("Mic")); 129// setMic(100-config.readNumEntry("Mic"));
130 130
131// // config.setGroup("Record"); 131// // config.setGroup("Record");
132// // int rate=config.readNumEntry("SampleRate", 11025); 132// // int rate=config.readNumEntry("SampleRate", 11025);
133// // if(rate == 11025) 133// // if(rate == 11025)
134// // sampleRate->setCurrentItem(0); 134// // sampleRate->setCurrentItem(0);
135// // else if(rate == 22050) 135// // else if(rate == 22050)
136// // sampleRate->setCurrentItem(1); 136// // sampleRate->setCurrentItem(1);
137// // else if(rate == 32000) 137// // else if(rate == 32000)
138// // sampleRate->setCurrentItem(2); 138// // sampleRate->setCurrentItem(2);
139// // else if(rate==44100) 139// // else if(rate==44100)
140// // sampleRate->setCurrentItem(3); 140// // sampleRate->setCurrentItem(3);
141// // stereoCheckBox->setChecked(config.readNumEntry("Stereo", 0)); 141// // stereoCheckBox->setChecked(config.readNumEntry("Stereo", 0));
142// // sixteenBitCheckBox->setChecked(config.readNumEntry("SixteenBit", 0)); 142// // sixteenBitCheckBox->setChecked(config.readNumEntry("SixteenBit", 0));
143// qDebug("QDialog::reject();"); 143// qDebug("QDialog::reject();");
144// ::exit(-1); 144// ::exit(-1);
145// } 145// }
146 146
147// void SoundSettings::accept() 147// void SoundSettings::accept()
148// { 148// {
149// qDebug("accept"); 149// qDebug("accept");
150// Config config( "qpe" ); 150// Config config( "qpe" );
151// config.setGroup( "Volume" ); 151// config.setGroup( "Volume" );
152// config.writeEntry("VolumePercent",100-volume->value()); 152// config.writeEntry("VolumePercent",100-volume->value());
153// config.writeEntry("Mic",100-mic->value()); 153// config.writeEntry("Mic",100-mic->value());
154// // config.writeEntry("TouchSound",touchsound->isChecked()); 154// // config.writeEntry("TouchSound",touchsound->isChecked());
155// // config.writeEntry("KeySound",keysound->isChecked()); 155// // config.writeEntry("KeySound",keysound->isChecked());
156 156
157// Config cfg("Vmemo"); 157// Config cfg("Vmemo");
158// cfg.writeEntry("Alert",AlertCheckBox->isChecked()); 158// cfg.writeEntry("Alert",AlertCheckBox->isChecked());
159// setVolume(volume->value()); 159// setVolume(volume->value());
160// setMic(mic->value()); 160// setMic(mic->value());
161 161
162// cfg.setGroup("Record"); 162// cfg.setGroup("Record");
163// cfg.writeEntry("SampleRate",sampleRate->currentText()); 163// cfg.writeEntry("SampleRate",sampleRate->currentText());
164// cfg.writeEntry("Stereo",stereoCheckBox->isChecked()); 164// cfg.writeEntry("Stereo",stereoCheckBox->isChecked());
165// cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked()); 165// cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked());
166// // Config cfg( "VMemo" ); 166// // Config cfg( "VMemo" );
167// // cfg.setGroup( "Defaults" ); 167// // cfg.setGroup( "Defaults" );
168// // cfg.writeEntry( "hideIcon", HideIcon_CheckBox->isChecked()); 168// // cfg.writeEntry( "hideIcon", HideIcon_CheckBox->isChecked());
169// qDebug("QDialog::accept();"); 169// qDebug("QDialog::accept();");
170// ::exit(0); 170// ::exit(0);
171// } 171// }
172 172
173void SoundSettings::setVolume(int v) 173void SoundSettings::setVolume(int v)
174{ 174{
175 Config config( "qpe" ); 175 Config config( "qpe" );
176 config.setGroup( "Volume" ); 176 config.setGroup( "Volume" );
177 config.writeEntry("VolumePercent",100-v); 177 config.writeEntry("VolumePercent",100-v);
178#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 178#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
179 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; 179 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE;
180#endif 180#endif
181} 181}
182 182
183void SoundSettings::setMic(int m) 183void SoundSettings::setMic(int m)
184{ 184{
185 Config config( "qpe" ); 185 Config config( "qpe" );
186 config.setGroup( "Volume" ); 186 config.setGroup( "Volume" );
187 config.writeEntry("Mic",100-m); 187 config.writeEntry("Mic",100-m);
188#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 188#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
189 QCopEnvelope( "QPE/System", "micChange(bool)" ) << FALSE; 189 QCopEnvelope( "QPE/System", "micChange(bool)" ) << FALSE;
190#endif 190#endif
191} 191}
192 192
193void SoundSettings::volumeChanged( bool ) 193void SoundSettings::volumeChanged( bool )
194{ 194{
195 Config config( "qpe" ); 195 Config config( "qpe" );
196 config.setGroup( "Volume" ); 196 config.setGroup( "Volume" );
197 volume->setValue(100-config.readNumEntry("VolumePercent")); 197 volume->setValue(100-config.readNumEntry("VolumePercent"));
198} 198}
199 199
200void SoundSettings::micChanged( bool ) 200void SoundSettings::micChanged( bool )
201{ 201{
202 Config config( "qpe" ); 202 Config config( "qpe" );
203 config.setGroup( "Volume" ); 203 config.setGroup( "Volume" );
204 mic->setValue(100-config.readNumEntry("Mic")); 204 mic->setValue(100-config.readNumEntry("Mic"));
205} 205}
206 206
207void SoundSettings::updateStorageCombo() { 207void SoundSettings::updateStorageCombo() {
208 208
209 Config config( "Vmemo" ); 209 Config config( "Vmemo" );
210 config.setGroup( "System" ); 210 config.setGroup( "System" );
211 QString loc = config.readEntry("RecLocation","/"); 211 QString loc = config.readEntry("RecLocation","/");
212int i=0; 212int i=0;
213int set=0; 213int set=0;
214 StorageInfo storageInfo; 214 StorageInfo storageInfo;
215 QString sName, sPath; 215 QString sName, sPath;
216 QStringList list; 216 QStringList list;
217 list << "Documents : "+QPEApplication::documentDir();
218 list << "tmp : /tmp";
219
217 const QList<FileSystem> &fs = storageInfo.fileSystems(); 220 const QList<FileSystem> &fs = storageInfo.fileSystems();
218 QListIterator<FileSystem> it ( fs ); 221 QListIterator<FileSystem> it ( fs );
219 for( ; it.current(); ++it ){ 222 for( ; it.current(); ++it ){
220 const QString name = (*it)->name(); 223 const QString name = (*it)->name();
221 const QString path = (*it)->path(); 224 const QString path = (*it)->path();
222 qDebug("storage name "+name +" storage path is "+path); 225 qDebug("storage name "+name +" storage path is "+path);
223 list << name + ": " +path; 226 list << name + ": " +path;
224 if( loc.find( path,0,TRUE) != -1) 227 if( loc.find( path,0,TRUE) != -1)
225 set = i; 228 set = i;
226// if(dit.current()->file().find(path) != -1 ) storage=name; 229// if(dit.current()->file().find(path) != -1 ) storage=name;
227 i++; 230 i++;
228 } 231 }
232
229 LocationComboBox->insertStringList(list); 233 LocationComboBox->insertStringList(list);
230 qDebug("set item %d", set); 234 qDebug("set item %d", set);
231 LocationComboBox->setCurrentItem(set); 235 LocationComboBox->setCurrentItem(set);
232} 236}
233 237
234void SoundSettings::setLocation(const QString & string) { 238void SoundSettings::setLocation(const QString & string) {
235 Config config( "Vmemo" ); 239 Config config( "Vmemo" );
236 config.setGroup( "System" ); 240 config.setGroup( "System" );
237 config.writeEntry("RecLocation",string); 241 config.writeEntry("RecLocation",string);
238 qDebug("set location "+string); 242 qDebug("set location "+string);
239 config.write(); 243 config.write();
240} 244}
241 245
242void SoundSettings::cleanUp() { 246void SoundSettings::cleanUp() {
243 qDebug("cleanup"); 247 qDebug("cleanup");
244 Config config( "qpe" ); 248 Config config( "qpe" );
245 config.setGroup( "Volume" ); 249 config.setGroup( "Volume" );
246 config.writeEntry("VolumePercent",100-volume->value()); 250 config.writeEntry("VolumePercent",100-volume->value());
247 config.writeEntry("Mic",100-mic->value()); 251 config.writeEntry("Mic",100-mic->value());
248// config.writeEntry("TouchSound",touchsound->isChecked()); 252// config.writeEntry("TouchSound",touchsound->isChecked());
249// config.writeEntry("KeySound",keysound->isChecked()); 253// config.writeEntry("KeySound",keysound->isChecked());
250 254
251 Config cfg("Vmemo"); 255 Config cfg("Vmemo");
252 cfg.writeEntry("Alert",AlertCheckBox->isChecked()); 256 cfg.writeEntry("Alert",AlertCheckBox->isChecked());
253 setVolume(volume->value()); 257 setVolume(volume->value());
254 setMic(mic->value()); 258 setMic(mic->value());
255 259
256 cfg.setGroup("Record"); 260 cfg.setGroup("Record");
257 cfg.writeEntry("SampleRate",sampleRate->currentText()); 261 cfg.writeEntry("SampleRate",sampleRate->currentText());
258 cfg.writeEntry("Stereo",stereoCheckBox->isChecked()); 262 cfg.writeEntry("Stereo",stereoCheckBox->isChecked());
259 cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked()); 263 cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked());
260 264
261 if(keyReset) QCopEnvelope ("QPE/System", "restart()"); 265 if(keyReset) QCopEnvelope ("QPE/System", "restart()");
262 266
263} 267}
264 268
265void SoundSettings::setKeyButton(const QString &name) { 269void SoundSettings::setKeyButton(const QString &name) {
266 Config cfg("Vmemo"); 270 Config cfg("Vmemo");
267 cfg.setGroup("Defaults"); 271 cfg.setGroup("Defaults");
268 cfg.writeEntry( "toggleKey", keyComboBox->currentItem() ); 272 cfg.writeEntry( "toggleKey", keyComboBox->currentItem() );
269 keyReset = TRUE; 273 keyReset = TRUE;
270 if(keyComboBox->currentItem() == 1) 274 if(keyComboBox->currentItem() == 1)
271 cfg.writeEntry( "hideIcon", 0 ); 275 cfg.writeEntry( "hideIcon", 0 );
272 else 276 else
273 cfg.writeEntry( "hideIcon", 1); 277 cfg.writeEntry( "hideIcon", 1);
274 278
275 279
276 cfg.write(); 280 cfg.write();
277} 281}
278 282
279void SoundSettings::updateLocationCombo() { 283void SoundSettings::updateLocationCombo() {
280 284
281} 285}
282 286
283void SoundSettings::setSizeLimitButton(const QString &index) { 287void SoundSettings::setSizeLimitButton(const QString &index) {
284 288
285 Config cfg("Vmemo"); 289 Config cfg("Vmemo");
286 cfg.setGroup("Record"); 290 cfg.setGroup("Record");
287 cfg.writeEntry("SizeLimit", index); 291 cfg.writeEntry("SizeLimit", index);
288 cfg.write(); 292 cfg.write();
289} 293}