author | llornkcor <llornkcor> | 2004-09-27 09:46:44 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-09-27 09:46:44 (UTC) |
commit | 28c514ec19215b6db5e98ba64d5f716c0b5ba391 (patch) (unidiff) | |
tree | c39132999d045d127848d8a5b8513e079d90203f /core/applets | |
parent | 3381ae96e9f386e96feb4121425912f9ddb3a53f (diff) | |
download | opie-28c514ec19215b6db5e98ba64d5f716c0b5ba391.zip opie-28c514ec19215b6db5e98ba64d5f716c0b5ba391.tar.gz opie-28c514ec19215b6db5e98ba64d5f716c0b5ba391.tar.bz2 |
fix vmemo
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index 07ef15c..d5808b7 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -197,82 +197,84 @@ static char * vmemo_xpm[] = { | |||
197 | " n n n n n n n n n "}; | 197 | " n n n n n n n n n "}; |
198 | 198 | ||
199 | 199 | ||
200 | using namespace Opie::Ui; | 200 | using namespace Opie::Ui; |
201 | VMemo::VMemo( QWidget *parent, const char *_name ) | 201 | VMemo::VMemo( QWidget *parent, const char *_name ) |
202 | : QWidget( parent, _name ) { | 202 | : QWidget( parent, _name ) { |
203 | setFixedHeight( 18 ); | 203 | setFixedHeight( 18 ); |
204 | setFixedWidth( 14 ); | 204 | setFixedWidth( 14 ); |
205 | 205 | ||
206 | t_timer = new QTimer( this ); | 206 | t_timer = new QTimer( this ); |
207 | connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); | 207 | connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); |
208 | 208 | ||
209 | Config vmCfg("Vmemo"); | 209 | Config vmCfg("Vmemo"); |
210 | vmCfg.setGroup("Defaults"); | 210 | vmCfg.setGroup("Defaults"); |
211 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); | 211 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); |
212 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); | 212 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); |
213 | 213 | ||
214 | odebug << "toggleKey " << toggleKey << "" << oendl; | 214 | odebug << "toggleKey " << toggleKey << "" << oendl; |
215 | 215 | ||
216 | // if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 216 | // if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
217 | // systemZaurus=TRUE; | 217 | // systemZaurus=TRUE; |
218 | // else | 218 | // else |
219 | systemZaurus = FALSE; | 219 | systemZaurus = FALSE; |
220 | 220 | ||
221 | // myChannel = new QCopChannel( "QPE/VMemo", this ); | ||
221 | myChannel = new QCopChannel( "QPE/VMemo", this ); | 222 | myChannel = new QCopChannel( "QPE/VMemo", this ); |
223 | |||
222 | connect( myChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 224 | connect( myChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
223 | this, SLOT(receive(const QCString&,const QByteArray&)) ); | 225 | this, SLOT(receive(const QCString&,const QByteArray&)) ); |
224 | 226 | ||
227 | |||
225 | if( toggleKey != -1 ) { | 228 | if( toggleKey != -1 ) { |
226 | odebug << "Register key " << toggleKey << "" << oendl; | 229 | odebug << "Register key " << toggleKey << "" << oendl; |
227 | QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)"); | 230 | QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)"); |
228 | // e << 4096; // Key_Escape | 231 | // e << 4096; // Key_Escape |
229 | // e << Key_F5; //4148 | 232 | // e << Key_F5; //4148 |
230 | e << toggleKey; | 233 | e << toggleKey; |
231 | e << QString("QPE/VMemo"); | 234 | e << QCString("QPE/VMemo"); |
232 | e << QString("toggleRecord()"); | 235 | e << QCString("toggleRecord()"); |
233 | } | 236 | } |
234 | if(toggleKey == 1) | 237 | if(toggleKey == 1) |
235 | usingIcon = TRUE; | 238 | usingIcon = TRUE; |
236 | else | 239 | else |
237 | usingIcon = FALSE; | 240 | usingIcon = FALSE; |
238 | // if( vmCfg.readNumEntry("hideIcon",0) == 1) | 241 | // if( vmCfg.readNumEntry("hideIcon",0) == 1) |
239 | if (!usingIcon) | 242 | if (!usingIcon) |
240 | hide(); | 243 | hide(); |
241 | recording = FALSE; | 244 | recording = FALSE; |
242 | // } | 245 | // } |
243 | } | 246 | } |
244 | 247 | ||
245 | VMemo::~VMemo() { | 248 | VMemo::~VMemo() { |
246 | } | 249 | } |
247 | 250 | ||
248 | int VMemo::position() | 251 | int VMemo::position() |
249 | { | 252 | { |
250 | return 6; | 253 | return 6; |
251 | } | 254 | } |
252 | 255 | ||
253 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { | 256 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { |
254 | odebug << "Vmemo receive" << oendl; | ||
255 | QDataStream stream( data, IO_ReadOnly ); | 257 | QDataStream stream( data, IO_ReadOnly ); |
256 | 258 | ||
257 | if (msg == "toggleRecord()") { | 259 | if (msg == "toggleRecord()") { |
258 | if (recording) { | 260 | if (recording) { |
259 | fromToggle = TRUE; | 261 | fromToggle = TRUE; |
260 | stopRecording(); | 262 | stopRecording(); |
261 | } else { | 263 | } else { |
262 | fromToggle = TRUE; | 264 | fromToggle = TRUE; |
263 | startRecording(); | 265 | startRecording(); |
264 | } | 266 | } |
265 | } | 267 | } |
266 | } | 268 | } |
267 | 269 | ||
268 | void VMemo::paintEvent( QPaintEvent* ) { | 270 | void VMemo::paintEvent( QPaintEvent* ) { |
269 | QPainter p(this); | 271 | QPainter p(this); |
270 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); | 272 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); |
271 | } | 273 | } |
272 | 274 | ||
273 | void VMemo::mousePressEvent( QMouseEvent * /*me*/) { | 275 | void VMemo::mousePressEvent( QMouseEvent * /*me*/) { |
274 | /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions | 276 | /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions |
275 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ | 277 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ |
276 | 278 | ||
277 | // if (!systemZaurus && me != NULL) | 279 | // if (!systemZaurus && me != NULL) |
278 | // return; | 280 | // return; |
@@ -499,49 +501,49 @@ bool VMemo::record() { | |||
499 | odebug << msg << oendl; | 501 | odebug << msg << oendl; |
500 | 502 | ||
501 | Config config("Vmemo"); | 503 | Config config("Vmemo"); |
502 | config.setGroup("Record"); | 504 | config.setGroup("Record"); |
503 | int sRate = config.readNumEntry("SizeLimit", 30); | 505 | int sRate = config.readNumEntry("SizeLimit", 30); |
504 | odebug << "VMEMO rate" << sRate << oendl; | 506 | odebug << "VMEMO rate" << sRate << oendl; |
505 | 507 | ||
506 | if(sRate > 0) { | 508 | if(sRate > 0) { |
507 | t_timer->start( sRate * 1000+1000, TRUE); | 509 | t_timer->start( sRate * 1000+1000, TRUE); |
508 | } | 510 | } |
509 | 511 | ||
510 | msg.sprintf("Recording format other"); | 512 | msg.sprintf("Recording format other"); |
511 | odebug << msg << oendl; | 513 | odebug << msg << oendl; |
512 | 514 | ||
513 | config.setGroup("Defaults"); | 515 | config.setGroup("Defaults"); |
514 | useADPCM = config.readBoolEntry("use_ADPCM", 0); | 516 | useADPCM = config.readBoolEntry("use_ADPCM", 0); |
515 | 517 | ||
516 | int bufsize = config.readNumEntry("BufferSize",1024); | 518 | int bufsize = config.readNumEntry("BufferSize",1024); |
517 | unsigned short sound[bufsize]; //, monoBuffer[bufsize]; | 519 | unsigned short sound[bufsize]; //, monoBuffer[bufsize]; |
518 | char abuf[bufsize / 2]; | 520 | char abuf[bufsize / 2]; |
519 | short sbuf[bufsize]; | 521 | short sbuf[bufsize]; |
520 | odebug << "ready to record"<< oendl; | 522 | odebug << "ready to record"<< oendl; |
521 | if(useADPCM) { | 523 | if(useADPCM) { |
522 | odebug << "usr ADPCM" << oendl; | 524 | odebug << "usr ADPCM" << oendl; |
523 | 525 | ||
524 | while(recording) { | 526 | while(recording) { |
525 | result = ::read(dsp, sbuf, bufsize); // adpcm read | 527 | result = ::read(dsp, sbuf, bufsize); // adpcm read |
526 | if( result <= 0) { | 528 | if( result <= 0) { |
527 | perror("recording error "); | 529 | perror("recording error "); |
528 | QMessageBox::message(tr("Note"),tr("error recording")); | 530 | QMessageBox::message(tr("Note"),tr("error recording")); |
529 | recording = FALSE; | 531 | recording = FALSE; |
530 | break; | 532 | break; |
531 | return FALSE; | 533 | return FALSE; |
532 | } | 534 | } |
533 | adpcm_coder( sbuf, abuf, result/2, &encoder_state); | 535 | adpcm_coder( sbuf, abuf, result/2, &encoder_state); |
534 | bytesWritten = ::write(wav, abuf, result/4); // adpcm write | 536 | bytesWritten = ::write(wav, abuf, result/4); // adpcm write |
535 | length += bytesWritten; | 537 | length += bytesWritten; |
536 | 538 | ||
537 | if(length < 0) { | 539 | if(length < 0) { |
538 | recording = false; | 540 | recording = false; |
539 | perror("dev/dsp's is a lookin' messy"); | 541 | perror("dev/dsp's is a lookin' messy"); |
540 | QMessageBox::message("Vmemo","Error writing to file\n"+ fileName); | 542 | QMessageBox::message("Vmemo","Error writing to file\n"+ fileName); |
541 | break; | 543 | break; |
542 | return FALSE; | 544 | return FALSE; |
543 | } | 545 | } |
544 | printf("%d\r", length); | 546 | printf("%d\r", length); |
545 | fflush(stdout); | 547 | fflush(stdout); |
546 | qApp->processEvents(); | 548 | qApp->processEvents(); |
547 | } | 549 | } |
@@ -644,26 +646,26 @@ int VMemo::setToggleButton(int tog) { | |||
644 | case 5: | 646 | case 5: |
645 | return Key_F9; | 647 | return Key_F9; |
646 | break; | 648 | break; |
647 | case 6: | 649 | case 6: |
648 | return Key_F10; | 650 | return Key_F10; |
649 | break; | 651 | break; |
650 | case 7: | 652 | case 7: |
651 | return Key_F11; | 653 | return Key_F11; |
652 | break; | 654 | break; |
653 | case 8: | 655 | case 8: |
654 | return Key_F13; | 656 | return Key_F13; |
655 | break; | 657 | break; |
656 | }; | 658 | }; |
657 | } | 659 | } |
658 | return -1; | 660 | return -1; |
659 | } | 661 | } |
660 | 662 | ||
661 | void VMemo::timerBreak() { | 663 | void VMemo::timerBreak() { |
662 | //stop | 664 | //stop |
663 | stopRecording(); | 665 | stopRecording(); |
664 | QMessageBox::message("Vmemo","Vmemo recording has ended"); | 666 | QMessageBox::message("Vmemo","Vmemo recording has ended"); |
665 | } | 667 | } |
666 | 668 | ||
667 | 669 | ||
668 | EXPORT_OPIE_APPLET_v1( VMemo ) | 670 | //EXPORT_OPIE_APPLET_v1( VMemo ) |
669 | 671 | ||