-rw-r--r-- | noncore/settings/sound/soundsettings.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/settings/sound/soundsettings.cpp b/noncore/settings/sound/soundsettings.cpp index 8b97e4d..20f0dab 100644 --- a/noncore/settings/sound/soundsettings.cpp +++ b/noncore/settings/sound/soundsettings.cpp | |||
@@ -1,200 +1,201 @@ | |||
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 | // parts copyright 2002 L.J. Potter | 20 | // parts copyright 2002 L.J. Potter |
21 | 21 | ||
22 | #include "soundsettings.h" | 22 | #include "soundsettings.h" |
23 | 23 | ||
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
26 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
27 | #include <qpe/storage.h> | 27 | #include <qpe/storage.h> |
28 | 28 | ||
29 | #include <qmessagebox.h> | ||
29 | #include <qapplication.h> | 30 | #include <qapplication.h> |
30 | #include <qslider.h> | 31 | #include <qslider.h> |
31 | #include <qcheckbox.h> | 32 | #include <qcheckbox.h> |
32 | #include <qlineedit.h> | 33 | #include <qlineedit.h> |
33 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
34 | 35 | ||
35 | #include <sys/utsname.h> | 36 | #include <sys/utsname.h> |
36 | #include <sys/time.h> | 37 | #include <sys/time.h> |
37 | #include <sys/types.h> | 38 | #include <sys/types.h> |
38 | #include <unistd.h> | 39 | #include <unistd.h> |
39 | #include <stdio.h> | 40 | #include <stdio.h> |
40 | #include <sys/stat.h> | 41 | #include <sys/stat.h> |
41 | 42 | ||
42 | SoundSettings::SoundSettings( QWidget* parent, const char* objname, WFlags fl ) | 43 | SoundSettings::SoundSettings( QWidget* parent, const char* objname, WFlags fl ) |
43 | : SoundSettingsBase( parent, objname, TRUE, fl ) | 44 | : SoundSettingsBase( parent, objname, TRUE, fl ) |
44 | { | 45 | { |
45 | keyReset=FALSE; | 46 | keyReset=FALSE; |
46 | 47 | ||
47 | Config config( "qpe"); | 48 | Config config( "qpe"); |
48 | config.setGroup( "Volume" ); | 49 | config.setGroup( "Volume" ); |
49 | Config cfg("Vmemo"); | 50 | Config cfg("Vmemo"); |
50 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 51 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
51 | AlertCheckBox->setChecked(cfg.readBoolEntry("Alert")); | 52 | AlertCheckBox->setChecked(cfg.readBoolEntry("Alert")); |
52 | 53 | ||
53 | cfg.setGroup("Record"); | 54 | cfg.setGroup("Record"); |
54 | int rate=config.readNumEntry("SampleRate", 22050); | 55 | int rate=config.readNumEntry("SampleRate", 22050); |
55 | if(rate == 8000) | 56 | if(rate == 8000) |
56 | sampleRate->setCurrentItem(0); | 57 | sampleRate->setCurrentItem(0); |
57 | else if(rate == 11025) | 58 | else if(rate == 11025) |
58 | sampleRate->setCurrentItem(1); | 59 | sampleRate->setCurrentItem(1); |
59 | else if(rate == 22050) | 60 | else if(rate == 22050) |
60 | sampleRate->setCurrentItem(2); | 61 | sampleRate->setCurrentItem(2); |
61 | else if(rate == 33075) | 62 | else if(rate == 33075) |
62 | sampleRate->setCurrentItem(3); | 63 | sampleRate->setCurrentItem(3); |
63 | else if(rate==44100) | 64 | else if(rate==44100) |
64 | sampleRate->setCurrentItem(4); | 65 | sampleRate->setCurrentItem(4); |
65 | 66 | ||
66 | stereoCheckBox->setChecked(cfg.readNumEntry("Stereo", 0)); //TODO hide if zaurus- mono only | 67 | stereoCheckBox->setChecked(cfg.readNumEntry("Stereo", 0)); //TODO hide if zaurus- mono only |
67 | 68 | ||
68 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) //since ipaq and zaurus have particular | 69 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) //since ipaq and zaurus have particular |
69 | //devices | 70 | //devices |
70 | bool systemZaurus=FALSE; | 71 | bool systemZaurus=FALSE; |
71 | struct utsname name; /* check for embedix kernel running on the zaurus*/ | 72 | struct utsname name; /* check for embedix kernel running on the zaurus*/ |
72 | if (uname(&name) != -1) {// TODO change this here,... | 73 | if (uname(&name) != -1) {// TODO change this here,... |
73 | QString release=name.release; | 74 | QString release=name.release; |
74 | if( release.find("embedix",0,TRUE) != -1) { | 75 | if( release.find("embedix",0,TRUE) != -1) { |
75 | qDebug("IS System Zaurus"); | 76 | qDebug("IS System Zaurus"); |
76 | systemZaurus=TRUE; | 77 | systemZaurus=TRUE; |
77 | } | 78 | } |
78 | } | 79 | } |
79 | if(!systemZaurus) { | 80 | if(!systemZaurus) { |
80 | stereoCheckBox->setChecked(TRUE); | 81 | stereoCheckBox->setChecked(TRUE); |
81 | } | 82 | } |
82 | stereoCheckBox->setEnabled(FALSE); | 83 | stereoCheckBox->setEnabled(FALSE); |
83 | sixteenBitCheckBox->setEnabled(FALSE); | 84 | sixteenBitCheckBox->setEnabled(FALSE); |
84 | #else | 85 | #else |
85 | #endif | 86 | #endif |
86 | int sRate=cfg.readNumEntry("SizeLimit", 30); | 87 | int sRate=cfg.readNumEntry("SizeLimit", 30); |
87 | qDebug("%d",sRate); | 88 | qDebug("%d",sRate); |
88 | 89 | ||
89 | if(sRate ==30) | 90 | if(sRate ==30) |
90 | timeLimitComboBox->setCurrentItem(0); | 91 | timeLimitComboBox->setCurrentItem(0); |
91 | else if(sRate==20) | 92 | else if(sRate==20) |
92 | timeLimitComboBox->setCurrentItem(1); | 93 | timeLimitComboBox->setCurrentItem(1); |
93 | else if(sRate == 15) | 94 | else if(sRate == 15) |
94 | timeLimitComboBox->setCurrentItem(2); | 95 | timeLimitComboBox->setCurrentItem(2); |
95 | else if(sRate == 10) | 96 | else if(sRate == 10) |
96 | timeLimitComboBox->setCurrentItem(3); | 97 | timeLimitComboBox->setCurrentItem(3); |
97 | else if(sRate == 5) | 98 | else if(sRate == 5) |
98 | timeLimitComboBox->setCurrentItem(4); | 99 | timeLimitComboBox->setCurrentItem(4); |
99 | else | 100 | else |
100 | timeLimitComboBox->setCurrentItem(5); | 101 | timeLimitComboBox->setCurrentItem(5); |
101 | 102 | ||
102 | sixteenBitCheckBox->setChecked(cfg.readNumEntry("SixteenBit", 1)); | 103 | sixteenBitCheckBox->setChecked(cfg.readNumEntry("SixteenBit", 1)); |
103 | 104 | ||
104 | cfg.setGroup("Defaults"); | 105 | cfg.setGroup("Defaults"); |
105 | keyComboBox->setCurrentItem(cfg.readNumEntry("toggleKey") ); | 106 | keyComboBox->setCurrentItem(cfg.readNumEntry("toggleKey") ); |
106 | 107 | ||
107 | updateStorageCombo(); | 108 | updateStorageCombo(); |
108 | connect( LocationComboBox,SIGNAL(activated(const QString &)),this,SLOT( setLocation(const QString &))); | 109 | connect( LocationComboBox,SIGNAL(activated(const QString &)),this,SLOT( setLocation(const QString &))); |
109 | connect( keyComboBox,SIGNAL(activated(const QString &)),this,SLOT( setKeyButton(const QString &))); | 110 | connect( keyComboBox,SIGNAL(activated(const QString &)),this,SLOT( setKeyButton(const QString &))); |
110 | connect( timeLimitComboBox,SIGNAL(activated( const QString &)),this,SLOT( setSizeLimitButton(const QString &))); | 111 | connect( timeLimitComboBox,SIGNAL(activated( const QString &)),this,SLOT( setSizeLimitButton(const QString &))); |
111 | // connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 112 | // connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
112 | } | 113 | } |
113 | 114 | ||
114 | void SoundSettings::updateStorageCombo() { | 115 | void SoundSettings::updateStorageCombo() { |
115 | 116 | ||
116 | Config config( "Vmemo" ); | 117 | Config config( "Vmemo" ); |
117 | config.setGroup( "System" ); | 118 | config.setGroup( "System" ); |
118 | QString loc = config.readEntry("RecLocation","/"); | 119 | QString loc = config.readEntry("RecLocation","/"); |
119 | int i=0; | 120 | int i=0; |
120 | int set=0; | 121 | int set=0; |
121 | StorageInfo storageInfo; | 122 | StorageInfo storageInfo; |
122 | QString sName, sPath; | 123 | QString sName, sPath; |
123 | QStringList list; | 124 | QStringList list; |
124 | list << "Documents : "+QPEApplication::documentDir(); | 125 | list << "Documents : "+QPEApplication::documentDir(); |
125 | list << "tmp : /tmp"; | 126 | list << "tmp : /tmp"; |
126 | 127 | ||
127 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 128 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
128 | QListIterator<FileSystem> it ( fs ); | 129 | QListIterator<FileSystem> it ( fs ); |
129 | for( ; it.current(); ++it ){ | 130 | for( ; it.current(); ++it ){ |
130 | const QString name = (*it)->name(); | 131 | const QString name = (*it)->name(); |
131 | const QString path = (*it)->path(); | 132 | const QString path = (*it)->path(); |
132 | qDebug("storage name "+name +" storage path is "+path); | 133 | qDebug("storage name "+name +" storage path is "+path); |
133 | list << name + ": " +path; | 134 | list << name + ": " +path; |
134 | if( loc.find( path,0,TRUE) != -1) | 135 | if( loc.find( path,0,TRUE) != -1) |
135 | set = i; | 136 | set = i; |
136 | // if(dit.current()->file().find(path) != -1 ) storage=name; | 137 | // if(dit.current()->file().find(path) != -1 ) storage=name; |
137 | i++; | 138 | i++; |
138 | } | 139 | } |
139 | 140 | ||
140 | LocationComboBox->insertStringList(list); | 141 | LocationComboBox->insertStringList(list); |
141 | qDebug("set item %d", set); | 142 | qDebug("set item %d", set); |
142 | LocationComboBox->setCurrentItem(set); | 143 | LocationComboBox->setCurrentItem(set); |
143 | } | 144 | } |
144 | 145 | ||
145 | void SoundSettings::setLocation(const QString & string) { | 146 | void SoundSettings::setLocation(const QString & string) { |
146 | Config config( "Vmemo" ); | 147 | Config config( "Vmemo" ); |
147 | config.setGroup( "System" ); | 148 | config.setGroup( "System" ); |
148 | config.writeEntry("RecLocation",string); | 149 | config.writeEntry("RecLocation",string); |
149 | qDebug("set location "+string); | 150 | qDebug("set location "+string); |
150 | config.write(); | 151 | config.write(); |
151 | } | 152 | } |
152 | 153 | ||
153 | void SoundSettings::cleanUp() { | 154 | void SoundSettings::cleanUp() { |
154 | Config cfg("Vmemo"); | 155 | Config cfg("Vmemo"); |
155 | cfg.writeEntry("Alert",AlertCheckBox->isChecked()); | 156 | cfg.writeEntry("Alert",AlertCheckBox->isChecked()); |
156 | 157 | ||
157 | cfg.setGroup("Record"); | 158 | cfg.setGroup("Record"); |
158 | cfg.writeEntry("SampleRate",sampleRate->currentText()); | 159 | cfg.writeEntry("SampleRate",sampleRate->currentText()); |
159 | cfg.writeEntry("Stereo",stereoCheckBox->isChecked()); | 160 | cfg.writeEntry("Stereo",stereoCheckBox->isChecked()); |
160 | cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked()); | 161 | cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked()); |
161 | 162 | ||
162 | if(keyReset) { | 163 | if(keyReset) { |
163 | switch ( QMessageBox::warning(this,tr("Restart"), | 164 | switch ( QMessageBox::warning(this,tr("Restart"), |
164 | tr("To implement a new key switch\nOpie will have to be restarted./n<B>Restart</B> Opie now?"), | 165 | tr("To implement a new key switch\nOpie will have to be restarted./n<B>Restart</B> Opie now?"), |
165 | tr("Yes"),tr("No"),0,1,1) ) { | 166 | tr("Yes"),tr("No"),0,1,1) ) { |
166 | case 0: | 167 | case 0: |
167 | QCopEnvelope ("QPE/System", "restart()"); | 168 | QCopEnvelope ("QPE/System", "restart()"); |
168 | break; | 169 | break; |
169 | }; | 170 | }; |
170 | } | 171 | } |
171 | } | 172 | } |
172 | 173 | ||
173 | void SoundSettings::setKeyButton(const QString &name) { | 174 | void SoundSettings::setKeyButton(const QString &name) { |
174 | Config cfg("Vmemo"); | 175 | Config cfg("Vmemo"); |
175 | cfg.setGroup("Defaults"); | 176 | cfg.setGroup("Defaults"); |
176 | cfg.writeEntry( "toggleKey", keyComboBox->currentItem() ); | 177 | cfg.writeEntry( "toggleKey", keyComboBox->currentItem() ); |
177 | keyReset = TRUE; | 178 | keyReset = TRUE; |
178 | if(keyComboBox->currentItem() == 1) | 179 | if(keyComboBox->currentItem() == 1) |
179 | cfg.writeEntry( "hideIcon", 0 ); | 180 | cfg.writeEntry( "hideIcon", 0 ); |
180 | else | 181 | else |
181 | cfg.writeEntry( "hideIcon", 1); | 182 | cfg.writeEntry( "hideIcon", 1); |
182 | 183 | ||
183 | 184 | ||
184 | cfg.write(); | 185 | cfg.write(); |
185 | } | 186 | } |
186 | 187 | ||
187 | void SoundSettings::updateLocationCombo() { | 188 | void SoundSettings::updateLocationCombo() { |
188 | 189 | ||
189 | } | 190 | } |
190 | 191 | ||
191 | void SoundSettings::setSizeLimitButton(const QString &index) { | 192 | void SoundSettings::setSizeLimitButton(const QString &index) { |
192 | 193 | ||
193 | Config cfg("Vmemo"); | 194 | Config cfg("Vmemo"); |
194 | cfg.setGroup("Record"); | 195 | cfg.setGroup("Record"); |
195 | if(index.find("Unlimited",0,TRUE) != -1) | 196 | if(index.find("Unlimited",0,TRUE) != -1) |
196 | cfg.writeEntry("SizeLimit", -1); | 197 | cfg.writeEntry("SizeLimit", -1); |
197 | else | 198 | else |
198 | cfg.writeEntry("SizeLimit", index); | 199 | cfg.writeEntry("SizeLimit", index); |
199 | cfg.write(); | 200 | cfg.write(); |
200 | } | 201 | } |