169
169
// --------------------------------------------------------
171
171
AdjustLevelsTool::AdjustLevelsTool(QObject* parent)
172
: EditorToolThreaded(parent),
173
d(new AdjustLevelsToolPriv)
172
: EditorToolThreaded(parent),
173
d(new AdjustLevelsToolPriv)
175
175
setObjectName("adjustlevels");
176
176
setToolName(i18n("Adjust Levels"));
206
206
// -------------------------------------------------------------
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);
366
366
connect(d->previewWidget, SIGNAL(signalCapturedPointFromOriginal(const Digikam::DColor&, const QPoint&)),
367
367
this, SLOT(slotSpotColorChanged(const Digikam::DColor&)));
369
connect(d->previewWidget, SIGNAL(spotPositionChangedFromTarget(const Digikam::DColor&, const QPoint&)),
370
this, SLOT(slotColorSelectedFromTarget(const Digikam::DColor&)));
369
connect(d->previewWidget, SIGNAL(spotPositionChangedFromTarget(const Digikam::DColor&, const QPoint&)),
370
this, SLOT(slotColorSelectedFromTarget(const Digikam::DColor&)));
373
373
// -------------------------------------------------------------
374
374
// Color sliders and spinbox slots.
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)
431
433
if ( obj == d->inputLevels )
517
525
if ( d->pickBlack->isChecked() )
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);
523
531
else if ( d->pickGray->isChecked() )
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);
529
537
else if ( d->pickWhite->isChecked() )
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);
537
d->levelsHistogramWidget->setHistogramGuideByColor(color);
545
d->levelsHistogramWidget->setHistogramGuideByColor(color);
541
549
// Refresh the current levels config.
741
750
d->gboxSettings->histogramBox()->histogram()->reset();
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));
748
757
// This is mandatory here to set spinbox values because slot connections
749
758
// can be not set completely at plugin startup.
827
839
// Update histogram.
829
841
if (d->destinationPreviewData)
830
delete [] d->destinationPreviewData;
843
delete [] d->destinationPreviewData;
832
846
d->destinationPreviewData = preview.copyBits();
833
847
d->gboxSettings->histogramBox()->histogram()->updateData(d->destinationPreviewData,
834
preview.width(), preview.height(), preview.sixteenBit(),
848
preview.width(), preview.height(), preview.sixteenBit(),
838
852
void AdjustLevelsTool::prepareFinal()
840
854
LevelsContainer settings;
841
856
for (int i=0 ; i<5 ; ++i)
843
858
settings.lInput[i] = d->levels->getLevelLowInputValue(i);
862
877
KUrl loadLevelsFile;
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")) );
867
883
if ( loadLevelsFile.isEmpty() )
870
888
if ( d->levels->loadLevelsFromGimpLevelsFile( loadLevelsFile ) == false )
872
KMessageBox::error(kapp->activeWindow(),
873
i18n("Cannot load from the Gimp levels text file."));
890
KMessageBox::error(kapp->activeWindow(),
891
i18n("Cannot load from the Gimp levels text file."));
877
895
// Refresh the current levels config.
885
903
KUrl saveLevelsFile;
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")) );
890
909
if ( saveLevelsFile.isEmpty() )
893
914
if ( d->levels->saveLevelsToGimpLevelsFile( saveLevelsFile ) == false )
895
KMessageBox::error(kapp->activeWindow(),
896
i18n("Cannot save to the Gimp levels text file."));
916
KMessageBox::error(kapp->activeWindow(),
917
i18n("Cannot save to the Gimp levels text file."));
900
921
// Refresh the current levels config.