summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-05-23 02:58:32 (UTC)
committer llornkcor <llornkcor>2002-05-23 02:58:32 (UTC)
commit999d033f887064f5e1ddfd492f12a7f1ede72887 (patch) (side-by-side diff)
treed8cd02814fa2edda14353fca8a0eaa39651092ea
parent375cce9ad697f99d54f3e1c60c6d197b535ed04e (diff)
downloadopie-999d033f887064f5e1ddfd492f12a7f1ede72887.zip
opie-999d033f887064f5e1ddfd492f12a7f1ede72887.tar.gz
opie-999d033f887064f5e1ddfd492f12a7f1ede72887.tar.bz2
workaround for bug with QPEApplication::documentDir() returning 'root/...' instead of '/root/...'
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 7cc4062..f5d2b20 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -257,98 +257,100 @@ void VMemo::paintEvent( QPaintEvent* )
void VMemo::mousePressEvent( QMouseEvent * )
{
startRecording();
}
void VMemo::mouseReleaseEvent( QMouseEvent * )
{
stopRecording();
}
bool VMemo::startRecording() {
if ( recording)
return FALSE;;
Config config( "Vmemo" );
config.setGroup( "System" );
useAlerts = config.readBoolEntry("Alert");
// if(useAlerts)
// QMessageBox::message("VMemo","Really Record?");//) ==1)
// return;
// } else {
if (!systemZaurus )
QSound::play(Resource::findSound("vmemob"));
// }
qDebug("Start recording");
recording = TRUE;
if (openDSP() == -1) {
QMessageBox::critical(0, "VMemo", "Could not open dsp device.\n"+errorMsg, "Abort");
recording = FALSE;
return FALSE;
}
config.setGroup("Defaults");
QDateTime dt = QDateTime::currentDateTime();
QString fName;
config.setGroup( "System" );
fName = QPEApplication::documentDir() ;
fileName = config.readEntry("RecLocation", fName);
int s;
s=fileName.find(':');
if(s)
fileName=fileName.right(fileName.length()-s-2);
qDebug("filename will be "+fileName);
- if( fileName.right(1).find('/') == -1)
- fileName+="/";
+ if( fileName.left(1).find('/') == -1)
+ fileName="/"+fileName;
+ if( fileName.right(1).find('/') == -1)
+ fileName+="/";
fName = "vm_"+ dt.toString()+ ".wav";
fileName+=fName;
qDebug("filename is "+fileName);
// No spaces in the filename
fileName.replace(QRegExp("'"),"");
fileName.replace(QRegExp(" "),"_");
fileName.replace(QRegExp(":"),".");
fileName.replace(QRegExp(","),"");
if(openWAV(fileName.latin1()) == -1) {
QString err("Could not open the output file\n");
err += fileName;
QMessageBox::critical(0, "VMemo", err, "Abort");
close(dsp);
return FALSE;
}
QArray<int> cats(1);
cats[0] = config.readNumEntry("Category", 0);
QString dlName("vm_");
dlName += dt.toString();
DocLnk l;
l.setFile(fileName);
l.setName(dlName);
l.setType("audio/x-wav");
l.setCategories(cats);
l.writeLink();
record();
return TRUE;
}
void VMemo::stopRecording() {
recording = FALSE;
}
int VMemo::openDSP()
{
Config cfg("Vmemo");
cfg.setGroup("Record");
speed = cfg.readNumEntry("SampleRate", 22050);
channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1)
if (cfg.readNumEntry("SixteenBit", 1)==1) {
format = AFMT_S16_LE;
resolution = 16;