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

« back to all changes in this revision

Viewing changes to libs/imageproperties/imagepropertiescolorstab.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:
135
135
};
136
136
 
137
137
ImagePropertiesColorsTab::ImagePropertiesColorsTab(QWidget* parent)
138
 
                        : KTabWidget(parent), d(new ImagePropertiesColorsTabPriv)
 
138
    : KTabWidget(parent), d(new ImagePropertiesColorsTabPriv)
139
139
{
140
140
    // Histogram tab area -----------------------------------------------------
141
141
 
142
 
    QScrollArea *sv = new QScrollArea(this);
 
142
    QScrollArea* sv = new QScrollArea(this);
143
143
    sv->setFrameStyle(QFrame::NoFrame);
144
144
    sv->setWidgetResizable(true);
145
145
 
146
146
    QWidget* histogramPage = new QWidget(sv->viewport());
147
 
    QGridLayout *topLayout = new QGridLayout(histogramPage);
 
147
    QGridLayout* topLayout = new QGridLayout(histogramPage);
148
148
    sv->setWidget(histogramPage);
149
149
 
150
150
    // -------------------------------------------------------------
151
151
 
152
152
    d->regionBox       = new QWidget(histogramPage);
153
 
    QHBoxLayout *hlay2 = new QHBoxLayout(d->regionBox);
 
153
    QHBoxLayout* hlay2 = new QHBoxLayout(d->regionBox);
154
154
    d->regionBG        = new QButtonGroup(d->regionBox);
155
155
    d->regionBG->setExclusive(true);
156
156
    d->regionBox->hide();
159
159
                                     "<b>Selection</b>: Compute histogram using the current image "
160
160
                                     "selection.</p>"));
161
161
 
162
 
    QPushButton *fullImageButton = new QPushButton(d->regionBox);
 
162
    QPushButton* fullImageButton = new QPushButton(d->regionBox);
163
163
    fullImageButton->setToolTip( i18n( "Full Image" ) );
164
164
    fullImageButton->setIcon(QPixmap(KStandardDirs::locate("data", "digikam/data/image-full.png")));
165
165
    fullImageButton->setCheckable(true);
166
166
    d->regionBG->addButton(fullImageButton, FullImageHistogram);
167
167
 
168
 
    QPushButton *SelectionImageButton = new QPushButton(d->regionBox);
 
168
    QPushButton* SelectionImageButton = new QPushButton(d->regionBox);
169
169
    SelectionImageButton->setToolTip( i18n( "Selection" ) );
170
170
    SelectionImageButton->setIcon(QPixmap(KStandardDirs::locate("data", "digikam/data/image-selection.png")));
171
171
    SelectionImageButton->setCheckable(true);
178
178
 
179
179
    // -------------------------------------------------------------
180
180
 
181
 
    KVBox *histoBox    = new KVBox(histogramPage);
 
181
    KVBox* histoBox    = new KVBox(histogramPage);
182
182
    d->histogramBox    = new HistogramBox(histoBox, Digikam::LRGBAC, true);
183
183
 
184
 
    QLabel *space = new QLabel(histoBox);
 
184
    QLabel* space = new QLabel(histoBox);
185
185
    space->setFixedHeight(1);
186
186
 
187
187
    // -------------------------------------------------------------
188
188
 
189
 
    QHBoxLayout *hlay3 = new QHBoxLayout();
190
 
    QLabel *label3     = new QLabel(i18n("Range:"), histogramPage);
 
189
    QHBoxLayout* hlay3 = new QHBoxLayout();
 
190
    QLabel* label3     = new QLabel(i18n("Range:"), histogramPage);
191
191
    label3->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
192
192
 
193
193
    d->minInterv = new QSpinBox(histogramPage);
210
210
 
211
211
    // -------------------------------------------------------------
212
212
 
213
 
    QGroupBox *gbox = new QGroupBox(i18n("Statistics"), histogramPage);
 
213
    QGroupBox* gbox = new QGroupBox(i18n("Statistics"), histogramPage);
214
214
    gbox->setWhatsThis(i18n("Here you can see the statistical results calculated from the "
215
215
                            "selected histogram part. These values are available for all "
216
216
                            "channels."));
217
217
    QGridLayout* grid       = new QGridLayout(gbox);
218
218
 
219
 
    DTextLabelName *label5  = new DTextLabelName(i18n("Pixels: "), gbox);
 
219
    DTextLabelName* label5  = new DTextLabelName(i18n("Pixels: "), gbox);
220
220
    d->labelPixelsValue     = new DTextLabelValue(0, gbox);
221
221
 
222
 
    DTextLabelName *label7  = new DTextLabelName(i18n("Count: "), gbox);
 
222
    DTextLabelName* label7  = new DTextLabelName(i18n("Count: "), gbox);
223
223
    d->labelCountValue      = new DTextLabelValue(0, gbox);
224
224
 
225
 
    DTextLabelName *label4  = new DTextLabelName(i18n("Mean: "), gbox);
 
225
    DTextLabelName* label4  = new DTextLabelName(i18n("Mean: "), gbox);
226
226
    d->labelMeanValue       = new DTextLabelValue(0, gbox);
227
227
 
228
 
    DTextLabelName *label6  = new DTextLabelName(i18n("Std. deviation: "), gbox);
 
228
    DTextLabelName* label6  = new DTextLabelName(i18n("Std. deviation: "), gbox);
229
229
    d->labelStdDevValue     = new DTextLabelValue(0, gbox);
230
230
 
231
 
    DTextLabelName *label8  = new DTextLabelName(i18n("Median: "), gbox);
 
231
    DTextLabelName* label8  = new DTextLabelName(i18n("Median: "), gbox);
232
232
    d->labelMedianValue     = new DTextLabelValue(0, gbox);
233
233
 
234
 
    DTextLabelName *label9  = new DTextLabelName(i18n("Percentile: "), gbox);
 
234
    DTextLabelName* label9  = new DTextLabelName(i18n("Percentile: "), gbox);
235
235
    d->labelPercentileValue = new DTextLabelValue(0, gbox);
236
236
 
237
 
    DTextLabelName *label10 = new DTextLabelName(i18n("Color depth: "), gbox);
 
237
    DTextLabelName* label10 = new DTextLabelName(i18n("Color depth: "), gbox);
238
238
    d->labelColorDepth      = new DTextLabelValue(0, gbox);
239
239
 
240
 
    DTextLabelName *label11 = new DTextLabelName(i18n("Alpha Channel: "), gbox);
 
240
    DTextLabelName* label11 = new DTextLabelName(i18n("Alpha Channel: "), gbox);
241
241
    d->labelAlphaChannel    = new DTextLabelValue(0, gbox);
242
242
 
243
243
    grid->addWidget(label5,                  0, 0, 1, 1);
274
274
 
275
275
    // ICC Profiles tab area ---------------------------------------
276
276
 
277
 
    QScrollArea *sv2 = new QScrollArea(this);
 
277
    QScrollArea* sv2 = new QScrollArea(this);
278
278
    sv2->setFrameStyle(QFrame::NoFrame);
279
279
    sv2->setWidgetResizable(true);
280
280
 
288
288
    KConfigGroup group        = config->group(QString("Image Properties SideBar"));
289
289
 
290
290
    setCurrentIndex(group.readEntry("ImagePropertiesColors Tab",
291
 
                    (int)ImagePropertiesColorsTabPriv::HISTOGRAM));
 
291
                                    (int)ImagePropertiesColorsTabPriv::HISTOGRAM));
292
292
    d->iccProfileWidget->setMode(group.readEntry("ICC Level", (int)ICCProfileWidget::CUSTOM));
293
293
    d->iccProfileWidget->setCurrentItemByKey(group.readEntry("Current ICC Item", QString()));
294
294
 
351
351
    config->sync();
352
352
 
353
353
    if (d->imageLoaderThread)
354
 
       delete d->imageLoaderThread;
 
354
    {
 
355
        delete d->imageLoaderThread;
 
356
    }
355
357
 
356
358
    delete d;
357
359
}
358
360
 
359
361
void ImagePropertiesColorsTab::setData(const KUrl& url, const QRect& selectionArea,
360
 
                                       DImg *img)
 
362
                                       DImg* img)
361
363
{
362
364
    // We might be getting duplicate events from AlbumIconView,
363
365
    // which will cause all sorts of duplicate work.
366
368
    // So filter here, before the stopHistogramComputation!
367
369
    // But do not filter if current path is null, as it would not disable the widget on first run.
368
370
    if (!img && !d->currentFilePath.isNull() && url.toLocalFile() == d->currentFilePath)
 
371
    {
369
372
        return;
 
373
    }
370
374
 
371
375
    // This is necessary to stop computation because d->image.bits() is currently used by
372
376
    // threaded histogram algorithm.
388
392
 
389
393
    if (url.isEmpty())
390
394
    {
391
 
       setEnabled(false);
392
 
       d->image.reset();
393
 
       return;
 
395
        setEnabled(false);
 
396
        d->image.reset();
 
397
        return;
394
398
    }
395
399
 
396
400
    d->selectionArea = selectionArea;
415
419
            {
416
420
                d->imageSelection = d->image.copy(d->selectionArea);
417
421
                d->histogramBox->histogram()->updateData(d->image.bits(), d->image.width(), d->image.height(),
418
 
                                               d->image.sixteenBit(), d->imageSelection.bits(),
419
 
                                               d->imageSelection.width(), d->imageSelection.height());
 
422
                        d->image.sixteenBit(), d->imageSelection.bits(),
 
423
                        d->imageSelection.width(), d->imageSelection.height());
420
424
                d->regionBox->show();
421
425
                updateInformation();
422
426
            }
423
427
            else
424
428
            {
425
429
                d->histogramBox->histogram()->updateData(d->image.bits(), d->image.width(),
426
 
                                               d->image.height(), d->image.sixteenBit());
 
430
                        d->image.height(), d->image.sixteenBit());
427
431
                d->regionBox->hide();
428
432
                updateInformation();
429
433
            }
444
448
    {
445
449
        d->imageLoaderThread = new SharedLoadSaveThread();
446
450
 
447
 
        connect(d->imageLoaderThread, SIGNAL(signalImageLoaded(const LoadingDescription &, const DImg&)),
448
 
                this, SLOT(slotLoadImageFromUrlComplete(const LoadingDescription &, const DImg&)));
 
451
        connect(d->imageLoaderThread, SIGNAL(signalImageLoaded(const LoadingDescription&, const DImg&)),
 
452
                this, SLOT(slotLoadImageFromUrlComplete(const LoadingDescription&, const DImg&)));
449
453
 
450
 
        connect(d->imageLoaderThread, SIGNAL(signalMoreCompleteLoadingAvailable(const LoadingDescription &, const LoadingDescription &)),
451
 
                this, SLOT(slotMoreCompleteLoadingAvailable(const LoadingDescription &, const LoadingDescription &)));
 
454
        connect(d->imageLoaderThread, SIGNAL(signalMoreCompleteLoadingAvailable(const LoadingDescription&, const LoadingDescription&)),
 
455
                this, SLOT(slotMoreCompleteLoadingAvailable(const LoadingDescription&, const LoadingDescription&)));
452
456
    }
453
457
 
454
458
    LoadingDescription desc = LoadingDescription(url.toLocalFile());
463
467
    }
464
468
 
465
469
    if (d->currentLoadingDescription.equalsOrBetterThan(desc))
 
470
    {
466
471
        return;
 
472
    }
467
473
 
468
474
    d->currentFilePath = desc.filePath;
469
475
    d->currentLoadingDescription = desc;
480
486
{
481
487
    // Discard any leftover messages from previous, possibly aborted loads
482
488
    if ( !loadingDescription.equalsOrBetterThan(d->currentLoadingDescription) )
 
489
    {
483
490
        return;
 
491
    }
484
492
 
485
493
    if ( !img.isNull() )
486
494
    {
502
510
}
503
511
 
504
512
void ImagePropertiesColorsTab::slotMoreCompleteLoadingAvailable(const LoadingDescription& oldLoadingDescription,
505
 
                                                                const LoadingDescription& newLoadingDescription)
 
513
        const LoadingDescription& newLoadingDescription)
506
514
{
507
515
    if (oldLoadingDescription == d->currentLoadingDescription &&
508
516
        newLoadingDescription.equalsOrBetterThan(d->currentLoadingDescription))
520
528
void ImagePropertiesColorsTab::setSelection(const QRect& selectionArea)
521
529
{
522
530
    if (selectionArea == d->selectionArea)
 
531
    {
523
532
        return;
 
533
    }
524
534
 
525
535
    // This is necessary to stop computation because d->image.bits() is currently used by
526
536
    // threaded histogram algorithm.
531
541
    {
532
542
        d->imageSelection = d->image.copy(d->selectionArea);
533
543
        d->histogramBox->histogram()->updateSelectionData(d->imageSelection.bits(), d->imageSelection.width(),
534
 
                                                d->imageSelection.height(), d->imageSelection.sixteenBit());
 
544
                d->imageSelection.height(), d->imageSelection.sixteenBit());
535
545
        d->regionBox->show();
536
546
        slotRenderingChanged(d->regionBG->checkedId());
537
547
    }
549
559
    slotScaleChanged();
550
560
 
551
561
    if (d->selectionArea.isValid())
552
 
       slotRenderingChanged(d->regionBG->checkedId());
 
562
    {
 
563
        slotRenderingChanged(d->regionBG->checkedId());
 
564
    }
553
565
}
554
566
 
555
567
void ImagePropertiesColorsTab::slotHistogramComputationFailed()
581
593
 
582
594
    // make the one control "push" the other
583
595
    if (min == d->maxInterv->value()+1)
 
596
    {
584
597
        d->maxInterv->setValue(min);
 
598
    }
 
599
 
585
600
    d->maxInterv->setMinimum(min-1);
586
601
    d->histogramBox->histogram()->slotMinValueChanged(min);
587
602
    updateStatistics();
590
605
void ImagePropertiesColorsTab::slotMaxValueChanged(int max)
591
606
{
592
607
    if (max == d->minInterv->value()-1)
 
608
    {
593
609
        d->minInterv->setValue(max);
 
610
    }
 
611
 
594
612
    d->minInterv->setMaximum(max+1);
595
613
    d->histogramBox->histogram()->slotMaxValueChanged(max);
596
614
    updateStatistics();
627
645
 
628
646
void ImagePropertiesColorsTab::updateStatistics()
629
647
{
630
 
    ImageHistogram *renderedHistogram = d->histogramBox->histogram()->currentHistogram();
 
648
    ImageHistogram* renderedHistogram = d->histogramBox->histogram()->currentHistogram();
 
649
 
631
650
    if (!renderedHistogram)
 
651
    {
632
652
        return;
 
653
    }
633
654
 
634
655
    QString value;
635
656
    int min = d->minInterv->value();