-rw-r--r-- | noncore/multimedia/showimg/showimg.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/multimedia/showimg/showimg.cpp b/noncore/multimedia/showimg/showimg.cpp index 0fbffe7..d6f0733 100644 --- a/noncore/multimedia/showimg/showimg.cpp +++ b/noncore/multimedia/showimg/showimg.cpp | |||
@@ -346,385 +346,385 @@ ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) | |||
346 | viewMenuView->insertSeparator(); | 346 | viewMenuView->insertSeparator(); |
347 | 347 | ||
348 | 348 | ||
349 | sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true); | 349 | sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true); |
350 | connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) ); | 350 | connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) ); |
351 | sss->addTo( iconToolBar ); | 351 | sss->addTo( iconToolBar ); |
352 | sss->addTo( viewMenuView ); | 352 | sss->addTo( viewMenuView ); |
353 | 353 | ||
354 | sss->setOn(isSized); | 354 | sss->setOn(isSized); |
355 | viewMenuView->insertSeparator(); | 355 | viewMenuView->insertSeparator(); |
356 | 356 | ||
357 | 357 | ||
358 | a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), | 358 | a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), |
359 | QString::null, 0, this, 0 ); | 359 | QString::null, 0, this, 0 ); |
360 | connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); | 360 | connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); |
361 | a->addTo( iconToolBar ); | 361 | a->addTo( iconToolBar ); |
362 | a->addTo( viewMenuView); | 362 | a->addTo( viewMenuView); |
363 | 363 | ||
364 | a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ), | 364 | a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ), |
365 | QString::null, 0, this, 0 ); | 365 | QString::null, 0, this, 0 ); |
366 | connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) ); | 366 | connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) ); |
367 | a->addTo( iconToolBar ); | 367 | a->addTo( iconToolBar ); |
368 | a->addTo( viewMenuView); | 368 | a->addTo( viewMenuView); |
369 | 369 | ||
370 | 370 | ||
371 | Config config( "ImageViewer" ); | 371 | Config config( "ImageViewer" ); |
372 | config.setGroup( "SlideShow" ); | 372 | config.setGroup( "SlideShow" ); |
373 | slideDelay = config.readNumEntry( "Delay", 2); | 373 | slideDelay = config.readNumEntry( "Delay", 2); |
374 | slideRepeat = config.readBoolEntry( "Repeat", FALSE ); | 374 | slideRepeat = config.readBoolEntry( "Repeat", FALSE ); |
375 | slideReverse = config.readBoolEntry("Reverse", FALSE); | 375 | slideReverse = config.readBoolEntry("Reverse", FALSE); |
376 | 376 | ||
377 | config.setGroup("Default"); | 377 | config.setGroup("Default"); |
378 | rotateOnLoad = config.readBoolEntry("Rotate", FALSE); | 378 | rotateOnLoad = config.readBoolEntry("Rotate", FALSE); |
379 | fastLoad = config.readBoolEntry("FastLoad", TRUE); | 379 | fastLoad = config.readBoolEntry("FastLoad", TRUE); |
380 | slideTimer = new QTimer( this ); | 380 | slideTimer = new QTimer( this ); |
381 | connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) ); | 381 | connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) ); |
382 | 382 | ||
383 | switchToFileSelector(); | 383 | switchToFileSelector(); |
384 | 384 | ||
385 | setMouseTracking( TRUE ); | 385 | setMouseTracking( TRUE ); |
386 | 386 | ||
387 | 387 | ||
388 | } | 388 | } |
389 | 389 | ||
390 | ImageViewer::~ImageViewer() | 390 | ImageViewer::~ImageViewer() |
391 | { | 391 | { |
392 | Config cfg("Image Viewer"); | 392 | Config cfg("Image Viewer"); |
393 | cfg.setGroup("Image Viewer"); | 393 | cfg.setGroup("Image Viewer"); |
394 | 394 | ||
395 | cfg.writeEntry("ShowThumbnails",(int)showThumbView); | 395 | cfg.writeEntry("ShowThumbnails",(int)showThumbView); |
396 | cfg.writeEntry("SizeToScreen",(int)isSized); | 396 | cfg.writeEntry("SizeToScreen",(int)isSized); |
397 | 397 | ||
398 | cfg.setGroup( "SlideShow" ); | 398 | cfg.setGroup( "SlideShow" ); |
399 | cfg.writeEntry( "Delay", slideDelay); | 399 | cfg.writeEntry( "Delay", slideDelay); |
400 | cfg.writeEntry( "Repeat", slideRepeat ); | 400 | cfg.writeEntry( "Repeat", slideRepeat ); |
401 | cfg.writeEntry("Reverse", slideReverse); | 401 | cfg.writeEntry("Reverse", slideReverse); |
402 | 402 | ||
403 | cfg.setGroup("Default"); | 403 | cfg.setGroup("Default"); |
404 | cfg.writeEntry("Rotate", rotateOnLoad); | 404 | cfg.writeEntry("Rotate", rotateOnLoad); |
405 | cfg.writeEntry("FastLoad", fastLoad); | 405 | cfg.writeEntry("FastLoad", fastLoad); |
406 | 406 | ||
407 | delete imagePanel; // in case it is fullscreen | 407 | delete imagePanel; // in case it is fullscreen |
408 | } | 408 | } |
409 | 409 | ||
410 | void ImageViewer::help() { | 410 | void ImageViewer::help() { |
411 | 411 | ||
412 | } | 412 | } |
413 | 413 | ||
414 | 414 | ||
415 | void ImageViewer::settings() | 415 | void ImageViewer::settings() |
416 | { | 416 | { |
417 | SettingsDialog dlg( this, 0, TRUE ); | 417 | SettingsDialog dlg( this, 0, TRUE ); |
418 | dlg.setDelay( slideDelay ); | 418 | dlg.setDelay( slideDelay ); |
419 | dlg.setRepeat( slideRepeat ); | 419 | dlg.setRepeat( slideRepeat ); |
420 | dlg.setReverse( slideReverse ); | 420 | dlg.setReverse( slideReverse ); |
421 | dlg.setRotate(rotateOnLoad); | 421 | dlg.setRotate(rotateOnLoad); |
422 | dlg.setFastLoad(fastLoad); | 422 | dlg.setFastLoad(fastLoad); |
423 | 423 | ||
424 | if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) { | 424 | if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) { |
425 | qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>"); | 425 | qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>"); |
426 | slideDelay = dlg.delay(); | 426 | slideDelay = dlg.delay(); |
427 | slideRepeat = dlg.repeat(); | 427 | slideRepeat = dlg.repeat(); |
428 | slideReverse = dlg.reverse(); | 428 | slideReverse = dlg.reverse(); |
429 | rotateOnLoad = dlg.rotate(); | 429 | rotateOnLoad = dlg.rotate(); |
430 | fastLoad = dlg.fastLoad(); | 430 | fastLoad = dlg.fastLoad(); |
431 | 431 | ||
432 | Config config( "ImageViewer" ); | 432 | Config config( "ImageViewer" ); |
433 | config.setGroup( "SlideShow" ); | 433 | config.setGroup( "SlideShow" ); |
434 | config.writeEntry( "Delay", slideDelay ); | 434 | config.writeEntry( "Delay", slideDelay ); |
435 | config.writeEntry( "Repeat", slideRepeat ); | 435 | config.writeEntry( "Repeat", slideRepeat ); |
436 | config.writeEntry("Reverse", slideReverse); | 436 | config.writeEntry("Reverse", slideReverse); |
437 | 437 | ||
438 | config.setGroup("Default"); | 438 | config.setGroup("Default"); |
439 | config.writeEntry("Rotate", rotateOnLoad); | 439 | config.writeEntry("Rotate", rotateOnLoad); |
440 | config.writeEntry("FastLoad", fastLoad); | 440 | config.writeEntry("FastLoad", fastLoad); |
441 | } | 441 | } |
442 | } | 442 | } |
443 | 443 | ||
444 | void ImageViewer::switchSizeToScreen() | 444 | void ImageViewer::switchSizeToScreen() |
445 | { | 445 | { |
446 | isSized=!isSized; | 446 | isSized=!isSized; |
447 | sss->setOn(isSized); | 447 | sss->setOn(isSized); |
448 | updateImage(); | 448 | updateImage(); |
449 | } | 449 | } |
450 | 450 | ||
451 | void ImageViewer::updateImage() | 451 | void ImageViewer::updateImage() |
452 | { | 452 | { |
453 | if ( isSized ) { | 453 | if ( isSized ) { |
454 | imagePanel->setPixmap(pmScaled); | 454 | imagePanel->setPixmap(pmScaled); |
455 | } else { | 455 | } else { |
456 | imagePanel->setPixmap(pm); | 456 | imagePanel->setPixmap(pm); |
457 | } | 457 | } |
458 | } | 458 | } |
459 | 459 | ||
460 | void ImageViewer::switchThumbView() | 460 | void ImageViewer::switchThumbView() |
461 | { | 461 | { |
462 | 462 | ||
463 | showThumbView=!showThumbView; | 463 | showThumbView=!showThumbView; |
464 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); | 464 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); |
465 | fileSelector->switchView(); | 465 | fileSelector->switchView(); |
466 | 466 | ||
467 | } | 467 | } |
468 | 468 | ||
469 | void ImageViewer::switchToFileSelector() | 469 | void ImageViewer::switchToFileSelector() |
470 | { | 470 | { |
471 | stack->raiseWidget(fileSelector); | 471 | stack->raiseWidget(fileSelector); |
472 | menuBar->clear(); | 472 | menuBar->clear(); |
473 | menuBar->insertItem( tr("File"), fileMenuFile ); | 473 | menuBar->insertItem( tr("File"), fileMenuFile ); |
474 | menuBar->insertItem( tr("View"), viewMenuFile ); | 474 | menuBar->insertItem( tr("View"), viewMenuFile ); |
475 | menuBar->insertItem( tr("Options"), optionsMenuFile ); | 475 | menuBar->insertItem( tr("Options"), optionsMenuFile ); |
476 | iconToolBar->hide(); | 476 | iconToolBar->hide(); |
477 | imagePanel->disable(); | 477 | imagePanel->disable(); |
478 | slideShow(false); | 478 | slideShow(false); |
479 | 479 | ||
480 | } | 480 | } |
481 | 481 | ||
482 | void ImageViewer::switchToImageView() | 482 | void ImageViewer::switchToImageView() |
483 | { | 483 | { |
484 | stack->raiseWidget(imagePanel); | 484 | stack->raiseWidget(imagePanel); |
485 | 485 | ||
486 | menuBar->clear(); | 486 | menuBar->clear(); |
487 | menuBar->insertItem( tr("File"), fileMenuView ); | 487 | menuBar->insertItem( tr("File"), fileMenuView ); |
488 | menuBar->insertItem( tr("View"), viewMenuView ); | 488 | menuBar->insertItem( tr("View"), viewMenuView ); |
489 | viewMenuView->setItemEnabled(BLACKANDWHITE,true); | 489 | viewMenuView->setItemEnabled(BLACKANDWHITE,true); |
490 | iconToolBar->show(); | 490 | iconToolBar->show(); |
491 | 491 | ||
492 | imagePanel->setPosition(0,0); | 492 | imagePanel->setPosition(0,0); |
493 | 493 | ||
494 | } | 494 | } |
495 | 495 | ||
496 | 496 | ||
497 | void ImageViewer::setDocument(const QString& fileref) | 497 | void ImageViewer::setDocument(const QString& fileref) |
498 | { | 498 | { |
499 | delayLoad = fileref; | 499 | delayLoad = fileref; |
500 | switchToImageView(); | 500 | switchToImageView(); |
501 | QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); | 501 | QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); |
502 | } | 502 | } |
503 | 503 | ||
504 | void ImageViewer::doDelayedLoad() | 504 | void ImageViewer::doDelayedLoad() |
505 | { | 505 | { |
506 | show(delayLoad); | 506 | show(delayLoad); |
507 | } | 507 | } |
508 | 508 | ||
509 | void ImageViewer::show() | 509 | void ImageViewer::show() |
510 | { | 510 | { |
511 | normalView(); | 511 | normalView(); |
512 | QMainWindow::show(); | 512 | QMainWindow::show(); |
513 | } | 513 | } |
514 | 514 | ||
515 | void ImageViewer::show(const QString& fileref) | 515 | void ImageViewer::show(const QString& fileref) |
516 | { | 516 | { |
517 | // qDebug("Show "+fileref); | 517 | // qDebug("Show "+fileref); |
518 | bFromDocView = TRUE; | 518 | bFromDocView = TRUE; |
519 | closeFileSelector(); | 519 | closeFileSelector(); |
520 | DocLnk link(fileref); | 520 | DocLnk link(fileref); |
521 | if ( link.isValid() ) { | 521 | if ( link.isValid() ) { |
522 | openFile(link); | 522 | openFile(link); |
523 | } else { | 523 | } else { |
524 | filename = fileref; | 524 | filename = fileref; |
525 | updateCaption( fileref ); | 525 | updateCaption( fileref ); |
526 | loadImage( fileref ); | 526 | loadImage( fileref ); |
527 | } | 527 | } |
528 | } | 528 | } |
529 | 529 | ||
530 | void ImageViewer::openFile() { | 530 | void ImageViewer::openFile() { |
531 | MimeTypes types; | 531 | MimeTypes types; |
532 | QStringList image; | 532 | QStringList image; |
533 | image << "image/*"; | 533 | image << "image/*"; |
534 | types.insert("Images", image); | 534 | types.insert("Images", image); |
535 | 535 | ||
536 | QString str = OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 ); | 536 | QString str = OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 ); |
537 | DocLnk link(str); | 537 | DocLnk link(str); |
538 | if ( link.isValid() ) | 538 | // if ( link.isValid() ) |
539 | openFile(link); | 539 | openFile(link); |
540 | 540 | ||
541 | } | 541 | } |
542 | 542 | ||
543 | void ImageViewer::openFile( const DocLnk &link ) | 543 | void ImageViewer::openFile( const DocLnk &link ) |
544 | { | 544 | { |
545 | closeFileSelector(); | 545 | closeFileSelector(); |
546 | // DocLnk link(file); | 546 | // DocLnk link(file); |
547 | qDebug("open "+link.name()); | 547 | qDebug("open "+link.name()); |
548 | updateCaption( link.name() ); | 548 | updateCaption( link.name() ); |
549 | loadImage( link.file() ); | 549 | loadImage( link.file() ); |
550 | if (slideTimer->isActive()) { | 550 | if (slideTimer->isActive()) { |
551 | slideTimer->start(slideDelay * 1000, FALSE); | 551 | slideTimer->start(slideDelay * 1000, FALSE); |
552 | } | 552 | } |
553 | 553 | ||
554 | } | 554 | } |
555 | 555 | ||
556 | void ImageViewer::open() | 556 | void ImageViewer::open() |
557 | { | 557 | { |
558 | switchToFileSelector(); | 558 | switchToFileSelector(); |
559 | } | 559 | } |
560 | 560 | ||
561 | void ImageViewer::closeFileSelector() | 561 | void ImageViewer::closeFileSelector() |
562 | { | 562 | { |
563 | switchToImageView(); | 563 | switchToImageView(); |
564 | } | 564 | } |
565 | 565 | ||
566 | void ImageViewer::updateCaption( QString name ) | 566 | void ImageViewer::updateCaption( QString name ) |
567 | { | 567 | { |
568 | int sep = name.findRev( '/' ); | 568 | int sep = name.findRev( '/' ); |
569 | if ( sep >= 0 ) | 569 | if ( sep >= 0 ) |
570 | name = name.mid( sep+1 ); | 570 | name = name.mid( sep+1 ); |
571 | setCaption( name + tr(" - Image Viewer") ); | 571 | setCaption( name + tr(" - Image Viewer") ); |
572 | } | 572 | } |
573 | 573 | ||
574 | /* | 574 | /* |
575 | This function loads an image from a file. | 575 | This function loads an image from a file. |
576 | */ | 576 | */ |
577 | 577 | ||
578 | void ImageViewer::loadImage( const char *fileName ) | 578 | void ImageViewer::loadImage( const char *fileName ) |
579 | { | 579 | { |
580 | filename = fileName; | 580 | filename = fileName; |
581 | if ( filename ) { | 581 | if ( filename ) { |
582 | QApplication::setOverrideCursor( waitCursor ); // this might take time | 582 | QApplication::setOverrideCursor( waitCursor ); // this might take time |
583 | //imagePanel->statusLabel()->setText( tr("Loading image...") ); | 583 | //imagePanel->statusLabel()->setText( tr("Loading image...") ); |
584 | qApp->processEvents(); | 584 | qApp->processEvents(); |
585 | bool ok = image.load(filename, 0); | 585 | bool ok = image.load(filename, 0); |
586 | if ( ok ) { | 586 | if ( ok ) { |
587 | ok = reconvertImage(); | 587 | ok = reconvertImage(); |
588 | updateImageInfo(filename); | 588 | updateImageInfo(filename); |
589 | } | 589 | } |
590 | if ( !ok ) { | 590 | if ( !ok ) { |
591 | pm.resize(0,0); // couldn't load image | 591 | pm.resize(0,0); // couldn't load image |
592 | update(); | 592 | update(); |
593 | } | 593 | } |
594 | QApplication::restoreOverrideCursor(); // restore original cursor | 594 | QApplication::restoreOverrideCursor(); // restore original cursor |
595 | } | 595 | } |
596 | 596 | ||
597 | // fastLoad ? ", Fast" : "", | 597 | // fastLoad ? ", Fast" : "", |
598 | // fastLoad ? QMAX(imagewidth/maxsize, imageheight/maxsize) : 1); | 598 | // fastLoad ? QMAX(imagewidth/maxsize, imageheight/maxsize) : 1); |
599 | 599 | ||
600 | 600 | ||
601 | // matrix.reset(); | 601 | // matrix.reset(); |
602 | rotated90 = FALSE; | 602 | rotated90 = FALSE; |
603 | 603 | ||
604 | if (rotateOnLoad) { | 604 | if (rotateOnLoad) { |
605 | rotated90 = TRUE; | 605 | rotated90 = TRUE; |
606 | rot90(); | 606 | rot90(); |
607 | // matrix.rotate( -90.0 ); | 607 | // matrix.rotate( -90.0 ); |
608 | } | 608 | } |
609 | 609 | ||
610 | switchToImageView(); | 610 | switchToImageView(); |
611 | updateImage(); | 611 | updateImage(); |
612 | 612 | ||
613 | } | 613 | } |
614 | 614 | ||
615 | bool ImageViewer::loadSelected() | 615 | bool ImageViewer::loadSelected() |
616 | { | 616 | { |
617 | bool ok = false; | 617 | bool ok = false; |
618 | if ( stack->visibleWidget() == fileSelector ) | 618 | if ( stack->visibleWidget() == fileSelector ) |
619 | { | 619 | { |
620 | const DocLnk *link = fileSelector->selected(); | 620 | const DocLnk *link = fileSelector->selected(); |
621 | if ( link ) | 621 | if ( link ) |
622 | { | 622 | { |
623 | if ( link->file() != filename ) | 623 | if ( link->file() != filename ) |
624 | { | 624 | { |
625 | updateCaption( link->name() ); | 625 | updateCaption( link->name() ); |
626 | filename = link->file(); | 626 | filename = link->file(); |
627 | qApp->processEvents(); | 627 | qApp->processEvents(); |
628 | ok = image.load(filename, 0); | 628 | ok = image.load(filename, 0); |
629 | if ( ok ) | 629 | if ( ok ) |
630 | { | 630 | { |
631 | updateImageInfo(filename); | 631 | updateImageInfo(filename); |
632 | ok = reconvertImage(); | 632 | ok = reconvertImage(); |
633 | } | 633 | } |
634 | if ( !ok ) | 634 | if ( !ok ) |
635 | pm.resize(0,0); | 635 | pm.resize(0,0); |
636 | } | 636 | } |
637 | } | 637 | } |
638 | } | 638 | } |
639 | if ( !image.isNull() ) | 639 | if ( !image.isNull() ) |
640 | { | 640 | { |
641 | ok = true; | 641 | ok = true; |
642 | closeFileSelector(); | 642 | closeFileSelector(); |
643 | } | 643 | } |
644 | 644 | ||
645 | return ok; | 645 | return ok; |
646 | } | 646 | } |
647 | 647 | ||
648 | bool ImageViewer::reconvertImage() | 648 | bool ImageViewer::reconvertImage() |
649 | { | 649 | { |
650 | bool success = FALSE; | 650 | bool success = FALSE; |
651 | 651 | ||
652 | if ( image.isNull() ) return FALSE; | 652 | if ( image.isNull() ) return FALSE; |
653 | 653 | ||
654 | QApplication::setOverrideCursor( waitCursor ); // this might take time | 654 | QApplication::setOverrideCursor( waitCursor ); // this might take time |
655 | if ( pm.convertFromImage(image /*, conversion_flags */ ) ) | 655 | if ( pm.convertFromImage(image /*, conversion_flags */ ) ) |
656 | { | 656 | { |
657 | pmScaled = QPixmap(); | 657 | pmScaled = QPixmap(); |
658 | scale(); | 658 | scale(); |
659 | success = TRUE; // load successful | 659 | success = TRUE; // load successful |
660 | } | 660 | } |
661 | else | 661 | else |
662 | { | 662 | { |
663 | pm.resize(0,0); // couldn't load image | 663 | pm.resize(0,0); // couldn't load image |
664 | } | 664 | } |
665 | QApplication::restoreOverrideCursor(); // restore original cursor | 665 | QApplication::restoreOverrideCursor(); // restore original cursor |
666 | 666 | ||
667 | return success; // TRUE if loaded OK | 667 | return success; // TRUE if loaded OK |
668 | } | 668 | } |
669 | 669 | ||
670 | 670 | ||
671 | int ImageViewer::calcHeight() | 671 | int ImageViewer::calcHeight() |
672 | { | 672 | { |
673 | if ( !isFullScreen ) | 673 | if ( !isFullScreen ) |
674 | return imagePanel->paneHeight(); | 674 | return imagePanel->paneHeight(); |
675 | else | 675 | else |
676 | return qApp->desktop()->height(); | 676 | return qApp->desktop()->height(); |
677 | } | 677 | } |
678 | /* | 678 | /* |
679 | This functions scales the pixmap in the member variable "pm" to fit the | 679 | This functions scales the pixmap in the member variable "pm" to fit the |
680 | widget size and puts the resulting pixmap in the member variable "pmScaled". | 680 | widget size and puts the resulting pixmap in the member variable "pmScaled". |
681 | */ | 681 | */ |
682 | void ImageViewer::scale() | 682 | void ImageViewer::scale() |
683 | { | 683 | { |
684 | int h = calcHeight(); | 684 | int h = calcHeight(); |
685 | if ( image.isNull() ) return; | 685 | if ( image.isNull() ) return; |
686 | 686 | ||
687 | QApplication::setOverrideCursor( waitCursor ); // this might take time | 687 | QApplication::setOverrideCursor( waitCursor ); // this might take time |
688 | if ( imagePanel->paneWidth() == pm.width() && h == pm.height() ) | 688 | if ( imagePanel->paneWidth() == pm.width() && h == pm.height() ) |
689 | { // no need to scale if widget | 689 | { // no need to scale if widget |
690 | pmScaled = pm; // size equals pixmap size | 690 | pmScaled = pm; // size equals pixmap size |
691 | } | 691 | } |
692 | else | 692 | else |
693 | { | 693 | { |
694 | double hs = (double)h / (double)image.height(); | 694 | double hs = (double)h / (double)image.height(); |
695 | double ws = (double)imagePanel->paneWidth() / (double)image.width(); | 695 | double ws = (double)imagePanel->paneWidth() / (double)image.width(); |
696 | double scaleFactor = (hs > ws) ? ws : hs; | 696 | double scaleFactor = (hs > ws) ? ws : hs; |
697 | int smoothW = (int)(scaleFactor * image.width()); | 697 | int smoothW = (int)(scaleFactor * image.width()); |
698 | int smoothH = (int)(scaleFactor * image.height()); | 698 | int smoothH = (int)(scaleFactor * image.height()); |
699 | 699 | ||
700 | pmScaled.convertFromImage( image.smoothScale( smoothW, smoothH ) /*, conversion_flags */ ); | 700 | pmScaled.convertFromImage( image.smoothScale( smoothW, smoothH ) /*, conversion_flags */ ); |
701 | } | 701 | } |
702 | QApplication::restoreOverrideCursor(); // restore original cursor | 702 | QApplication::restoreOverrideCursor(); // restore original cursor |
703 | } | 703 | } |
704 | 704 | ||
705 | /* | 705 | /* |
706 | The resize event handler, if a valid pixmap was loaded it will call | 706 | The resize event handler, if a valid pixmap was loaded it will call |
707 | scale() to fit the pixmap to the new widget size. | 707 | scale() to fit the pixmap to the new widget size. |
708 | */ | 708 | */ |
709 | 709 | ||
710 | void ImageViewer::resizeEvent( QResizeEvent * ) | 710 | void ImageViewer::resizeEvent( QResizeEvent * ) |
711 | { | 711 | { |
712 | 712 | ||
713 | if ( pm.size() == QSize( 0, 0 ) ) // we couldn't load the image | 713 | if ( pm.size() == QSize( 0, 0 ) ) // we couldn't load the image |
714 | return; | 714 | return; |
715 | 715 | ||
716 | int h = calcHeight(); | 716 | int h = calcHeight(); |
717 | 717 | ||
718 | if ( imagePanel->paneWidth() != pmScaled.width() || h != pmScaled.height() ) | 718 | if ( imagePanel->paneWidth() != pmScaled.width() || h != pmScaled.height() ) |
719 | { // if new size, | 719 | { // if new size, |
720 | scale(); // scale pmScaled to window | 720 | scale(); // scale pmScaled to window |
721 | } | 721 | } |
722 | if ( image.hasAlphaBuffer() ) | 722 | if ( image.hasAlphaBuffer() ) |
723 | erase(); | 723 | erase(); |
724 | } | 724 | } |
725 | 725 | ||
726 | 726 | ||
727 | void ImageViewer::hFlip() | 727 | void ImageViewer::hFlip() |
728 | { | 728 | { |
729 | // matrix.scale( -1.0, 1.0 ); | 729 | // matrix.scale( -1.0, 1.0 ); |
730 | 730 | ||