author | llornkcor <llornkcor> | 2002-07-12 04:53:07 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-07-12 04:53:07 (UTC) |
commit | 7c12000481b535ce54951ef8a53b439814f8fcd6 (patch) (unidiff) | |
tree | eed9230c9d4defd43b0735710fec49788ca17fd5 | |
parent | 5f010888acabe5d00504b05d159b2837ff115f05 (diff) | |
download | opie-7c12000481b535ce54951ef8a53b439814f8fcd6.zip opie-7c12000481b535ce54951ef8a53b439814f8fcd6.tar.gz opie-7c12000481b535ce54951ef8a53b439814f8fcd6.tar.bz2 |
try to fix taskbar icon foofaa
-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 | |||
@@ -233,65 +233,79 @@ VMemo::VMemo( QWidget *parent, const char *_name ) | |||
233 | e << toggleKey; | 233 | e << toggleKey; |
234 | e << QString("QPE/VMemo"); | 234 | e << QString("QPE/VMemo"); |
235 | e << QString("toggleRecord()"); | 235 | e << QString("toggleRecord()"); |
236 | } | 236 | } |
237 | if(toggleKey == 1) | 237 | if(toggleKey == 1) |
238 | usingIcon=TRUE; | 238 | usingIcon=TRUE; |
239 | else | 239 | else |
240 | usingIcon=FALSE; | 240 | usingIcon=FALSE; |
241 | if( vmCfg.readNumEntry("hideIcon",0) == 1) | 241 | if( vmCfg.readNumEntry("hideIcon",0) == 1) |
242 | hide(); | 242 | hide(); |
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
246 | VMemo::~VMemo() | 246 | VMemo::~VMemo() |
247 | { | 247 | { |
248 | } | 248 | } |
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) |
282 | // stopRecording(); | 296 | // stopRecording(); |
283 | } | 297 | } |
284 | 298 | ||
285 | bool VMemo::startRecording() { | 299 | bool VMemo::startRecording() { |
286 | 300 | ||
287 | if ( recording) | 301 | if ( recording) |
288 | return FALSE; | 302 | return FALSE; |
289 | 303 | ||
290 | Config config( "Vmemo" ); | 304 | Config config( "Vmemo" ); |
291 | config.setGroup( "System" ); | 305 | config.setGroup( "System" ); |
292 | 306 | ||
293 | useAlerts = config.readBoolEntry("Alert",1); | 307 | useAlerts = config.readBoolEntry("Alert",1); |
294 | if(useAlerts) { | 308 | if(useAlerts) { |
295 | 309 | ||
296 | msgLabel = new QLabel( 0, "alertLabel" ); | 310 | msgLabel = new QLabel( 0, "alertLabel" ); |
297 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); | 311 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); |
@@ -326,56 +340,68 @@ bool VMemo::startRecording() { | |||
326 | config.setGroup( "System" ); | 340 | config.setGroup( "System" ); |
327 | fName = QPEApplication::documentDir() ; | 341 | fName = QPEApplication::documentDir() ; |
328 | fileName = config.readEntry("RecLocation", fName); | 342 | fileName = config.readEntry("RecLocation", fName); |
329 | 343 | ||
330 | int s; | 344 | int s; |
331 | s=fileName.find(':'); | 345 | s=fileName.find(':'); |
332 | if(s) | 346 | if(s) |
333 | fileName=fileName.right(fileName.length()-s-2); | 347 | fileName=fileName.right(fileName.length()-s-2); |
334 | qDebug("pathname will be "+fileName); | 348 | qDebug("pathname will be "+fileName); |
335 | 349 | ||
336 | if( fileName.left(1).find('/') == -1) | 350 | if( fileName.left(1).find('/') == -1) |
337 | fileName="/"+fileName; | 351 | fileName="/"+fileName; |
338 | if( fileName.right(1).find('/') == -1) | 352 | if( fileName.right(1).find('/') == -1) |
339 | fileName+="/"; | 353 | fileName+="/"; |
340 | fName = "vm_"+ dt.toString()+ ".wav"; | 354 | fName = "vm_"+ dt.toString()+ ".wav"; |
341 | 355 | ||
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); |
366 | l.setType("audio/x-wav"); | 392 | l.setType("audio/x-wav"); |
367 | l.setCategories(cats); | 393 | l.setCategories(cats); |
368 | l.writeLink(); | 394 | l.writeLink(); |
369 | 395 | ||
370 | record(); | 396 | record(); |
371 | 397 | ||
372 | return TRUE; | 398 | return TRUE; |
373 | } | 399 | } |
374 | 400 | ||
375 | void VMemo::stopRecording() { | 401 | void VMemo::stopRecording() { |
376 | show(); | 402 | show(); |
377 | qDebug("Stopped recording"); | 403 | qDebug("Stopped recording"); |
378 | recording = FALSE; | 404 | recording = FALSE; |
379 | if(useAlerts) { | 405 | if(useAlerts) { |
380 | msgLabel->close(); | 406 | msgLabel->close(); |
381 | msgLabel=0; | 407 | msgLabel=0; |
@@ -626,26 +652,26 @@ int VMemo::setToggleButton(int tog) { | |||
626 | break; | 652 | break; |
627 | case 4: | 653 | case 4: |
628 | return Key_F12; | 654 | return Key_F12; |
629 | break; | 655 | break; |
630 | case 5: | 656 | case 5: |
631 | return Key_F9; | 657 | return Key_F9; |
632 | break; | 658 | break; |
633 | case 6: | 659 | case 6: |
634 | return Key_F10; | 660 | return Key_F10; |
635 | break; | 661 | break; |
636 | case 7: | 662 | case 7: |
637 | return Key_F11; | 663 | return Key_F11; |
638 | break; | 664 | break; |
639 | case 8: | 665 | case 8: |
640 | return Key_F13; | 666 | return Key_F13; |
641 | break; | 667 | break; |
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 | } |