-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index 84d53e0..2d694d2 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp @@ -204,16 +204,17 @@ VMemo::VMemo( QWidget *parent, const char *_name ) recording = FALSE; t_timer = new QTimer( this ); connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); struct utsname name; /* check for embedix kernel running on the zaurus*/ if (uname(&name) != -1) { QString release=name.release; + Config vmCfg("Vmemo"); vmCfg.setGroup("Defaults"); int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); qDebug("toggleKey %d", toggleKey); if(release.find("embedix",0,TRUE) !=-1) systemZaurus=TRUE; @@ -228,27 +229,29 @@ VMemo::VMemo( QWidget *parent, const char *_name ) // QPEApplication::grabKeyboard(); QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); // e << 4096; // Key_Escape // e << Key_F5; //4148 e << toggleKey; e << QString("QPE/VMemo"); e << QString("toggleRecord()"); } - if( vmCfg.readNumEntry("hideIcon",0) == 1 || toggleKey > 0) + + if( vmCfg.readNumEntry("hideIcon",0) == 1) hide(); } } VMemo::~VMemo() { } void VMemo::receive( const QCString &msg, const QByteArray &data ) { + qDebug("receive"); QDataStream stream( data, IO_ReadOnly ); if (msg == "toggleRecord()") { if (recording) { fromToggle = TRUE; stopRecording(); } else { fromToggle = TRUE; startRecording(); @@ -270,17 +273,17 @@ void VMemo::mousePressEvent( QMouseEvent * ) void VMemo::mouseReleaseEvent( QMouseEvent * ) { stopRecording(); } bool VMemo::startRecording() { if ( recording) - return FALSE;; + return FALSE; Config config( "Vmemo" ); config.setGroup( "System" ); useAlerts = config.readBoolEntry("Alert"); if(useAlerts) { msgLabel = new QLabel( 0, "alertLabel" ); @@ -313,33 +316,34 @@ bool VMemo::startRecording() { 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); + qDebug("pathname will be "+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"); + // 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); @@ -355,20 +359,26 @@ bool VMemo::startRecording() { record(); // delete msgLabel; return TRUE; } void VMemo::stopRecording() { +show(); + qDebug("Stopped recording"); recording = FALSE; if(useAlerts) if( msgLabel) delete msgLabel; t_timer->stop(); + Config cfg("Vmemo"); + cfg.setGroup("Defaults"); + if( cfg.readNumEntry("hideIcon",0) == 1 ) + hide(); } int VMemo::openDSP() { Config cfg("Vmemo"); cfg.setGroup("Record"); speed = cfg.readNumEntry("SampleRate", 22050); @@ -379,20 +389,20 @@ int VMemo::openDSP() } else { format = AFMT_U8; resolution = 8; } qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); if(systemZaurus) { - dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 + dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 channels=1; //zaurus has one input channel } else { - dsp = open("/dev/dsp", O_RDWR); + dsp = open("/dev/dsp", O_RDONLY); } if(dsp == -1) { perror("open(\"/dev/dsp\")"); errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); return -1; } @@ -560,26 +570,27 @@ void VMemo::record(void) lseek(wav, 4, SEEK_SET); write(wav, &value, 4); lseek(wav, 40, SEEK_SET); write(wav, &length, 4); track.close(); - qDebug("Tracvk closed"); + qDebug("Track closed"); if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) perror("ioctl(\"SNDCTL_DSP_RESET\")"); ::close(dsp); fileName = fileName.left(fileName.length()-4); // if(useAlerts) // QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); qDebug("done recording "+fileName); + QSound::play(Resource::findSound("vmemoe")); Config cfg("qpe"); cfg.setGroup("Volume"); QString foo = cfg.readEntry("Mute","TRUE"); if(foo.find("TRUE",0,TRUE) != -1) QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute |