~ubuntu-branches/ubuntu/saucy/digikam/saucy

« back to all changes in this revision

Viewing changes to utilities/slideshow/slideshow.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-12-21 23:19:11 UTC
  • mfrom: (1.2.33 upstream) (3.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20101221231911-z9jip7s5aht1jqn9
Tags: 2:1.7.0-1ubuntu1
* Merge from Debian Experimental. Remaining Ubuntu changes:
  - Export .pot name and copy to plugins in debian/rules
  - Version build-depends on kipi-plugins-dev to ensure build is against the
    same version on all archs
* Drop debian/patches/kubuntu_01_linker.diff, incoporated upstream
* Remove patches directory and unused patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
115
115
};
116
116
 
117
117
SlideShow::SlideShow(const SlideShowSettings& settings)
118
 
         : QWidget(0, Qt::FramelessWindowHint), d(new SlideShowPriv)
 
118
    : QWidget(0, Qt::FramelessWindowHint), d(new SlideShowPriv)
119
119
{
120
120
    d->settings = settings;
121
121
 
145
145
 
146
146
    d->toolBar = new ToolBar(this);
147
147
    d->toolBar->hide();
 
148
 
148
149
    if (!d->settings.loop)
 
150
    {
149
151
        d->toolBar->setEnabledPrev(false);
 
152
    }
150
153
 
151
154
    connect(d->toolBar, SIGNAL(signalPause()),
152
155
            this, SLOT(slotPause()));
220
223
void SlideShow::setCurrent(const KUrl& url)
221
224
{
222
225
    int index = d->settings.fileList.indexOf(url);
 
226
 
223
227
    if (index != -1)
224
228
    {
225
229
        d->currentImage = url;
303
307
void SlideShow::slotGotImagePreview(const LoadingDescription& desc, const DImg& preview)
304
308
{
305
309
    if (desc.filePath != d->currentImage.toLocalFile() || desc.isThumbnail())
 
310
    {
306
311
        return;
 
312
    }
307
313
 
308
314
    d->preview = preview;
309
315
 
317
323
            d->timer->setSingleShot(true);
318
324
            d->timer->start(d->settings.delay);
319
325
        }
 
326
 
320
327
        preloadNextImage();
321
328
    }
322
329
}
389
396
                str.clear();
390
397
 
391
398
                if (!photoInfo.make.isEmpty())
 
399
                {
392
400
                    str = photoInfo.make;
 
401
                }
393
402
 
394
403
                if (!photoInfo.model.isEmpty())
395
404
                {
396
405
                    if (!photoInfo.make.isEmpty())
 
406
                    {
397
407
                        str += QString(" / ");
 
408
                    }
398
409
 
399
410
                    str += photoInfo.model;
400
411
                }
409
420
                str.clear();
410
421
 
411
422
                if (!photoInfo.exposureTime.isEmpty())
 
423
                {
412
424
                    str = photoInfo.exposureTime;
 
425
                }
413
426
 
414
427
                if (!photoInfo.sensitivity.isEmpty())
415
428
                {
416
429
                    if (!photoInfo.exposureTime.isEmpty())
 
430
                    {
417
431
                        str += QString(" / ");
 
432
                    }
418
433
 
419
434
                    str += i18n("%1 ISO",photoInfo.sensitivity);
420
435
                }
429
444
                str.clear();
430
445
 
431
446
                if (!photoInfo.aperture.isEmpty())
 
447
                {
432
448
                    str = photoInfo.aperture;
 
449
                }
433
450
 
434
451
                if (photoInfo.focalLength35mm.isEmpty())
435
452
                {
436
453
                    if (!photoInfo.focalLength.isEmpty())
437
454
                    {
438
455
                        if (!photoInfo.aperture.isEmpty())
 
456
                        {
439
457
                            str += QString(" / ");
 
458
                        }
440
459
 
441
460
                        str += photoInfo.focalLength;
442
461
                    }
444
463
                else
445
464
                {
446
465
                    if (!photoInfo.aperture.isEmpty())
447
 
                            str += QString(" / ");
 
466
                    {
 
467
                        str += QString(" / ");
 
468
                    }
448
469
 
449
470
                    if (!photoInfo.focalLength.isEmpty())
 
471
                    {
450
472
                        str += QString("%1 (35mm: %2)").arg(photoInfo.focalLength).arg(photoInfo.focalLength35mm);
 
473
                    }
451
474
                    else
 
475
                    {
452
476
                        str += QString("35mm: %1)").arg(photoInfo.focalLength35mm);
 
477
                    }
453
478
                }
454
479
 
455
480
                printInfoText(p, offset, str);
471
496
            if (d->settings.printName)
472
497
            {
473
498
                str = QString("%1 (%2/%3)").arg(d->currentImage.fileName())
474
 
                                           .arg(QString::number(d->fileIndex + 1))
475
 
                                           .arg(QString::number(d->settings.fileList.count()));
 
499
                      .arg(QString::number(d->fileIndex + 1))
 
500
                      .arg(QString::number(d->settings.fileList.count()));
476
501
 
477
502
                printInfoText(p, offset, str);
478
503
            }
485
510
            p.drawText(0, 0, d->pixmap.width(), d->pixmap.height(),
486
511
                       Qt::AlignCenter|Qt::TextWordWrap,
487
512
                       i18n("Cannot display image\n\"%1\"",
488
 
                       d->currentImage.fileName()));
 
513
                            d->currentImage.fileName()));
489
514
        }
490
515
    }
491
516
    else
493
518
        // End of Slide Show.
494
519
 
495
520
        QPixmap logo;
 
521
 
496
522
        if (KGlobal::mainComponent().aboutData()->appName() == QString("digikam"))
497
523
        {
498
524
            logo = QPixmap(KStandardDirs::locate("data", "digikam/data/logo-digikam.png"))
499
 
                           .scaled(128, 128, Qt::KeepAspectRatio, Qt::SmoothTransformation);
 
525
                   .scaled(128, 128, Qt::KeepAspectRatio, Qt::SmoothTransformation);
500
526
        }
501
527
        else
502
528
        {
503
529
            logo = QPixmap(KStandardDirs::locate("data", "showfoto/data/logo-showfoto.png"))
504
 
                           .scaled(128, 128, Qt::KeepAspectRatio, Qt::SmoothTransformation);
 
530
                   .scaled(128, 128, Qt::KeepAspectRatio, Qt::SmoothTransformation);
505
531
        }
506
532
 
507
533
        QFont fn(font());
527
553
    {
528
554
        offset += 20;
529
555
        p.setPen(Qt::black);
 
556
 
530
557
        for (int x=19; x<=21; ++x)
531
558
            for (int y=offset+1; y>=offset-1; --y)
 
559
            {
532
560
                p.drawText(x, height()-y, str);
 
561
            }
533
562
 
534
563
        p.setPen(Qt::white);
535
564
        p.drawText(20, height()-offset, str);
556
585
             currIndex < (uint)comments.length() && !breakLine ; ++currIndex )
557
586
        {
558
587
            if ( comments[currIndex] == QChar('\n') || comments[currIndex].isSpace() )
 
588
            {
559
589
                breakLine = true;
 
590
            }
560
591
        }
561
592
 
562
593
        if (commentsLinesLengthLocal <= (currIndex - commentsIndex))
 
594
        {
563
595
            commentsLinesLengthLocal = (currIndex - commentsIndex);
 
596
        }
564
597
 
565
598
        breakLine = false;
566
599
 
568
601
             currIndex <= commentsIndex + commentsLinesLengthLocal &&
569
602
             currIndex < (uint)comments.length() && !breakLine ;
570
603
             ++currIndex )
571
 
            {
572
 
                breakLine = (comments[currIndex] == QChar('\n')) ? true : false;
573
 
 
574
 
                if (breakLine)
575
 
                    newLine.append(QString(" "));
576
 
                else
577
 
                    newLine.append(comments[currIndex]);
578
 
            }
579
 
 
580
 
            commentsIndex = currIndex; // The line is ended
 
604
        {
 
605
            breakLine = (comments[currIndex] == QChar('\n')) ? true : false;
 
606
 
 
607
            if (breakLine)
 
608
            {
 
609
                newLine.append(QString(" "));
 
610
            }
 
611
            else
 
612
            {
 
613
                newLine.append(comments[currIndex]);
 
614
            }
 
615
        }
 
616
 
 
617
        commentsIndex = currIndex; // The line is ended
581
618
 
582
619
        if (commentsIndex != (uint)comments.length())
583
620
        {
640
677
    close();
641
678
}
642
679
 
643
 
void SlideShow::wheelEvent(QWheelEvent *e)
 
680
void SlideShow::wheelEvent(QWheelEvent* e)
644
681
{
645
682
    if (e->delta() < 0)
646
683
    {
662
699
void SlideShow::mousePressEvent(QMouseEvent* e)
663
700
{
664
701
    if (d->endOfShow)
 
702
    {
665
703
        close();
 
704
    }
666
705
 
667
706
    if (e->button() == Qt::LeftButton)
668
707
    {
683
722
void SlideShow::keyPressEvent(QKeyEvent* e)
684
723
{
685
724
    if (!e)
 
725
    {
686
726
        return;
 
727
    }
687
728
 
688
729
    d->toolBar->keyPressEvent(e);
689
730
}
718
759
    d->mouseMoveTimer->start(1000);
719
760
 
720
761
    if (!d->toolBar->canHide())
 
762
    {
721
763
        return;
 
764
    }
722
765
 
723
766
    QPoint pos(e->pos());
724
767
 
752
795
    else
753
796
    {
754
797
        if (!d->toolBar->isHidden())
 
798
        {
755
799
            d->toolBar->hide();
 
800
        }
756
801
    }
757
802
}
758
803
 
769
814
 
770
815
    if (topLeftLarger.contains(pos) || topRightLarger.contains(pos)
771
816
        || bottomLeftLarger.contains(pos) || bottomRightLarger.contains(pos))
 
817
    {
772
818
        return;
 
819
    }
773
820
 
774
821
    setCursor(QCursor(Qt::BlankCursor));
775
822
}
778
825
void SlideShow::inhibitScreenSaver()
779
826
{
780
827
    QDBusMessage message = QDBusMessage::createMethodCall( "org.freedesktop.ScreenSaver", "/ScreenSaver",
781
 
                                                           "org.freedesktop.ScreenSaver", "Inhibit" );
 
828
                           "org.freedesktop.ScreenSaver", "Inhibit" );
782
829
    message << QString( "digiKam" );
783
830
    message << i18nc( "Reason for inhibiting the screensaver activation, when the presentation mode is active", "Giving a presentation" );
784
831
 
785
832
    QDBusReply<uint> reply = QDBusConnection::sessionBus().call( message );
 
833
 
786
834
    if ( reply.isValid() )
 
835
    {
787
836
        d->screenSaverCookie = reply.value();
 
837
    }
788
838
}
789
839
 
790
840
void SlideShow::allowScreenSaver()
792
842
    if ( d->screenSaverCookie != -1 )
793
843
    {
794
844
        QDBusMessage message = QDBusMessage::createMethodCall( "org.freedesktop.ScreenSaver", "/ScreenSaver",
795
 
                                                               "org.freedesktop.ScreenSaver", "UnInhibit" );
 
845
                               "org.freedesktop.ScreenSaver", "UnInhibit" );
796
846
        message << (uint)d->screenSaverCookie;
797
847
        QDBusConnection::sessionBus().send( message );
798
848
    }