-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index 2c3edf1..b77e3b8 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -249,33 +249,47 @@ VMemo::~VMemo() | |||
249 | 249 | ||
250 | void VMemo::receive( const QCString &msg, const QByteArray &data ) | 250 | void VMemo::receive( const QCString &msg, const QByteArray &data ) |
251 | { | 251 | { |
252 | qDebug("receive"); | 252 | qDebug("receive"); |
253 | QDataStream stream( data, IO_ReadOnly ); | 253 | QDataStream stream( data, IO_ReadOnly ); |
254 | if (msg == "toggleRecord()") { | 254 | if (msg == "toggleRecord()") { |
255 | if (recording) { | 255 | if (recording) { |
256 | fromToggle = TRUE; | 256 | fromToggle = TRUE; |
257 | stopRecording(); | 257 | mouseReleaseEvent(NULL); |
258 | // stopRecording(); | ||
258 | } else { | 259 | } else { |
259 | fromToggle = TRUE; | 260 | fromToggle = TRUE; |
261 | // mousePressEvent(NULL); | ||
260 | startRecording(); | 262 | startRecording(); |
261 | } | 263 | } |
262 | } | 264 | } |
263 | } | 265 | } |
264 | 266 | ||
265 | void VMemo::paintEvent( QPaintEvent* ) | 267 | void VMemo::paintEvent( QPaintEvent* ) |
266 | { | 268 | { |
267 | QPainter p(this); | 269 | QPainter p(this); |
268 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); | 270 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); |
269 | } | 271 | } |
270 | 272 | ||
271 | void VMemo::mousePressEvent( QMouseEvent * ) | 273 | void VMemo::mousePressEvent( QMouseEvent * me) |
272 | { | 274 | { |
273 | if(!recording) | 275 | // just to be safe |
276 | if (recording) { | ||
277 | recording = FALSE; | ||
278 | return; | ||
279 | } | ||
280 | /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions | ||
281 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ | ||
282 | if ( me->button() != LeftButton) | ||
283 | |||
284 | // if (!systemZaurus && me != NULL) | ||
285 | return; | ||
286 | |||
287 | if(!recording) | ||
274 | startRecording(); | 288 | startRecording(); |
275 | else | 289 | else |
276 | stopRecording(); | 290 | stopRecording(); |
277 | } | 291 | } |
278 | 292 | ||
279 | void VMemo::mouseReleaseEvent( QMouseEvent * ) | 293 | void VMemo::mouseReleaseEvent( QMouseEvent * ) |
280 | { | 294 | { |
281 | // if(usingIcon && !recording) | 295 | // if(usingIcon && !recording) |
@@ -342,24 +356,36 @@ bool VMemo::startRecording() { | |||
342 | fileName+=fName; | 356 | fileName+=fName; |
343 | qDebug("filename is "+fileName); | 357 | qDebug("filename is "+fileName); |
344 | // No spaces in the filename | 358 | // No spaces in the filename |
345 | fileName.replace(QRegExp("'"),""); | 359 | fileName.replace(QRegExp("'"),""); |
346 | fileName.replace(QRegExp(" "),"_"); | 360 | fileName.replace(QRegExp(" "),"_"); |
347 | fileName.replace(QRegExp(":"),"."); | 361 | fileName.replace(QRegExp(":"),"."); |
348 | fileName.replace(QRegExp(","),""); | 362 | fileName.replace(QRegExp(","),""); |
349 | 363 | ||
350 | if(openWAV(fileName.latin1()) == -1) { | 364 | // open tmp file here |
351 | // QString err("Could not open the output file\n"); | 365 | char *pointer; |
352 | // err += fileName; | 366 | pointer=tmpnam(NULL); |
353 | // QMessageBox::critical(0, "vmemo", err, "Abort"); | 367 | qDebug("Opening tmp file %s",pointer); |
354 | close(dsp); | 368 | |
369 | if(openWAV(pointer ) == -1) { | ||
370 | |||
371 | // if(openWAV(fileName.latin1()) == -1) { | ||
372 | QString err("Could not open the temp file\n"); | ||
373 | err += fileName; | ||
374 | QMessageBox::critical(0, "vmemo", err, "Abort"); | ||
375 | ::close(dsp); | ||
355 | return FALSE; | 376 | return FALSE; |
356 | } | 377 | } |
357 | 378 | QString cmd; | |
379 | cmd.sprintf("mv %s "+fileName,pointer); | ||
380 | |||
381 | // move tmp file to regular file here | ||
382 | system(cmd.latin1()); | ||
383 | |||
358 | QArray<int> cats(1); | 384 | QArray<int> cats(1); |
359 | cats[0] = config.readNumEntry("Category", 0); | 385 | cats[0] = config.readNumEntry("Category", 0); |
360 | 386 | ||
361 | QString dlName("vm_"); | 387 | QString dlName("vm_"); |
362 | dlName += dt.toString(); | 388 | dlName += dt.toString(); |
363 | DocLnk l; | 389 | DocLnk l; |
364 | l.setFile(fileName); | 390 | l.setFile(fileName); |
365 | l.setName(dlName); | 391 | l.setName(dlName); |
@@ -642,10 +668,10 @@ int VMemo::setToggleButton(int tog) { | |||
642 | }; | 668 | }; |
643 | } | 669 | } |
644 | return -1; | 670 | return -1; |
645 | } | 671 | } |
646 | 672 | ||
647 | void VMemo::timerBreak() { | 673 | void VMemo::timerBreak() { |
648 | //stop | 674 | //stop |
649 | stopRecording(); | 675 | stopRecording(); |
650 | QMessageBox::message("Vmemo","Vmemo recording has \ntimed out"); | 676 | QMessageBox::message("Vmemo","Vmemo recording has ended"); |
651 | } | 677 | } |