summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sound/soundsettings.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/noncore/settings/sound/soundsettings.cpp b/noncore/settings/sound/soundsettings.cpp
index 3ceaf0c..759a469 100644
--- a/noncore/settings/sound/soundsettings.cpp
+++ b/noncore/settings/sound/soundsettings.cpp
@@ -1,271 +1,272 @@
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 struct utsname name; /* check for embedix kernel running on the zaurus*/ 70 struct utsname name; /* check for embedix kernel running on the zaurus*/
71 if (uname(&name) != -1) { 71 if (uname(&name) != -1) {
72 QString release=name.release; 72 QString release=name.release;
73 73
74 if( release.find("embedix",0,TRUE) !=-1) 74 if( release.find("embedix",0,TRUE) !=-1)
75 stereoCheckBox->hide(); 75 stereoCheckBox->hide();
76 } 76 }
77// else 77// else
78// stereoCheckBox->hide(); 78// stereoCheckBox->hide();
79 int sRate=config.readNumEntry("SizeLimit", 30); 79 int sRate=cfg.readNumEntry("SizeLimit", 30);
80 qDebug("%d",sRate);
81
80 if(sRate ==30) 82 if(sRate ==30)
81 timeLimitComboBox->setCurrentItem(0); 83 timeLimitComboBox->setCurrentItem(0);
82 else if(sRate==20) 84 else if(sRate==20)
83 timeLimitComboBox->setCurrentItem(1); 85 timeLimitComboBox->setCurrentItem(1);
84 else if(sRate == 15) 86 else if(sRate == 15)
85 timeLimitComboBox->setCurrentItem(2); 87 timeLimitComboBox->setCurrentItem(2);
86 else if(sRate == 10) 88 else if(sRate == 10)
87
88 timeLimitComboBox->setCurrentItem(3); 89 timeLimitComboBox->setCurrentItem(3);
89 else 90 else
90 timeLimitComboBox->setCurrentItem(4); 91 timeLimitComboBox->setCurrentItem(4);
91 92
92 93
93 sixteenBitCheckBox->setChecked(cfg.readNumEntry("SixteenBit", 1)); 94 sixteenBitCheckBox->setChecked(cfg.readNumEntry("SixteenBit", 1));
94 95
95 cfg.setGroup("Defaults"); 96 cfg.setGroup("Defaults");
96 keyComboBox->setCurrentItem(cfg.readNumEntry("toggleKey") ); 97 keyComboBox->setCurrentItem(cfg.readNumEntry("toggleKey") );
97 98
98 updateStorageCombo(); 99 updateStorageCombo();
99 100
100 connect(volume, SIGNAL(valueChanged(int)), this, SLOT(setVolume(int))); 101 connect(volume, SIGNAL(valueChanged(int)), this, SLOT(setVolume(int)));
101 connect(mic, SIGNAL(valueChanged(int)), this, SLOT(setMic(int))); 102 connect(mic, SIGNAL(valueChanged(int)), this, SLOT(setMic(int)));
102 connect(qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); 103 connect(qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) );
103 connect(qApp, SIGNAL( micChanged(bool) ), this, SLOT ( micChanged(bool) ) ); 104 connect(qApp, SIGNAL( micChanged(bool) ), this, SLOT ( micChanged(bool) ) );
104 connect( LocationComboBox,SIGNAL(activated(const QString &)),this,SLOT( setLocation(const QString &))); 105 connect( LocationComboBox,SIGNAL(activated(const QString &)),this,SLOT( setLocation(const QString &)));
105 connect( keyComboBox,SIGNAL(activated(const QString &)),this,SLOT(setKeyButton(const QString &))); 106 connect( keyComboBox,SIGNAL(activated(const QString &)),this,SLOT(setKeyButton(const QString &)));
106 connect( timeLimitComboBox,SIGNAL(activated( const QString &)),this,SLOT(setSizeLimitButton(const QString &))); 107 connect( timeLimitComboBox,SIGNAL(activated( const QString &)),this,SLOT(setSizeLimitButton(const QString &)));
107// connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 108// connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
108} 109}
109 110
110// void SoundSettings::reject() 111// void SoundSettings::reject()
111// { 112// {
112// qDebug("reject"); 113// qDebug("reject");
113// Config config( "qpe"); 114// Config config( "qpe");
114// config.setGroup( "Volume"); 115// config.setGroup( "Volume");
115 116
116// setVolume(100-config.readNumEntry("VolumePercent")); 117// setVolume(100-config.readNumEntry("VolumePercent"));
117// setMic(100-config.readNumEntry("Mic")); 118// setMic(100-config.readNumEntry("Mic"));
118 119
119// // config.setGroup("Record"); 120// // config.setGroup("Record");
120// // int rate=config.readNumEntry("SampleRate", 11025); 121// // int rate=config.readNumEntry("SampleRate", 11025);
121// // if(rate == 11025) 122// // if(rate == 11025)
122// // sampleRate->setCurrentItem(0); 123// // sampleRate->setCurrentItem(0);
123// // else if(rate == 22050) 124// // else if(rate == 22050)
124// // sampleRate->setCurrentItem(1); 125// // sampleRate->setCurrentItem(1);
125// // else if(rate == 32000) 126// // else if(rate == 32000)
126// // sampleRate->setCurrentItem(2); 127// // sampleRate->setCurrentItem(2);
127// // else if(rate==44100) 128// // else if(rate==44100)
128// // sampleRate->setCurrentItem(3); 129// // sampleRate->setCurrentItem(3);
129// // stereoCheckBox->setChecked(config.readNumEntry("Stereo", 0)); 130// // stereoCheckBox->setChecked(config.readNumEntry("Stereo", 0));
130// // sixteenBitCheckBox->setChecked(config.readNumEntry("SixteenBit", 0)); 131// // sixteenBitCheckBox->setChecked(config.readNumEntry("SixteenBit", 0));
131// qDebug("QDialog::reject();"); 132// qDebug("QDialog::reject();");
132// ::exit(-1); 133// ::exit(-1);
133// } 134// }
134 135
135// void SoundSettings::accept() 136// void SoundSettings::accept()
136// { 137// {
137// qDebug("accept"); 138// qDebug("accept");
138// Config config( "qpe" ); 139// Config config( "qpe" );
139// config.setGroup( "Volume" ); 140// config.setGroup( "Volume" );
140// config.writeEntry("VolumePercent",100-volume->value()); 141// config.writeEntry("VolumePercent",100-volume->value());
141// config.writeEntry("Mic",100-mic->value()); 142// config.writeEntry("Mic",100-mic->value());
142// // config.writeEntry("TouchSound",touchsound->isChecked()); 143// // config.writeEntry("TouchSound",touchsound->isChecked());
143// // config.writeEntry("KeySound",keysound->isChecked()); 144// // config.writeEntry("KeySound",keysound->isChecked());
144 145
145// Config cfg("Vmemo"); 146// Config cfg("Vmemo");
146// cfg.writeEntry("Alert",AlertCheckBox->isChecked()); 147// cfg.writeEntry("Alert",AlertCheckBox->isChecked());
147// setVolume(volume->value()); 148// setVolume(volume->value());
148// setMic(mic->value()); 149// setMic(mic->value());
149 150
150// cfg.setGroup("Record"); 151// cfg.setGroup("Record");
151// cfg.writeEntry("SampleRate",sampleRate->currentText()); 152// cfg.writeEntry("SampleRate",sampleRate->currentText());
152// cfg.writeEntry("Stereo",stereoCheckBox->isChecked()); 153// cfg.writeEntry("Stereo",stereoCheckBox->isChecked());
153// cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked()); 154// cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked());
154// // Config cfg( "VMemo" ); 155// // Config cfg( "VMemo" );
155// // cfg.setGroup( "Defaults" ); 156// // cfg.setGroup( "Defaults" );
156// // cfg.writeEntry( "hideIcon", HideIcon_CheckBox->isChecked()); 157// // cfg.writeEntry( "hideIcon", HideIcon_CheckBox->isChecked());
157// qDebug("QDialog::accept();"); 158// qDebug("QDialog::accept();");
158// ::exit(0); 159// ::exit(0);
159// } 160// }
160 161
161void SoundSettings::setVolume(int v) 162void SoundSettings::setVolume(int v)
162{ 163{
163 Config config( "qpe" ); 164 Config config( "qpe" );
164 config.setGroup( "Volume" ); 165 config.setGroup( "Volume" );
165 config.writeEntry("VolumePercent",100-v); 166 config.writeEntry("VolumePercent",100-v);
166#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 167#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
167 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; 168 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE;
168#endif 169#endif
169} 170}
170 171
171void SoundSettings::setMic(int m) 172void SoundSettings::setMic(int m)
172{ 173{
173 Config config( "qpe" ); 174 Config config( "qpe" );
174 config.setGroup( "Volume" ); 175 config.setGroup( "Volume" );
175 config.writeEntry("Mic",100-m); 176 config.writeEntry("Mic",100-m);
176#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 177#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
177 QCopEnvelope( "QPE/System", "micChange(bool)" ) << FALSE; 178 QCopEnvelope( "QPE/System", "micChange(bool)" ) << FALSE;
178#endif 179#endif
179} 180}
180 181
181void SoundSettings::volumeChanged( bool ) 182void SoundSettings::volumeChanged( bool )
182{ 183{
183 Config config( "qpe" ); 184 Config config( "qpe" );
184 config.setGroup( "Volume" ); 185 config.setGroup( "Volume" );
185 volume->setValue(100-config.readNumEntry("VolumePercent")); 186 volume->setValue(100-config.readNumEntry("VolumePercent"));
186} 187}
187 188
188void SoundSettings::micChanged( bool ) 189void SoundSettings::micChanged( bool )
189{ 190{
190 Config config( "qpe" ); 191 Config config( "qpe" );
191 config.setGroup( "Volume" ); 192 config.setGroup( "Volume" );
192 mic->setValue(100-config.readNumEntry("Mic")); 193 mic->setValue(100-config.readNumEntry("Mic"));
193} 194}
194 195
195void SoundSettings::updateStorageCombo() { 196void SoundSettings::updateStorageCombo() {
196 197
197 Config config( "Vmemo" ); 198 Config config( "Vmemo" );
198 config.setGroup( "System" ); 199 config.setGroup( "System" );
199 QString loc = config.readEntry("RecLocation","/"); 200 QString loc = config.readEntry("RecLocation","/");
200int i=0; 201int i=0;
201int set=0; 202int set=0;
202 StorageInfo storageInfo; 203 StorageInfo storageInfo;
203 QString sName, sPath; 204 QString sName, sPath;
204 QStringList list; 205 QStringList list;
205 const QList<FileSystem> &fs = storageInfo.fileSystems(); 206 const QList<FileSystem> &fs = storageInfo.fileSystems();
206 QListIterator<FileSystem> it ( fs ); 207 QListIterator<FileSystem> it ( fs );
207 for( ; it.current(); ++it ){ 208 for( ; it.current(); ++it ){
208 const QString name = (*it)->name(); 209 const QString name = (*it)->name();
209 const QString path = (*it)->path(); 210 const QString path = (*it)->path();
210 qDebug("storage name "+name +" storage path is "+path); 211 qDebug("storage name "+name +" storage path is "+path);
211 list << name + ": " +path; 212 list << name + ": " +path;
212 if( loc.find( path,0,TRUE) != -1) 213 if( loc.find( path,0,TRUE) != -1)
213 set = i; 214 set = i;
214// if(dit.current()->file().find(path) != -1 ) storage=name; 215// if(dit.current()->file().find(path) != -1 ) storage=name;
215 i++; 216 i++;
216 } 217 }
217 LocationComboBox->insertStringList(list); 218 LocationComboBox->insertStringList(list);
218 qDebug("set item %d", set); 219 qDebug("set item %d", set);
219 LocationComboBox->setCurrentItem(set); 220 LocationComboBox->setCurrentItem(set);
220} 221}
221 222
222void SoundSettings::setLocation(const QString & string) { 223void SoundSettings::setLocation(const QString & string) {
223 Config config( "Vmemo" ); 224 Config config( "Vmemo" );
224 config.setGroup( "System" ); 225 config.setGroup( "System" );
225 config.writeEntry("RecLocation",string); 226 config.writeEntry("RecLocation",string);
226 qDebug("set location "+string); 227 qDebug("set location "+string);
227 config.write(); 228 config.write();
228} 229}
229 230
230void SoundSettings::cleanUp() { 231void SoundSettings::cleanUp() {
231 qDebug("cleanup"); 232 qDebug("cleanup");
232 Config config( "qpe" ); 233 Config config( "qpe" );
233 config.setGroup( "Volume" ); 234 config.setGroup( "Volume" );
234 config.writeEntry("VolumePercent",100-volume->value()); 235 config.writeEntry("VolumePercent",100-volume->value());
235 config.writeEntry("Mic",100-mic->value()); 236 config.writeEntry("Mic",100-mic->value());
236// config.writeEntry("TouchSound",touchsound->isChecked()); 237// config.writeEntry("TouchSound",touchsound->isChecked());
237// config.writeEntry("KeySound",keysound->isChecked()); 238// config.writeEntry("KeySound",keysound->isChecked());
238 239
239 Config cfg("Vmemo"); 240 Config cfg("Vmemo");
240 cfg.writeEntry("Alert",AlertCheckBox->isChecked()); 241 cfg.writeEntry("Alert",AlertCheckBox->isChecked());
241 setVolume(volume->value()); 242 setVolume(volume->value());
242 setMic(mic->value()); 243 setMic(mic->value());
243 244
244 cfg.setGroup("Record"); 245 cfg.setGroup("Record");
245 cfg.writeEntry("SampleRate",sampleRate->currentText()); 246 cfg.writeEntry("SampleRate",sampleRate->currentText());
246 cfg.writeEntry("Stereo",stereoCheckBox->isChecked()); 247 cfg.writeEntry("Stereo",stereoCheckBox->isChecked());
247 cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked()); 248 cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked());
248 249
249 if(keyReset) QCopEnvelope ("QPE/System", "restart()"); 250 if(keyReset) QCopEnvelope ("QPE/System", "restart()");
250 251
251} 252}
252 253
253void SoundSettings::setKeyButton(const QString &name) { 254void SoundSettings::setKeyButton(const QString &name) {
254 Config cfg("Vmemo"); 255 Config cfg("Vmemo");
255 cfg.setGroup("Defaults"); 256 cfg.setGroup("Defaults");
256 cfg.writeEntry( "toggleKey", keyComboBox->currentItem() ); 257 cfg.writeEntry( "toggleKey", keyComboBox->currentItem() );
257 keyReset = TRUE; 258 keyReset = TRUE;
258 cfg.write(); 259 cfg.write();
259} 260}
260 261
261void SoundSettings::updateLocationCombo() { 262void SoundSettings::updateLocationCombo() {
262 263
263} 264}
264 265
265void SoundSettings::setSizeLimitButton(const QString &index) { 266void SoundSettings::setSizeLimitButton(const QString &index) {
266 267
267 Config cfg("Vmemo"); 268 Config cfg("Vmemo");
268 cfg.setGroup("Record"); 269 cfg.setGroup("Record");
269 cfg.writeEntry("SizeLimit", index); 270 cfg.writeEntry("SizeLimit", index);
270 cfg.write(); 271 cfg.write();
271} 272}