137
137
ImagePropertiesColorsTab::ImagePropertiesColorsTab(QWidget* parent)
138
: KTabWidget(parent), d(new ImagePropertiesColorsTabPriv)
138
: KTabWidget(parent), d(new ImagePropertiesColorsTabPriv)
140
140
// Histogram tab area -----------------------------------------------------
142
QScrollArea *sv = new QScrollArea(this);
142
QScrollArea* sv = new QScrollArea(this);
143
143
sv->setFrameStyle(QFrame::NoFrame);
144
144
sv->setWidgetResizable(true);
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);
150
150
// -------------------------------------------------------------
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>"));
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);
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);
179
179
// -------------------------------------------------------------
181
KVBox *histoBox = new KVBox(histogramPage);
181
KVBox* histoBox = new KVBox(histogramPage);
182
182
d->histogramBox = new HistogramBox(histoBox, Digikam::LRGBAC, true);
184
QLabel *space = new QLabel(histoBox);
184
QLabel* space = new QLabel(histoBox);
185
185
space->setFixedHeight(1);
187
187
// -------------------------------------------------------------
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);
193
193
d->minInterv = new QSpinBox(histogramPage);
211
211
// -------------------------------------------------------------
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 "
217
217
QGridLayout* grid = new QGridLayout(gbox);
219
DTextLabelName *label5 = new DTextLabelName(i18n("Pixels: "), gbox);
219
DTextLabelName* label5 = new DTextLabelName(i18n("Pixels: "), gbox);
220
220
d->labelPixelsValue = new DTextLabelValue(0, gbox);
222
DTextLabelName *label7 = new DTextLabelName(i18n("Count: "), gbox);
222
DTextLabelName* label7 = new DTextLabelName(i18n("Count: "), gbox);
223
223
d->labelCountValue = new DTextLabelValue(0, gbox);
225
DTextLabelName *label4 = new DTextLabelName(i18n("Mean: "), gbox);
225
DTextLabelName* label4 = new DTextLabelName(i18n("Mean: "), gbox);
226
226
d->labelMeanValue = new DTextLabelValue(0, gbox);
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);
231
DTextLabelName *label8 = new DTextLabelName(i18n("Median: "), gbox);
231
DTextLabelName* label8 = new DTextLabelName(i18n("Median: "), gbox);
232
232
d->labelMedianValue = new DTextLabelValue(0, gbox);
234
DTextLabelName *label9 = new DTextLabelName(i18n("Percentile: "), gbox);
234
DTextLabelName* label9 = new DTextLabelName(i18n("Percentile: "), gbox);
235
235
d->labelPercentileValue = new DTextLabelValue(0, gbox);
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);
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);
243
243
grid->addWidget(label5, 0, 0, 1, 1);
288
288
KConfigGroup group = config->group(QString("Image Properties SideBar"));
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()));
353
353
if (d->imageLoaderThread)
354
delete d->imageLoaderThread;
355
delete d->imageLoaderThread;
359
361
void ImagePropertiesColorsTab::setData(const KUrl& url, const QRect& selectionArea,
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
375
// This is necessary to stop computation because d->image.bits() is currently used by
372
376
// threaded histogram algorithm.
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();
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();
445
449
d->imageLoaderThread = new SharedLoadSaveThread();
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&)));
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&)));
454
458
LoadingDescription desc = LoadingDescription(url.toLocalFile());
504
512
void ImagePropertiesColorsTab::slotMoreCompleteLoadingAvailable(const LoadingDescription& oldLoadingDescription,
505
const LoadingDescription& newLoadingDescription)
513
const LoadingDescription& newLoadingDescription)
507
515
if (oldLoadingDescription == d->currentLoadingDescription &&
508
516
newLoadingDescription.equalsOrBetterThan(d->currentLoadingDescription))
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());