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

« back to all changes in this revision

Viewing changes to imageplugins/color/adjustlevelstool.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:
112
112
        levels(0),
113
113
        originalImage(0),
114
114
        gboxSettings(0)
115
 
        {}
 
115
    {}
116
116
 
117
117
    static const QString configGroupName;
118
118
    static const QString configGammaChannelEntry;
169
169
// --------------------------------------------------------
170
170
 
171
171
AdjustLevelsTool::AdjustLevelsTool(QObject* parent)
172
 
                : EditorToolThreaded(parent),
173
 
                  d(new AdjustLevelsToolPriv)
 
172
    : EditorToolThreaded(parent),
 
173
      d(new AdjustLevelsToolPriv)
174
174
{
175
175
    setObjectName("adjustlevels");
176
176
    setToolName(i18n("Adjust Levels"));
206
206
    // -------------------------------------------------------------
207
207
 
208
208
    d->levelsHistogramWidget = new HistogramWidget(256, 140, d->originalImage->bits(),
209
 
                                                             d->originalImage->width(),
210
 
                                                             d->originalImage->height(),
211
 
                                                             d->originalImage->sixteenBit(),
212
 
                                                             d->gboxSettings->plainPage(), false);
 
209
            d->originalImage->width(),
 
210
            d->originalImage->height(),
 
211
            d->originalImage->sixteenBit(),
 
212
            d->gboxSettings->plainPage(), false);
213
213
    d->levelsHistogramWidget->setWhatsThis(i18n("This is the histogram drawing of the selected channel "
214
 
                                                "from the original image."));
 
214
                                           "from the original image."));
215
215
    QHBoxLayout* inputLevelsLayout = new QHBoxLayout;
216
216
    inputLevelsLayout->addWidget(d->levelsHistogramWidget);
217
217
 
365
365
 
366
366
    connect(d->previewWidget, SIGNAL(signalCapturedPointFromOriginal(const Digikam::DColor&, const QPoint&)),
367
367
            this, SLOT(slotSpotColorChanged(const Digikam::DColor&)));
368
 
/*
369
 
    connect(d->previewWidget, SIGNAL(spotPositionChangedFromTarget(const Digikam::DColor&, const QPoint&)),
370
 
            this, SLOT(slotColorSelectedFromTarget(const Digikam::DColor&)));
371
 
*/
 
368
    /*
 
369
        connect(d->previewWidget, SIGNAL(spotPositionChangedFromTarget(const Digikam::DColor&, const QPoint&)),
 
370
                this, SLOT(slotColorSelectedFromTarget(const Digikam::DColor&)));
 
371
    */
372
372
 
373
373
    // -------------------------------------------------------------
374
374
    // Color sliders and spinbox slots.
418
418
AdjustLevelsTool::~AdjustLevelsTool()
419
419
{
420
420
    if (d->destinationPreviewData)
421
 
       delete [] d->destinationPreviewData;
 
421
    {
 
422
        delete [] d->destinationPreviewData;
 
423
    }
422
424
 
423
425
    delete d->levels;
424
426
    delete d;
426
428
 
427
429
// See B.K.O #146636: use event filter with all level slider to display a
428
430
// guide over level histogram.
429
 
bool AdjustLevelsTool::eventFilter(QObject *obj, QEvent *ev)
 
431
bool AdjustLevelsTool::eventFilter(QObject* obj, QEvent* ev)
430
432
{
431
433
    if ( obj == d->inputLevels )
432
434
    {
440
442
 
441
443
            return false;
442
444
        }
 
445
 
443
446
        if ( ev->type() == QEvent::MouseButtonRelease)
444
447
        {
445
448
            disconnect(d->inputLevels, SIGNAL(leftValueChanged(double)),
456
459
            return false;
457
460
        }
458
461
    }
 
462
 
459
463
    if ( obj == d->outputLevels )
460
464
    {
461
465
        if ( ev->type() == QEvent::MouseButtonPress)
468
472
 
469
473
            return false;
470
474
        }
 
475
 
471
476
        if ( ev->type() == QEvent::MouseButtonRelease)
472
477
        {
473
478
            disconnect(d->outputLevels, SIGNAL(leftValueChanged(double)),
507
512
 
508
513
void AdjustLevelsTool::slotPickerColorButtonActived(int type)
509
514
{
510
 
    if (type == AdjustLevelsToolPriv::NoPicker) return;
 
515
    if (type == AdjustLevelsToolPriv::NoPicker)
 
516
    {
 
517
        return;
 
518
    }
511
519
 
512
520
    d->previewWidget->setCapturePointMode(true);
513
521
}
516
524
{
517
525
    if ( d->pickBlack->isChecked() )
518
526
    {
519
 
       // Black tonal levels point.
520
 
       d->levels->levelsBlackToneAdjustByColors(d->gboxSettings->histogramBox()->channel(), color);
521
 
       d->pickBlack->setChecked(false);
 
527
        // Black tonal levels point.
 
528
        d->levels->levelsBlackToneAdjustByColors(d->gboxSettings->histogramBox()->channel(), color);
 
529
        d->pickBlack->setChecked(false);
522
530
    }
523
531
    else if ( d->pickGray->isChecked() )
524
532
    {
525
 
       // Gray tonal levels point.
526
 
       d->levels->levelsGrayToneAdjustByColors(d->gboxSettings->histogramBox()->channel(), color);
527
 
       d->pickGray->setChecked(false);
 
533
        // Gray tonal levels point.
 
534
        d->levels->levelsGrayToneAdjustByColors(d->gboxSettings->histogramBox()->channel(), color);
 
535
        d->pickGray->setChecked(false);
528
536
    }
529
537
    else if ( d->pickWhite->isChecked() )
530
538
    {
531
 
       // White tonal levels point.
532
 
       d->levels->levelsWhiteToneAdjustByColors(d->gboxSettings->histogramBox()->channel(), color);
533
 
       d->pickWhite->setChecked(false);
 
539
        // White tonal levels point.
 
540
        d->levels->levelsWhiteToneAdjustByColors(d->gboxSettings->histogramBox()->channel(), color);
 
541
        d->pickWhite->setChecked(false);
534
542
    }
535
543
    else
536
544
    {
537
 
       d->levelsHistogramWidget->setHistogramGuideByColor(color);
538
 
       return;
 
545
        d->levelsHistogramWidget->setHistogramGuideByColor(color);
 
546
        return;
539
547
    }
540
548
 
541
549
    // Refresh the current levels config.
671
679
{
672
680
    ChannelType channel = d->gboxSettings->histogramBox()->channel();
673
681
    d->levelsHistogramWidget->setChannelType(channel);
 
682
 
674
683
    switch (channel)
675
684
    {
676
685
        case RedChannel:
741
750
    d->gboxSettings->histogramBox()->histogram()->reset();
742
751
 
743
752
    d->gboxSettings->histogramBox()->setChannel((ChannelType)group.readEntry(d->configHistogramChannelEntry,
744
 
                    (int)LuminosityChannel));
 
753
            (int)LuminosityChannel));
745
754
    d->gboxSettings->histogramBox()->setScale((HistogramScale)group.readEntry(d->configHistogramScaleEntry,
746
 
                    (int)LogScaleHistogram));
 
755
            (int)LogScaleHistogram));
747
756
 
748
757
    // This is mandatory here to set spinbox values because slot connections
749
758
    // can be not set completely at plugin startup.
792
801
void AdjustLevelsTool::slotResetSettings()
793
802
{
794
803
    for (int channel = 0 ; channel < 5 ; ++channel)
 
804
    {
795
805
        d->levels->levelsChannelReset(channel);
 
806
    }
796
807
 
797
808
    // Refresh the current levels config.
798
809
    slotChannelChanged();
804
815
void AdjustLevelsTool::prepareEffect()
805
816
{
806
817
    LevelsContainer settings;
 
818
 
807
819
    for (int i=0 ; i<5 ; ++i)
808
820
    {
809
821
        settings.lInput[i]  = d->levels->getLevelLowInputValue(i);
827
839
    // Update histogram.
828
840
 
829
841
    if (d->destinationPreviewData)
830
 
       delete [] d->destinationPreviewData;
 
842
    {
 
843
        delete [] d->destinationPreviewData;
 
844
    }
831
845
 
832
846
    d->destinationPreviewData = preview.copyBits();
833
847
    d->gboxSettings->histogramBox()->histogram()->updateData(d->destinationPreviewData,
834
 
                                                             preview.width(), preview.height(), preview.sixteenBit(),
835
 
                                                             0, 0, 0, false);
 
848
            preview.width(), preview.height(), preview.sixteenBit(),
 
849
            0, 0, 0, false);
836
850
}
837
851
 
838
852
void AdjustLevelsTool::prepareFinal()
839
853
{
840
854
    LevelsContainer settings;
 
855
 
841
856
    for (int i=0 ; i<5 ; ++i)
842
857
    {
843
858
        settings.lInput[i]  = d->levels->getLevelLowInputValue(i);
862
877
    KUrl loadLevelsFile;
863
878
 
864
879
    loadLevelsFile = KFileDialog::getOpenUrl(KGlobalSettings::documentPath(),
865
 
                                             QString( "*" ), kapp->activeWindow(),
866
 
                                             QString( i18n("Select Gimp Levels File to Load")) );
 
880
                     QString( "*" ), kapp->activeWindow(),
 
881
                     QString( i18n("Select Gimp Levels File to Load")) );
 
882
 
867
883
    if ( loadLevelsFile.isEmpty() )
868
 
       return;
 
884
    {
 
885
        return;
 
886
    }
869
887
 
870
888
    if ( d->levels->loadLevelsFromGimpLevelsFile( loadLevelsFile ) == false )
871
889
    {
872
 
       KMessageBox::error(kapp->activeWindow(),
873
 
                          i18n("Cannot load from the Gimp levels text file."));
874
 
       return;
 
890
        KMessageBox::error(kapp->activeWindow(),
 
891
                           i18n("Cannot load from the Gimp levels text file."));
 
892
        return;
875
893
    }
876
894
 
877
895
    // Refresh the current levels config.
885
903
    KUrl saveLevelsFile;
886
904
 
887
905
    saveLevelsFile = KFileDialog::getSaveUrl(KGlobalSettings::documentPath(),
888
 
                                             QString( "*" ), kapp->activeWindow(),
889
 
                                             QString( i18n("Gimp Levels File to Save")) );
 
906
                     QString( "*" ), kapp->activeWindow(),
 
907
                     QString( i18n("Gimp Levels File to Save")) );
 
908
 
890
909
    if ( saveLevelsFile.isEmpty() )
891
 
       return;
 
910
    {
 
911
        return;
 
912
    }
892
913
 
893
914
    if ( d->levels->saveLevelsToGimpLevelsFile( saveLevelsFile ) == false )
894
915
    {
895
 
       KMessageBox::error(kapp->activeWindow(),
896
 
                          i18n("Cannot save to the Gimp levels text file."));
897
 
       return;
 
916
        KMessageBox::error(kapp->activeWindow(),
 
917
                           i18n("Cannot save to the Gimp levels text file."));
 
918
        return;
898
919
    }
899
920
 
900
921
    // Refresh the current levels config.