00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "soundsettings.h"
00023
00024
00025 #include <opie2/odebug.h>
00026 #include <qpe/qpeapplication.h>
00027 #include <qpe/config.h>
00028 #include <qpe/qcopenvelope_qws.h>
00029 #include <qpe/storage.h>
00030 using namespace Opie::Core;
00031
00032
00033 #include <qcheckbox.h>
00034 #include <qcombobox.h>
00035 #include <qlabel.h>
00036
00037
00038 #include <sys/utsname.h>
00039 #include <sys/time.h>
00040 #include <sys/types.h>
00041 #include <unistd.h>
00042 #include <sys/stat.h>
00043
00044
00045 SoundSettings::SoundSettings( QWidget* parent, const char* objname, WFlags fl )
00046 : SoundSettingsBase( parent, objname, true, fl )
00047 {
00048 keyReset=false;
00049 noWarning=false;
00050 Config config( "qpe");
00051 config.setGroup( "Volume" );
00052 Config cfg("Vmemo");
00053
00054
00055
00056
00057 AlertCheckBox->setChecked( cfg.readBoolEntry("Alert", 1));
00058
00059 cfg.setGroup("Record");
00060 int rate=config.readNumEntry("SampleRate", 22050);
00061 if(rate == 8000)
00062 sampleRate->setCurrentItem(0);
00063 else if(rate == 11025)
00064 sampleRate->setCurrentItem(1);
00065 else if(rate == 22050)
00066 sampleRate->setCurrentItem(2);
00067 else if(rate == 33075)
00068 sampleRate->setCurrentItem(3);
00069 else if(rate==44100)
00070 sampleRate->setCurrentItem(4);
00071
00072 stereoCheckBox->setChecked(cfg.readNumEntry("Stereo", 0));
00073
00074
00075 #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX)
00076
00077
00078 bool systemZaurus=false;
00079 struct utsname name;
00080 if (uname(&name) != -1) {
00081 QString release=name.release;
00082 if( release.find("embedix",0,true) != -1) {
00083 odebug << "IS System Zaurus" << oendl;
00084 systemZaurus=true;
00085 }
00086 }
00087 if(!systemZaurus) {
00088 stereoCheckBox->setChecked(true);
00089 }
00090 stereoCheckBox->setEnabled(false);
00091 sixteenBitCheckBox->setEnabled(false);
00092 #else
00093 #endif
00094 int sRate=cfg.readNumEntry("SizeLimit", 30);
00095 odebug << "" << sRate << "" << oendl;
00096
00097 if(sRate == 30)
00098 timeLimitComboBox->setCurrentItem(0);
00099 else if(sRate == 20)
00100 timeLimitComboBox->setCurrentItem(1);
00101 else if(sRate == 15)
00102 timeLimitComboBox->setCurrentItem(2);
00103 else if(sRate == 10)
00104 timeLimitComboBox->setCurrentItem(3);
00105 else if(sRate == 5)
00106 timeLimitComboBox->setCurrentItem(4);
00107 else
00108 timeLimitComboBox->setCurrentItem(5);
00109
00110 sixteenBitCheckBox->setChecked(cfg.readNumEntry("SixteenBit", 1));
00111
00112 cfg.setGroup("Defaults");
00113 recordKey = cfg.readNumEntry("toggleKey");
00114 keyComboBox->setCurrentItem( recordKey);
00115
00116 updateStorageCombo();
00117
00118 Config vmCfg("Vmemo");
00119 vmCfg.setGroup("Defaults");
00120 adpcmCheckBox->setChecked( vmCfg.readBoolEntry("use_ADPCM", 0));
00121
00122 connect(LocationComboBox,SIGNAL(activated(const QString&)),this,SLOT(setLocation(const QString&)));
00123 connect(keyComboBox,SIGNAL(activated(int)),this,SLOT(setKeyButton(int)));
00124 connect(timeLimitComboBox,SIGNAL(activated(const QString&)),this,SLOT(setSizeLimitButton(const QString&)));
00125 connect(restartCheckBox,SIGNAL( toggled(bool)),this,SLOT(restartOpie(bool)));
00126 connect(adpcmCheckBox,SIGNAL( toggled(bool)),this,SLOT(slotAdpcm(bool)));
00127
00128
00129 }
00130
00131 void SoundSettings::updateStorageCombo() {
00132
00133 Config config( "Vmemo" );
00134 config.setGroup( "System" );
00135 QString loc = config.readEntry("RecLocation","/");
00136 int i = 0;
00137 int set = 0;
00138 StorageInfo storageInfo;
00139 QString sName, sPath;
00140 QStringList list;
00141 list << "Documents : "+QPEApplication::documentDir();
00142 list << "tmp : /tmp";
00143
00144 const QList<FileSystem> &fs = storageInfo.fileSystems();
00145 QListIterator<FileSystem> it ( fs );
00146 for( ; it.current(); ++it ){
00147 const QString name = (*it)->name();
00148 const QString path = (*it)->path();
00149 odebug << "storage name "+name +" storage path is "+path << oendl;
00150 list << name + ": " +path;
00151 if( loc.find( path,0,true) != -1)
00152 set = i;
00153
00154 i++;
00155 }
00156
00157 LocationComboBox->insertStringList(list);
00158 odebug << "set item " << set << "" << oendl;
00159 LocationComboBox->setCurrentItem(set);
00160 }
00161
00162 void SoundSettings::setLocation(const QString & string) {
00163 Config config( "Vmemo" );
00164 config.setGroup( "System" );
00165 config.writeEntry("RecLocation",string);
00166 odebug << "set location "+string << oendl;
00167 config.write();
00168 }
00169
00170 void SoundSettings::accept() {
00171 cleanUp();
00172 qApp->quit();
00173 }
00174
00175
00176 void SoundSettings::cleanUp() {
00177
00178 Config cfg("Vmemo");
00179 cfg.writeEntry("Alert",AlertCheckBox->isChecked());
00180
00181 cfg.setGroup("Record");
00182 cfg.writeEntry("SampleRate",sampleRate->currentText());
00183 cfg.writeEntry("Stereo",stereoCheckBox->isChecked());
00184 cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked());
00185 if(keyReset && noWarning) {
00186 QCopEnvelope ("QPE/System", "restart()");
00187 }
00188 cfg.setGroup("Defaults");
00189 cfg.writeEntry( "toggleKey", recordKey);
00190 if( recordKey == 1) {
00191 cfg.writeEntry( "hideIcon", 0 );
00192 }
00193 else {
00194 cfg.writeEntry( "hideIcon", 1);
00195 }
00196 cfg.write();
00197 }
00198
00199 void SoundSettings::setKeyButton( int index) {
00200 recordKey = index;
00201 restartCheckBox->setChecked(true);
00202 keyReset = true;
00203 if( index == 1) {
00204 keyLabel->setText(tr("Shows icon"));
00205 }
00206 else {
00207 keyLabel->setText(tr("Hides icon"));
00208 }
00209 }
00210
00211 void SoundSettings::updateLocationCombo() {
00212
00213 }
00214
00215 void SoundSettings::setSizeLimitButton(const QString &index) {
00216
00217 Config cfg("Vmemo");
00218 cfg.setGroup("Record");
00219 if(index.find("Unlimited",0,true) != -1)
00220 cfg.writeEntry("SizeLimit", -1);
00221 else
00222 cfg.writeEntry("SizeLimit", index);
00223 cfg.write();
00224 }
00225
00226 void SoundSettings::restartOpie(bool b) {
00227 noWarning=b;
00228 }
00229
00230 void SoundSettings::slotAdpcm(bool b) {
00231 Config vmCfg("Vmemo");
00232 vmCfg.setGroup("Defaults");
00233 vmCfg.writeEntry("use_ADPCM", b);
00234 vmCfg.write();
00235 }