author | llornkcor <llornkcor> | 2002-09-20 16:15:20 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-09-20 16:15:20 (UTC) |
commit | 40df2487c53a5ab484d33d619f5b6ed449c0b485 (patch) (side-by-side diff) | |
tree | 9439fb7a35a16a798c4a07a612f001ab7f36d948 | |
parent | 5442f262a9e59becacdde4822f439b91d43795df (diff) | |
download | opie-40df2487c53a5ab484d33d619f5b6ed449c0b485.zip opie-40df2487c53a5ab484d33d619f5b6ed449c0b485.tar.gz opie-40df2487c53a5ab484d33d619f5b6ed449c0b485.tar.bz2 |
cleanup
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index c5d0a5b..4c07b3a 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp @@ -190,171 +190,145 @@ static char * vmemo_xpm[] = { "=. c #1F1F21", " ", " . + @ # ", " $ % & * = - ", " ; > , ' ) ! ~ ", " { ] ^ / ( _ : ", " < [ } | 1 2 3 ", " 4 5 6 7 8 9 0 a b c ", " d e f g h i j 3 k l m n ", " o p q r s t u v w n ", " o x y z A B C D E n ", " F G H I J K L M N O ", " P Q R S T U V W X ", " Y Z ` b ...+. ", " @.#.$.%.&. ", " *.B =. ", " n n n n n n n n n "}; VMemo::VMemo( QWidget *parent, const char *_name ) : QWidget( parent, _name ) { setFixedHeight( 18 ); setFixedWidth( 14 ); - 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)); useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); qDebug("toggleKey %d", toggleKey); if(release.find("embedix",0,TRUE) !=-1) systemZaurus=TRUE; else systemZaurus=FALSE; myChannel = new QCopChannel( "QPE/VMemo", this ); connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); if( toggleKey != -1 ) { - // 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(toggleKey == 1) usingIcon=TRUE; else usingIcon=FALSE; if( vmCfg.readNumEntry("hideIcon",0) == 1) hide(); + recording = FALSE; } } 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; - mouseReleaseEvent(NULL); stopRecording(); } else { fromToggle = TRUE; - // mousePressEvent(NULL); startRecording(); } } } void VMemo::paintEvent( QPaintEvent* ) { QPainter p(this); p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); } void VMemo::mousePressEvent( QMouseEvent * me) { - // just to be safe -// if (recording) { -// recording = FALSE; -// return; -// } /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions mousePressEvent and mouseReleaseEvent with a NULL parameter. */ -// if ( me->button() != LeftButton && me != NULL /*&& !systemZaurus*/) { // if (!systemZaurus && me != NULL) // return; // } if(!recording) startRecording(); else stopRecording(); } void VMemo::mouseReleaseEvent( QMouseEvent * ) { -// if(usingIcon && !recording) -// stopRecording(); } bool VMemo::startRecording() { - - if ( recording) - return FALSE; - Config config( "Vmemo" ); config.setGroup( "System" ); useAlerts = config.readBoolEntry("Alert",1); if(useAlerts) { msgLabel = new QLabel( 0, "alertLabel" ); msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); msgLabel->show(); } - // if(useAlerts) - // QMessageBox::message("VMemo","Really Record?");//) ==1) - // return; - // } else { - // if (!systemZaurus ) - // QSound::play(Resource::findSound("vmemob")); - // } qDebug("Start recording engines"); recording = TRUE; if (openDSP() == -1) { - // QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort"); - // delete msgLabel; recording = FALSE; msgLabel=0; delete msgLabel; 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("pathname will be "+fileName); if( fileName.left(1).find('/') == -1) fileName="/"+fileName; @@ -555,84 +529,80 @@ bool VMemo::record() { perror("recording error "); // qDebug(currentFileName); QMessageBox::message(tr("Note"),tr("error recording")); recording=FALSE; break; return FALSE; } if(useADPCM) { adpcm_coder( sbuf, abuf, result/2, &encoder_state); bytesWritten = ::write(wav, abuf, result/4); } else { for (int i = 0; i < result; i++) { //since Z is mono do normally monoBuffer[i] = sound[i]; } length+=write(wav, monoBuffer, result); } length +=bytesWritten; if(length<0) { recording=false; perror("dev/dsp's is a lookin' messy"); - QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); + QMessageBox::message("Vmemo","Error writing to file\n"+ fileName); break; return FALSE; } // printf("%d\r",length); // fflush(stdout); qApp->processEvents(); } // qDebug("file has length of %d lasting %d seconds", // length, (( length / speed) / channels) / 2 ); // } //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<// value = length+36; lseek(wav, 4, SEEK_SET); write(wav, &value, 4); lseek(wav, 40, SEEK_SET); write(wav, &length, 4); track.close(); qDebug("Track closed"); if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) perror("ioctl(\"SNDCTL_DSP_RESET\")"); ::close(dsp); - // 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 return TRUE; } int VMemo::setToggleButton(int tog) { for( int i=0; i < 10;i++) { switch (tog) { case 0: return -1; break; case 1: return 0; break; case 2: return Key_Escape; break; case 3: return Key_Space; break; |