File indexing completed on 2025-03-09 04:09:46

0001 /** ===========================================================
0002  * @file
0003  *
0004  * This file is a part of digiKam project
0005  * <a href="https://www.digikam.org">https://www.digikam.org</a>
0006  *
0007  * @date   2006-09-13
0008  * @brief  LibRaw settings widgets
0009  *
0010  * @author Copyright (C) 2006-2015 by Gilles Caulier
0011  *         <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
0012  * @author Copyright (C) 2006-2011 by Marcel Wiesweg
0013  *         <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a>
0014  * @author Copyright (C) 2007-2008 by Guillaume Castagnino
0015  *         <a href="mailto:casta at xwing dot info">casta at xwing dot info</a>
0016  *
0017  * This program is free software; you can redistribute it
0018  * and/or modify it under the terms of the GNU General
0019  * Public License as published by the Free Software Foundation;
0020  * either version 2, or (at your option)
0021  * any later version.
0022  *
0023  * This program is distributed in the hope that it will be useful,
0024  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0025  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0026  * GNU General Public License for more details.
0027  *
0028  * ============================================================ */
0029 
0030 #define OPTIONFIXCOLORSHIGHLIGHTSENTRY "FixColorsHighlights"
0031 #define OPTIONDECODESIXTEENBITENTRY "SixteenBitsImage"
0032 #define OPTIONWHITEBALANCEENTRY "White Balance"
0033 #define OPTIONCUSTOMWHITEBALANCEENTRY "Custom White Balance"
0034 #define OPTIONCUSTOMWBGREENENTRY "Custom White Balance Green"
0035 #define OPTIONFOURCOLORRGBENTRY "Four Color RGB"
0036 #define OPTIONUNCLIPCOLORSENTRY "Unclip Color"
0037 // Wrong spelling, but do not fix it since it is a configuration key
0038 // krazy:cond=spelling
0039 #define OPTIONDONTSTRETCHPIXELSENTRY "Dont Stretch Pixels"
0040 // krazy:endcond=spelling
0041 #define OPTIONMEDIANFILTERPASSESENTRY "Median Filter Passes"
0042 #define OPTIONNOISEREDUCTIONTYPEENTRY "Noise Reduction Type"
0043 #define OPTIONNOISEREDUCTIONTHRESHOLDENTRY "Noise Reduction Threshold"
0044 #define OPTIONUSECACORRECTIONENTRY "EnableCACorrection"
0045 #define OPTIONCAREDMULTIPLIERENTRY "caRedMultiplier"
0046 #define OPTIONCABLUEMULTIPLIERENTRY "caBlueMultiplier"
0047 #define OPTIONAUTOBRIGHTNESSENTRY "AutoBrightness"
0048 #define OPTIONDECODINGQUALITYENTRY "Decoding Quality"
0049 #define OPTIONINPUTCOLORSPACEENTRY "Input Color Space"
0050 #define OPTIONOUTPUTCOLORSPACEENTRY "Output Color Space"
0051 #define OPTIONINPUTCOLORPROFILEENTRY "Input Color Profile"
0052 #define OPTIONOUTPUTCOLORPROFILEENTRY "Output Color Profile"
0053 #define OPTIONBRIGHTNESSMULTIPLIERENTRY "Brightness Multiplier"
0054 #define OPTIONUSEBLACKPOINTENTRY "Use Black Point"
0055 #define OPTIONBLACKPOINTENTRY "Black Point"
0056 #define OPTIONUSEWHITEPOINTENTRY "Use White Point"
0057 #define OPTIONWHITEPOINTENTRY "White Point"
0058 
0059 //-- Extended demosaicing settings ----------------------------------------------------------
0060 
0061 #define OPTIONDCBITERATIONSENTRY "Dcb Iterations"
0062 #define OPTIONDCBENHANCEFLENTRY "Dcb Enhance Filter"
0063 #define OPTIONEECIREFINEENTRY "Eeci Refine"
0064 #define OPTIONESMEDPASSESENTRY "Es Median Filter Passes"
0065 #define OPTIONNRCHROMINANCETHRESHOLDENTRY "Noise Reduction Chrominance Threshold"
0066 #define OPTIONEXPOCORRECTIONENTRY "Expo Correction"
0067 #define OPTIONEXPOCORRECTIONSHIFTENTRY "Expo Correction Shift"
0068 #define OPTIONEXPOCORRECTIONHIGHLIGHTENTRY "Expo Correction Highlight"
0069 
0070 #include "dcrawsettingswidget.h"
0071 
0072 // C++ includes
0073 
0074 #include <cmath>
0075 
0076 // Qt includes
0077 
0078 #include <QCheckBox>
0079 #include <QLabel>
0080 #include <QWhatsThis>
0081 #include <QGridLayout>
0082 #include <QApplication>
0083 #include <QStyle>
0084 #include <QIcon>
0085 #include <QStandardPaths>
0086 
0087 // KDE includes
0088 
0089 #include <klocalizedstring.h>
0090 
0091 // Local includes
0092 
0093 #include "kdcraw.h"
0094 #include "rnuminput.h"
0095 #include "rcombobox.h"
0096 #include "rexpanderbox.h"
0097 #include "libkdcraw_debug.h"
0098 
0099 #include <kis_icon_utils.h>
0100 
0101 namespace KDcrawIface
0102 {
0103 
0104 class Q_DECL_HIDDEN DcrawSettingsWidget::Private
0105 {
0106 public:
0107 
0108     Private()
0109     {
0110         autoBrightnessBox              = 0;
0111         sixteenBitsImage               = 0;
0112         fourColorCheckBox              = 0;
0113         brightnessLabel                = 0;
0114         brightnessSpinBox              = 0;
0115         blackPointCheckBox             = 0;
0116         blackPointSpinBox              = 0;
0117         whitePointCheckBox             = 0;
0118         whitePointSpinBox              = 0;
0119         whiteBalanceComboBox           = 0;
0120         whiteBalanceLabel              = 0;
0121         customWhiteBalanceSpinBox      = 0;
0122         customWhiteBalanceLabel        = 0;
0123         customWhiteBalanceGreenSpinBox = 0;
0124         customWhiteBalanceGreenLabel   = 0;
0125         unclipColorLabel               = 0;
0126         dontStretchPixelsCheckBox      = 0;
0127         RAWQualityComboBox             = 0;
0128         RAWQualityLabel                = 0;
0129         noiseReductionComboBox         = 0;
0130         NRSpinBox1                     = 0;
0131         NRSpinBox2                     = 0;
0132         NRLabel1                       = 0;
0133         NRLabel2                       = 0;
0134         enableCACorrectionBox          = 0;
0135         autoCACorrectionBox            = 0;
0136         caRedMultSpinBox               = 0;
0137         caBlueMultSpinBox              = 0;
0138         caRedMultLabel                 = 0;
0139         caBlueMultLabel                = 0;
0140         unclipColorComboBox            = 0;
0141         reconstructLabel               = 0;
0142         reconstructSpinBox             = 0;
0143         outputColorSpaceLabel          = 0;
0144         outputColorSpaceComboBox       = 0;
0145         demosaicingSettings            = 0;
0146         whiteBalanceSettings           = 0;
0147         correctionsSettings            = 0;
0148         colormanSettings               = 0;
0149         medianFilterPassesSpinBox      = 0;
0150         medianFilterPassesLabel        = 0;
0151         inIccUrlEdit                   = 0;
0152         outIccUrlEdit                  = 0;
0153         inputColorSpaceLabel           = 0;
0154         inputColorSpaceComboBox        = 0;
0155         fixColorsHighlightsBox         = 0;
0156         refineInterpolationBox         = 0;
0157         noiseReductionLabel            = 0;
0158         expoCorrectionBox              = 0;
0159         expoCorrectionShiftSpinBox     = 0;
0160         expoCorrectionHighlightSpinBox = 0;
0161         expoCorrectionShiftLabel       = 0;
0162         expoCorrectionHighlightLabel   = 0;
0163     }
0164 
0165     /** Convert Exposure correction shift E.V value from GUI to Linear value needs by libraw decoder.
0166      */
0167     double shiftExpoFromEvToLinear(double ev) const
0168     {
0169         // From GUI : -2.0EV => 0.25
0170         //            +3.0EV => 8.00
0171         return (1.55*ev + 3.35);
0172     }
0173 
0174     /** Convert Exposure correction shift Linear value from liraw decoder to E.V value needs by GUI.
0175      */
0176     double shiftExpoFromLinearToEv(double lin) const
0177     {
0178         // From GUI : 0.25 => -2.0EV
0179         //            8.00 => +3.0EV
0180         return ((lin-3.35) / 1.55);
0181     }
0182 
0183 public:
0184 
0185     QWidget*         demosaicingSettings;
0186     QWidget*         whiteBalanceSettings;
0187     QWidget*         correctionsSettings;
0188     QWidget*         colormanSettings;
0189 
0190     QLabel*          whiteBalanceLabel;
0191     QLabel*          customWhiteBalanceLabel;
0192     QLabel*          customWhiteBalanceGreenLabel;
0193     QLabel*          brightnessLabel;
0194     QLabel*          RAWQualityLabel;
0195     QLabel*          NRLabel1;
0196     QLabel*          NRLabel2;
0197     QLabel*          caRedMultLabel;
0198     QLabel*          caBlueMultLabel;
0199     QLabel*          unclipColorLabel;
0200     QLabel*          reconstructLabel;
0201     QLabel*          inputColorSpaceLabel;
0202     QLabel*          outputColorSpaceLabel;
0203     QLabel*          medianFilterPassesLabel;
0204     QLabel*          noiseReductionLabel;
0205     QLabel*          expoCorrectionShiftLabel;
0206     QLabel*          expoCorrectionHighlightLabel;
0207 
0208     QCheckBox*       blackPointCheckBox;
0209     QCheckBox*       whitePointCheckBox;
0210     QCheckBox*       sixteenBitsImage;
0211     QCheckBox*       autoBrightnessBox;
0212     QCheckBox*       fourColorCheckBox;
0213     QCheckBox*       dontStretchPixelsCheckBox;
0214     QCheckBox*       enableCACorrectionBox;
0215     QCheckBox*       autoCACorrectionBox;
0216     QCheckBox*       fixColorsHighlightsBox;
0217     QCheckBox*       refineInterpolationBox;
0218     QCheckBox*       expoCorrectionBox;
0219 
0220     RFileSelector*   inIccUrlEdit;
0221     RFileSelector*   outIccUrlEdit;
0222 
0223     RComboBox*       noiseReductionComboBox;
0224     RComboBox*       whiteBalanceComboBox;
0225     RComboBox*       RAWQualityComboBox;
0226     RComboBox*       unclipColorComboBox;
0227     RComboBox*       inputColorSpaceComboBox;
0228     RComboBox*       outputColorSpaceComboBox;
0229 
0230     RIntNumInput*    customWhiteBalanceSpinBox;
0231     RIntNumInput*    reconstructSpinBox;
0232     RIntNumInput*    blackPointSpinBox;
0233     RIntNumInput*    whitePointSpinBox;
0234     RIntNumInput*    NRSpinBox1;
0235     RIntNumInput*    NRSpinBox2;
0236     RIntNumInput*    medianFilterPassesSpinBox;
0237 
0238     RDoubleNumInput* customWhiteBalanceGreenSpinBox;
0239     RDoubleNumInput* caRedMultSpinBox;
0240     RDoubleNumInput* caBlueMultSpinBox;
0241     RDoubleNumInput* brightnessSpinBox;
0242     RDoubleNumInput* expoCorrectionShiftSpinBox;
0243     RDoubleNumInput* expoCorrectionHighlightSpinBox;
0244 };
0245 
0246 DcrawSettingsWidget::DcrawSettingsWidget(QWidget* const parent, int advSettings)
0247     : RExpanderBox(parent), d(new Private)
0248 {
0249     setup(advSettings);
0250 }
0251 
0252 void DcrawSettingsWidget::setup(int advSettings)
0253 {
0254     setObjectName( QLatin1String("DCRawSettings Expander" ));
0255 
0256     // ---------------------------------------------------------------
0257     // DEMOSAICING Settings panel
0258 
0259     d->demosaicingSettings               = new QWidget(this);
0260     QGridLayout* const demosaicingLayout = new QGridLayout(d->demosaicingSettings);
0261 
0262     int line = 0;
0263 
0264     d->sixteenBitsImage = new QCheckBox(i18nc("@option:check", "16 bits color depth"), d->demosaicingSettings);
0265     d->sixteenBitsImage->setToolTip(i18nc("@info:whatsthis", "<p>If enabled, all RAW files will "
0266                                 "be decoded in 16-bit color depth using a linear gamma curve. To "
0267                                 "prevent dark picture rendering in the editor, it is recommended to "
0268                                 "use Color Management in this mode.</p>"
0269                                 "<p>If disabled, all RAW files will be decoded in 8-bit color "
0270                                 "depth with a BT.709 gamma curve and a 99th-percentile white point. "
0271                                 "This mode is faster than 16-bit decoding.</p>"));
0272     demosaicingLayout->addWidget(d->sixteenBitsImage, 0, 0, 1, 2);
0273 
0274     if (advSettings & SIXTEENBITS)
0275     {
0276         d->sixteenBitsImage->show();
0277         line = 1;
0278     }
0279     else
0280     {
0281         d->sixteenBitsImage->hide();
0282     }
0283 
0284     d->fourColorCheckBox = new QCheckBox(i18nc("@option:check", "Interpolate RGB as four colors"), d->demosaicingSettings);
0285     d->fourColorCheckBox->setToolTip(i18nc("@info:whatsthis", "<title>Interpolate RGB as four "
0286                                 "colors</title>"
0287                                 "<p>The default is to assume that all green pixels are the same. "
0288                                 "If even-row green pixels are more sensitive to ultraviolet light "
0289                                 "than odd-row this difference causes a mesh pattern in the output; "
0290                                 "using this option solves this problem with minimal loss of detail.</p>"
0291                                 "<p>To resume, this option blurs the image a little, but it "
0292                                 "eliminates false 2x2 mesh patterns with VNG quality method or "
0293                                 "mazes with AHD quality method.</p>"));
0294     demosaicingLayout->addWidget(d->fourColorCheckBox, line, 0, 1, line == 0 ? 2 : 3);
0295     line++;
0296 
0297     QLabel* const dcrawVersion = new QLabel(d->demosaicingSettings);
0298     dcrawVersion->setAlignment(Qt::AlignRight);
0299     dcrawVersion->setToolTip(i18nc("@info:tooltip", "Visit LibRaw project website"));
0300     dcrawVersion->setOpenExternalLinks(true);
0301     dcrawVersion->setTextFormat(Qt::RichText);
0302     dcrawVersion->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
0303     dcrawVersion->setText(QString::fromLatin1("<a href=\"%1\">%2</a>")
0304                           .arg(QLatin1String("https://www.libraw.org"))
0305                           .arg(QString::fromLatin1("libraw %1").arg(KDcraw::librawVersion())));
0306 
0307     demosaicingLayout->addWidget(dcrawVersion, 0, 2, 1, 1);
0308 
0309     d->dontStretchPixelsCheckBox  = new QCheckBox(i18nc("@option:check", "Do not stretch or rotate pixels"), d->demosaicingSettings);
0310     d->dontStretchPixelsCheckBox->setToolTip(i18nc("@info:whatsthis",
0311                                 "<title>Do not stretch or rotate pixels</title>"
0312                                 "<p>For Fuji Super CCD cameras, show the image tilted 45 degrees. "
0313                                 "For cameras with non-square pixels, do not stretch the image to "
0314                                 "its correct aspect ratio. In any case, this option guarantees that "
0315                                 "each output pixel corresponds to one RAW pixel.</p>"));
0316     demosaicingLayout->addWidget(d->dontStretchPixelsCheckBox, line, 0, 1, 3);
0317     line++;
0318 
0319     d->RAWQualityLabel    = new QLabel(i18nc("@label:listbox", "Quality:"), d->demosaicingSettings);
0320     d->RAWQualityComboBox = new RComboBox(d->demosaicingSettings);
0321 
0322     // Original dcraw demosaicing methods
0323     d->RAWQualityComboBox->insertItem(RawDecodingSettings::BILINEAR, i18nc("@item:inlistbox Quality", "Bilinear"));
0324     d->RAWQualityComboBox->insertItem(RawDecodingSettings::VNG,      i18nc("@item:inlistbox Quality", "VNG"));
0325     d->RAWQualityComboBox->insertItem(RawDecodingSettings::PPG,      i18nc("@item:inlistbox Quality", "PPG"));
0326     d->RAWQualityComboBox->insertItem(RawDecodingSettings::AHD,      i18nc("@item:inlistbox Quality", "AHD"));
0327 
0328     // Extended demosaicing method from GPL2 pack
0329     d->RAWQualityComboBox->insertItem(RawDecodingSettings::DCB,      i18nc("@item:inlistbox Quality", "DCB"));
0330     d->RAWQualityComboBox->insertItem(RawDecodingSettings::PL_AHD,   i18nc("@item:inlistbox Quality", "AHD v2"));
0331     d->RAWQualityComboBox->insertItem(RawDecodingSettings::AFD,      i18nc("@item:inlistbox Quality", "AFD"));
0332     d->RAWQualityComboBox->insertItem(RawDecodingSettings::VCD,      i18nc("@item:inlistbox Quality", "VCD"));
0333     d->RAWQualityComboBox->insertItem(RawDecodingSettings::VCD_AHD,  i18nc("@item:inlistbox Quality", "VCD & AHD"));
0334     d->RAWQualityComboBox->insertItem(RawDecodingSettings::LMMSE,    i18nc("@item:inlistbox Quality", "LMMSE"));
0335     // Extended demosaicing method from GPL3 pack
0336     d->RAWQualityComboBox->insertItem(RawDecodingSettings::AMAZE,    i18nc("@item:inlistbox Quality", "AMaZE"));
0337 
0338     // If Libraw do not support GPL2 pack, disable entries relevant.
0339     if (!KDcraw::librawUseGPL2DemosaicPack())
0340     {
0341         for (int i=RawDecodingSettings::DCB ; i <=RawDecodingSettings::LMMSE ; ++i)
0342             d->RAWQualityComboBox->combo()->setItemData(i, false, Qt::UserRole-1);
0343     }
0344 
0345     // If Libraw do not support GPL3 pack, disable entries relevant.
0346     if (!KDcraw::librawUseGPL3DemosaicPack())
0347     {
0348         d->RAWQualityComboBox->combo()->setItemData(RawDecodingSettings::AMAZE, false, Qt::UserRole-1);
0349     }
0350 
0351     d->RAWQualityComboBox->setDefaultIndex(RawDecodingSettings::BILINEAR);
0352     d->RAWQualityComboBox->setCurrentIndex(RawDecodingSettings::BILINEAR);
0353     d->RAWQualityComboBox->setToolTip(i18nc("@info:whatsthis", "<title>Quality (interpolation)</title>"
0354                                 "<p>Select here the demosaicing method to use when decoding RAW "
0355                                 "images. A demosaicing algorithm is a digital image process used to "
0356                                 "interpolate a complete image from the partial raw data received "
0357                                 "from the color-filtered image sensor, internal to many digital "
0358                                 "cameras, in form of a matrix of colored pixels. Also known as CFA "
0359                                 "interpolation or color reconstruction, another common spelling is "
0360                                 "demosaicing. The following methods are available for demosaicing "
0361                                 "RAW images:</p>"
0362 
0363                                 // Original dcraw demosaicing methods
0364 
0365                                 "<p><ul><li><emphasis strong='true'>Bilinear</emphasis>: use "
0366                                 "high-speed but low-quality bilinear interpolation (default - for "
0367                                 "slow computers). In this method, the red value of a non-red pixel "
0368                                 "is computed as the average of the adjacent red pixels, and similarly "
0369                                 "for blue and green.</li>"
0370 
0371                                 "<li><emphasis strong='true'>VNG</emphasis>: use Variable Number "
0372                                 "of Gradients interpolation. This method computes gradients near "
0373                                 "the pixel of interest and uses the lower gradients (representing "
0374                                 "smoother and more similar parts of the image) to make an estimate.</li>"
0375 
0376                                 "<li><emphasis strong='true'>PPG</emphasis>: use Patterned-Pixel-"
0377                                 "Grouping interpolation. Pixel Grouping uses assumptions about "
0378                                 "natural scenery in making estimates. It has fewer color artifacts "
0379                                 "on natural images than the Variable Number of Gradients method.</li>"
0380 
0381                                 "<li><emphasis strong='true'>AHD</emphasis>: use Adaptive "
0382                                 "Homogeneity-Directed interpolation. This method selects the "
0383                                 "direction of interpolation so as to maximize a homogeneity metric, "
0384                                 "thus typically minimizing color artifacts.</li>"
0385 
0386                                 // Extended demosaicing method
0387 
0388                                 "<li><emphasis strong='true'>DCB</emphasis>: DCB interpolation from "
0389                                 "linuxphoto.org project.</li>"
0390 
0391                                 "<li><emphasis strong='true'>AHD v2</emphasis>: modified AHD "
0392                                 "interpolation using Variance of Color Differences method.</li>"
0393 
0394                                 "<li><emphasis strong='true'>AFD</emphasis>: Adaptive Filtered "
0395                                 "Demosaicing interpolation through 5 pass median filter from PerfectRaw "
0396                                 "project.</li>"
0397 
0398                                 "<li><emphasis strong='true'>VCD</emphasis>: Variance of Color "
0399                                 "Differences interpolation.</li>"
0400 
0401                                 "<li><emphasis strong='true'>VCD & AHD</emphasis>: Mixed demosaicing "
0402                                 "between VCD and AHD.</li>"
0403 
0404                                 "<li><emphasis strong='true'>LMMSE</emphasis>: color demosaicing via "
0405                                 "directional linear minimum mean-square error estimation interpolation "
0406                                 "from PerfectRaw.</li>"
0407 
0408                                 "<li><emphasis strong='true'>AMaZE</emphasis>: Aliasing Minimization "
0409                                 "interpolation and Zipper Elimination to apply color aberration removal "
0410                                 "from RawTherapee project.</li></ul></p>"
0411 
0412                                 "<p>Note: some methods can be unavailable if RAW decoder have been built "
0413                                 "without extension packs.</p>"));
0414 
0415     demosaicingLayout->addWidget(d->RAWQualityLabel,    line, 0, 1, 1);
0416     demosaicingLayout->addWidget(d->RAWQualityComboBox, line, 1, 1, 2);
0417     line++;
0418 
0419     d->medianFilterPassesSpinBox = new RIntNumInput(d->demosaicingSettings);
0420     d->medianFilterPassesSpinBox->setRange(0, 10, 1);
0421     d->medianFilterPassesSpinBox->setDefaultValue(0);
0422     d->medianFilterPassesLabel   = new QLabel(i18nc("@label:slider", "Pass:"), d->whiteBalanceSettings);
0423     d->medianFilterPassesSpinBox->setToolTip( i18nc("@info:whatsthis", "<title>Pass</title>"
0424                                 "<p>Set here the passes used by the median filter applied after "
0425                                 "interpolation to Red-Green and Blue-Green channels.</p>"
0426                                 "<p>This setting is only available for specific Quality options: "
0427                                 "<emphasis strong='true'>Bilinear</emphasis>, <emphasis strong='true'>"
0428                                 "VNG</emphasis>, <emphasis strong='true'>PPG</emphasis>, "
0429                                 "<emphasis strong='true'>AHD</emphasis>, <emphasis strong='true'>"
0430                                 "DCB</emphasis>, and <emphasis strong='true'>VCD & AHD</emphasis>.</p>"));
0431     demosaicingLayout->addWidget(d->medianFilterPassesLabel,   line, 0, 1, 1);
0432     demosaicingLayout->addWidget(d->medianFilterPassesSpinBox, line, 1, 1, 2);
0433     line++;
0434 
0435     d->refineInterpolationBox = new QCheckBox(i18nc("@option:check", "Refine interpolation"), d->demosaicingSettings);
0436     d->refineInterpolationBox->setToolTip(i18nc("@info:whatsthis", "<title>Refine interpolation</title>"
0437                                 "<p>This setting is available only for few Quality options:</p>"
0438                                 "<p><ul><li><emphasis strong='true'>DCB</emphasis>: turn on "
0439                                 "the enhance interpolated colors filter.</li>"
0440                                 "<li><emphasis strong='true'>VCD & AHD</emphasis>: turn on the "
0441                                 "enhanced effective color interpolation (EECI) refine to improve "
0442                                 "sharpness.</li></ul></p>"));
0443     demosaicingLayout->addWidget(d->refineInterpolationBox, line, 0, 1, 2);
0444 
0445     // If Libraw do not support GPL2 pack, disable options relevant.
0446     if (!KDcraw::librawUseGPL2DemosaicPack())
0447     {
0448         d->medianFilterPassesLabel->setEnabled(false);
0449         d->medianFilterPassesSpinBox->setEnabled(false);
0450         d->refineInterpolationBox->setEnabled(false);
0451     }
0452 
0453     addItem(d->demosaicingSettings, KisIconUtils::loadIcon("kdcraw").pixmap(16, 16), i18nc("@label", "Demosaicing"), QString("demosaicing"), true);
0454 
0455     // ---------------------------------------------------------------
0456     // WHITE BALANCE Settings Panel
0457 
0458     d->whiteBalanceSettings               = new QWidget(this);
0459     QGridLayout* const whiteBalanceLayout = new QGridLayout(d->whiteBalanceSettings);
0460 
0461     d->whiteBalanceLabel    = new QLabel(i18nc("@label:listbox", "Method:"), d->whiteBalanceSettings);
0462     d->whiteBalanceComboBox = new RComboBox(d->whiteBalanceSettings);
0463     d->whiteBalanceComboBox->insertItem(RawDecodingSettings::NONE,   i18nc("@item:inlistbox", "Default D65"));
0464     d->whiteBalanceComboBox->insertItem(RawDecodingSettings::CAMERA, i18nc("@item:inlistbox", "Camera"));
0465     d->whiteBalanceComboBox->insertItem(RawDecodingSettings::AUTO,   i18nc("@item:inlistbox set while balance automatically", "Automatic"));
0466     d->whiteBalanceComboBox->insertItem(RawDecodingSettings::CUSTOM, i18nc("@item:inlistbox set white balance manually", "Manual"));
0467     d->whiteBalanceComboBox->setDefaultIndex(RawDecodingSettings::CAMERA);
0468     d->whiteBalanceComboBox->setToolTip(i18nc("@info:whatsthis", "<title>White Balance</title>"
0469                                 "<p>Configure the raw white balance:</p>"
0470                                 "<p><ul><li><emphasis strong='true'>Default D65</emphasis>: "
0471                                 "Use a standard daylight D65 white balance.</li>"
0472                                 "<li><emphasis strong='true'>Camera</emphasis>: Use the white "
0473                                 "balance specified by the camera. If not available, reverts to "
0474                                 "default neutral white balance.</li>"
0475                                 "<li><emphasis strong='true'>Automatic</emphasis>: Calculates an "
0476                                 "automatic white balance averaging the entire image.</li>"
0477                                 "<li><emphasis strong='true'>Manual</emphasis>: Set a custom "
0478                                 "temperature and green level values.</li></ul></p>"));
0479 
0480     d->customWhiteBalanceSpinBox = new RIntNumInput(d->whiteBalanceSettings);
0481     d->customWhiteBalanceSpinBox->setRange(2000, 12000, 10);
0482     d->customWhiteBalanceSpinBox->setDefaultValue(6500);
0483     d->customWhiteBalanceLabel   = new QLabel(i18nc("@label:slider", "T(K):"), d->whiteBalanceSettings);
0484     d->customWhiteBalanceSpinBox->setToolTip( i18nc("@info:whatsthis", "<title>Temperature</title>"
0485                                 "<p>Set here the color temperature in Kelvin.</p>"));
0486 
0487     d->customWhiteBalanceGreenSpinBox = new RDoubleNumInput(d->whiteBalanceSettings);
0488     d->customWhiteBalanceGreenSpinBox->setDecimals(2);
0489     d->customWhiteBalanceGreenSpinBox->setRange(0.2, 2.5, 0.01);
0490     d->customWhiteBalanceGreenSpinBox->setDefaultValue(1.0);
0491     d->customWhiteBalanceGreenLabel   = new QLabel(i18nc("@label:slider Green component", "Green:"), d->whiteBalanceSettings);
0492     d->customWhiteBalanceGreenSpinBox->setToolTip(i18nc("@info:whatsthis", "<p>Set here the "
0493                                 "green component to set magenta color cast removal level.</p>"));
0494 
0495     d->unclipColorLabel    = new QLabel(i18nc("@label:listbox", "Highlights:"), d->whiteBalanceSettings);
0496     d->unclipColorComboBox = new RComboBox(d->whiteBalanceSettings);
0497     d->unclipColorComboBox->insertItem(0, i18nc("@item:inlistbox", "Solid white"));
0498     d->unclipColorComboBox->insertItem(1, i18nc("@item:inlistbox", "Unclip"));
0499     d->unclipColorComboBox->insertItem(2, i18nc("@item:inlistbox", "Blend"));
0500     d->unclipColorComboBox->insertItem(3, i18nc("@item:inlistbox", "Rebuild"));
0501     d->unclipColorComboBox->setDefaultIndex(0);
0502     d->unclipColorComboBox->setToolTip(i18nc("@info:whatsthis", "<title>Highlights</title>"
0503                                 "<p>Select here the highlight clipping method:</p>"
0504                                 "<p><ul><li><emphasis strong='true'>Solid white</emphasis>: "
0505                                 "clip all highlights to solid white</li>"
0506                                 "<li><emphasis strong='true'>Unclip</emphasis>: leave highlights "
0507                                 "unclipped in various shades of pink</li>"
0508                                 "<li><emphasis strong='true'>Blend</emphasis>:Blend clipped and "
0509                                 "unclipped values together for a gradual fade to white</li>"
0510                                 "<li><emphasis strong='true'>Rebuild</emphasis>: reconstruct "
0511                                 "highlights using a level value</li></ul></p>"));
0512 
0513     d->reconstructLabel   = new QLabel(i18nc("@label:slider Highlight reconstruct level", "Level:"), d->whiteBalanceSettings);
0514     d->reconstructSpinBox = new RIntNumInput(d->whiteBalanceSettings);
0515     d->reconstructSpinBox->setRange(0, 6, 1);
0516     d->reconstructSpinBox->setDefaultValue(0);
0517     d->reconstructSpinBox->setToolTip(i18nc("@info:whatsthis", "<title>Level</title>"
0518                                 "<p>Specify the reconstruct highlight level. Low values favor "
0519                                 "whites and high values favor colors.</p>"));
0520 
0521     d->expoCorrectionBox = new QCheckBox(i18nc("@option:check", "Exposure Correction (E.V)"), d->whiteBalanceSettings);
0522     d->expoCorrectionBox->setToolTip(i18nc("@info:whatsthis", "<p>Turn on the exposure "
0523                                 "correction before interpolation.</p>"));
0524 
0525     d->expoCorrectionShiftLabel   = new QLabel(i18nc("@label:slider", "Linear Shift:"), d->whiteBalanceSettings);
0526     d->expoCorrectionShiftSpinBox = new RDoubleNumInput(d->whiteBalanceSettings);
0527     d->expoCorrectionShiftSpinBox->setDecimals(2);
0528     d->expoCorrectionShiftSpinBox->setRange(-2.0, 3.0, 0.01);
0529     d->expoCorrectionShiftSpinBox->setDefaultValue(0.0);
0530     d->expoCorrectionShiftSpinBox->setToolTip(i18nc("@info:whatsthis", "<title>Shift</title>"
0531                                 "<p>Linear Shift of exposure correction before interpolation in E.V</p>"));
0532 
0533     d->expoCorrectionHighlightLabel   = new QLabel(i18nc("@label:slider", "Highlight:"), d->whiteBalanceSettings);
0534     d->expoCorrectionHighlightSpinBox = new RDoubleNumInput(d->whiteBalanceSettings);
0535     d->expoCorrectionHighlightSpinBox->setDecimals(2);
0536     d->expoCorrectionHighlightSpinBox->setRange(0.0, 1.0, 0.01);
0537     d->expoCorrectionHighlightSpinBox->setDefaultValue(0.0);
0538     d->expoCorrectionHighlightSpinBox->setToolTip(i18nc("@info:whatsthis", "<title>Highlight</title>"
0539                                 "<p>Amount of highlight preservation for exposure correction "
0540                                 "before interpolation in E.V. Only take effect if Shift Correction is > 1.0 E.V</p>"));
0541 
0542     d->fixColorsHighlightsBox = new QCheckBox(i18nc("@option:check", "Correct false colors in highlights"), d->whiteBalanceSettings);
0543     d->fixColorsHighlightsBox->setToolTip(i18nc("@info:whatsthis", "<p>If enabled, images with "
0544                                 "overblown channels are processed much more accurately, without "
0545                                 "'pink clouds' (and blue highlights under tungsten lamps).</p>"));
0546 
0547     d->autoBrightnessBox = new QCheckBox(i18nc("@option:check", "Auto Brightness"), d->whiteBalanceSettings);
0548     d->autoBrightnessBox->setToolTip(i18nc("@info:whatsthis", "<p>If disable, use a fixed white level "
0549                                 "and ignore the image histogram to adjust brightness.</p>"));
0550 
0551     d->brightnessLabel   = new QLabel(i18nc("@label:slider", "Brightness:"), d->whiteBalanceSettings);
0552     d->brightnessSpinBox = new RDoubleNumInput(d->whiteBalanceSettings);
0553     d->brightnessSpinBox->setDecimals(2);
0554     d->brightnessSpinBox->setRange(0.0, 10.0, 0.01);
0555     d->brightnessSpinBox->setDefaultValue(1.0);
0556     d->brightnessSpinBox->setToolTip(i18nc("@info:whatsthis", "<title>Brightness</title>"
0557                                 "<p>Specify the brightness level of output image. The default "
0558                                 "value is 1.0 (works in 8-bit mode only).</p>"));
0559 
0560     if (! (advSettings & POSTPROCESSING))
0561     {
0562         d->brightnessLabel->hide();
0563         d->brightnessSpinBox->hide();
0564     }
0565 
0566     d->blackPointCheckBox = new QCheckBox(i18nc("@option:check Black point", "Black:"), d->whiteBalanceSettings);
0567     d->blackPointCheckBox->setToolTip(i18nc("@info:whatsthis", "<title>Black point</title>"
0568                                 "<p>Use a specific black point value to decode RAW pictures. If "
0569                                 "you set this option to off, the Black Point value will be "
0570                                 "automatically computed.</p>"));
0571     d->blackPointSpinBox = new RIntNumInput(d->whiteBalanceSettings);
0572     d->blackPointSpinBox->setRange(0, 1000, 1);
0573     d->blackPointSpinBox->setDefaultValue(0);
0574     d->blackPointSpinBox->setToolTip(i18nc("@info:whatsthis", "<title>Black point value</title>"
0575                                 "<p>Specify specific black point value of the output image.</p>"));
0576 
0577     d->whitePointCheckBox = new QCheckBox(i18nc("@option:check White point", "White:"), d->whiteBalanceSettings);
0578     d->whitePointCheckBox->setToolTip(i18nc("@info:whatsthis", "<title>White point</title>"
0579                                 "<p>Use a specific white point value to decode RAW pictures. If "
0580                                 "you set this option to off, the White Point value will be "
0581                                 "automatically computed.</p>"));
0582     d->whitePointSpinBox = new RIntNumInput(d->whiteBalanceSettings);
0583     d->whitePointSpinBox->setRange(0, 20000, 1);
0584     d->whitePointSpinBox->setDefaultValue(0);
0585     d->whitePointSpinBox->setToolTip(i18nc("@info:whatsthis", "<title>White point value</title>"
0586                                 "<p>Specify specific white point value of the output image.</p>"));
0587 
0588     if (! (advSettings & BLACKWHITEPOINTS))
0589     {
0590         d->blackPointCheckBox->hide();
0591         d->blackPointSpinBox->hide();
0592         d->whitePointCheckBox->hide();
0593         d->whitePointSpinBox->hide();
0594     }
0595 
0596     whiteBalanceLayout->addWidget(d->whiteBalanceLabel,              0,  0, 1, 1);
0597     whiteBalanceLayout->addWidget(d->whiteBalanceComboBox,           0,  1, 1, 2);
0598     whiteBalanceLayout->addWidget(d->customWhiteBalanceLabel,        1,  0, 1, 1);
0599     whiteBalanceLayout->addWidget(d->customWhiteBalanceSpinBox,      1,  1, 1, 2);
0600     whiteBalanceLayout->addWidget(d->customWhiteBalanceGreenLabel,   2,  0, 1, 1);
0601     whiteBalanceLayout->addWidget(d->customWhiteBalanceGreenSpinBox, 2,  1, 1, 2);
0602     whiteBalanceLayout->addWidget(d->unclipColorLabel,               3,  0, 1, 1);
0603     whiteBalanceLayout->addWidget(d->unclipColorComboBox,            3,  1, 1, 2);
0604     whiteBalanceLayout->addWidget(d->reconstructLabel,               4,  0, 1, 1);
0605     whiteBalanceLayout->addWidget(d->reconstructSpinBox,             4,  1, 1, 2);
0606     whiteBalanceLayout->addWidget(d->expoCorrectionBox,              5,  0, 1, 2);
0607     whiteBalanceLayout->addWidget(d->expoCorrectionShiftLabel,       6,  0, 1, 1);
0608     whiteBalanceLayout->addWidget(d->expoCorrectionShiftSpinBox,     6,  1, 1, 2);
0609     whiteBalanceLayout->addWidget(d->expoCorrectionHighlightLabel,   7,  0, 1, 1);
0610     whiteBalanceLayout->addWidget(d->expoCorrectionHighlightSpinBox, 7,  1, 1, 2);
0611     whiteBalanceLayout->addWidget(d->fixColorsHighlightsBox,         8,  0, 1, 3);
0612     whiteBalanceLayout->addWidget(d->autoBrightnessBox,              9,  0, 1, 3);
0613     whiteBalanceLayout->addWidget(d->brightnessLabel,                10, 0, 1, 1);
0614     whiteBalanceLayout->addWidget(d->brightnessSpinBox,              10, 1, 1, 2);
0615     whiteBalanceLayout->addWidget(d->blackPointCheckBox,             11, 0, 1, 1);
0616     whiteBalanceLayout->addWidget(d->blackPointSpinBox,              11, 1, 1, 2);
0617     whiteBalanceLayout->addWidget(d->whitePointCheckBox,             12, 0, 1, 1);
0618     whiteBalanceLayout->addWidget(d->whitePointSpinBox,              12, 1, 1, 2);
0619     whiteBalanceLayout->setSpacing(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
0620     whiteBalanceLayout->setMargin(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
0621 
0622     addItem(d->whiteBalanceSettings, KisIconUtils::loadIcon("kdcraw").pixmap(16, 16), i18nc("@label", "White Balance"), QString("whitebalance"), true);
0623 
0624     // ---------------------------------------------------------------
0625     // CORRECTIONS Settings panel
0626 
0627     d->correctionsSettings               = new QWidget(this);
0628     QGridLayout* const correctionsLayout = new QGridLayout(d->correctionsSettings);
0629 
0630     d->noiseReductionLabel    = new QLabel(i18nc("@label:listbox", "Noise reduction:"), d->correctionsSettings);
0631     d->noiseReductionComboBox = new RComboBox(d->colormanSettings);
0632     d->noiseReductionComboBox->insertItem(RawDecodingSettings::NONR,       i18nc("@item:inlistbox Noise Reduction", "None"));
0633     d->noiseReductionComboBox->insertItem(RawDecodingSettings::WAVELETSNR, i18nc("@item:inlistbox Noise Reduction", "Wavelets"));
0634     d->noiseReductionComboBox->insertItem(RawDecodingSettings::FBDDNR,     i18nc("@item:inlistbox Noise Reduction", "FBDD"));
0635     d->noiseReductionComboBox->insertItem(RawDecodingSettings::LINENR,     i18nc("@item:inlistbox Noise Reduction", "CFA Line Denoise"));
0636     d->noiseReductionComboBox->insertItem(RawDecodingSettings::IMPULSENR,  i18nc("@item:inlistbox Noise Reduction", "Impulse Denoise"));
0637     d->noiseReductionComboBox->setDefaultIndex(RawDecodingSettings::NONR);
0638     d->noiseReductionComboBox->setToolTip(i18nc("@info:whatsthis", "<title>Noise Reduction</title>"
0639                                 "<p>Select here the noise reduction method to apply during RAW "
0640                                 "decoding.</p>"
0641                                 "<p><ul><li><emphasis strong='true'>None</emphasis>: no "
0642                                 "noise reduction.</li>"
0643                                 "<li><emphasis strong='true'>Wavelets</emphasis>: wavelets "
0644                                 "correction to erase noise while preserving real detail. It's "
0645                                 "applied after interpolation.</li>"
0646                                 "<li><emphasis strong='true'>FBDD</emphasis>: Fake Before "
0647                                 "Demosaicing Denoising noise reduction. It's applied before "
0648                                 "interpolation.</li>"
0649                                 "<li><emphasis strong='true'>CFA Line Denoise</emphasis>: Banding "
0650                                 "noise suppression. It's applied after interpolation.</li>"
0651                                 "<li><emphasis strong='true'>Impulse Denoise</emphasis>: Impulse "
0652                                 "noise suppression. It's applied after interpolation.</li></ul></p>"));
0653 
0654     d->NRSpinBox1 = new RIntNumInput(d->correctionsSettings);
0655     d->NRSpinBox1->setRange(100, 1000, 1);
0656     d->NRSpinBox1->setDefaultValue(100);
0657     d->NRLabel1   = new QLabel(d->correctionsSettings);
0658 
0659     d->NRSpinBox2 = new RIntNumInput(d->correctionsSettings);
0660     d->NRSpinBox2->setRange(100, 1000, 1);
0661     d->NRSpinBox2->setDefaultValue(100);
0662     d->NRLabel2   = new QLabel(d->correctionsSettings);
0663 
0664     d->enableCACorrectionBox = new QCheckBox(i18nc("@option:check", "Enable Chromatic Aberration correction"), d->correctionsSettings);
0665     d->enableCACorrectionBox->setToolTip(i18nc("@info:whatsthis", "<title>Enable Chromatic "
0666                                 "Aberration correction</title>"
0667                                 "<p>Enlarge the raw red-green and blue-yellow axis by the given "
0668                                 "factors (automatic by default).</p>"));
0669 
0670     d->autoCACorrectionBox = new QCheckBox(i18nc("@option:check", "Automatic color axis adjustments"), d->correctionsSettings);
0671     d->autoCACorrectionBox->setToolTip(i18nc("@info:whatsthis", "<title>Automatic Chromatic "
0672                                 "Aberration correction</title>"
0673                                 "<p>If this option is turned on, it will try to shift image "
0674                                 "channels slightly and evaluate Chromatic Aberration change. Note "
0675                                 "that if you shot blue-red pattern, the method may fail. In this "
0676                                 "case, disable this option and tune manually color factors.</p>"));
0677 
0678     d->caRedMultLabel   = new QLabel(i18nc("@label:slider", "Red-Green:"), d->correctionsSettings);
0679     d->caRedMultSpinBox = new RDoubleNumInput(d->correctionsSettings);
0680     d->caRedMultSpinBox->setDecimals(1);
0681     d->caRedMultSpinBox->setRange(-4.0, 4.0, 0.1);
0682     d->caRedMultSpinBox->setDefaultValue(0.0);
0683     d->caRedMultSpinBox->setToolTip(i18nc("@info:whatsthis", "<title>Red-Green multiplier</title>"
0684                                 "<p>Set here the amount of correction on red-green axis</p>"));
0685 
0686     d->caBlueMultLabel   = new QLabel(i18nc("@label:slider", "Blue-Yellow:"), d->correctionsSettings);
0687     d->caBlueMultSpinBox = new RDoubleNumInput(d->correctionsSettings);
0688     d->caBlueMultSpinBox->setDecimals(1);
0689     d->caBlueMultSpinBox->setRange(-4.0, 4.0, 0.1);
0690     d->caBlueMultSpinBox->setDefaultValue(0.0);
0691     d->caBlueMultSpinBox->setToolTip(i18nc("@info:whatsthis", "<title>Blue-Yellow multiplier</title>"
0692                                 "<p>Set here the amount of correction on blue-yellow axis</p>"));
0693 
0694     correctionsLayout->addWidget(d->noiseReductionLabel,    0, 0, 1, 1);
0695     correctionsLayout->addWidget(d->noiseReductionComboBox, 0, 1, 1, 2);
0696     correctionsLayout->addWidget(d->NRLabel1,               1, 0, 1, 1);
0697     correctionsLayout->addWidget(d->NRSpinBox1,             1, 1, 1, 2);
0698     correctionsLayout->addWidget(d->NRLabel2,               2, 0, 1, 1);
0699     correctionsLayout->addWidget(d->NRSpinBox2,             2, 1, 1, 2);
0700     correctionsLayout->addWidget(d->enableCACorrectionBox,  3, 0, 1, 3);
0701     correctionsLayout->addWidget(d->autoCACorrectionBox,    4, 0, 1, 3);
0702     correctionsLayout->addWidget(d->caRedMultLabel,         5, 0, 1, 1);
0703     correctionsLayout->addWidget(d->caRedMultSpinBox,       5, 1, 1, 2);
0704     correctionsLayout->addWidget(d->caBlueMultLabel,        6, 0, 1, 1);
0705     correctionsLayout->addWidget(d->caBlueMultSpinBox,      6, 1, 1, 2);
0706     correctionsLayout->setRowStretch(7, 10);
0707     correctionsLayout->setSpacing(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
0708     correctionsLayout->setMargin(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
0709 
0710     addItem(d->correctionsSettings, KisIconUtils::loadIcon("kdcraw").pixmap(16, 16), i18nc("@label", "Corrections"), QString("corrections"), false);
0711 
0712     // ---------------------------------------------------------------
0713     // COLOR MANAGEMENT Settings panel
0714 
0715     d->colormanSettings               = new QWidget(this);
0716     QGridLayout* const colormanLayout = new QGridLayout(d->colormanSettings);
0717 
0718     d->inputColorSpaceLabel     = new QLabel(i18nc("@label:listbox", "Camera Profile:"), d->colormanSettings);
0719     d->inputColorSpaceComboBox  = new RComboBox(d->colormanSettings);
0720     d->inputColorSpaceComboBox->insertItem(RawDecodingSettings::NOINPUTCS,     i18nc("@item:inlistbox Camera Profile", "None"));
0721     d->inputColorSpaceComboBox->insertItem(RawDecodingSettings::EMBEDDED,      i18nc("@item:inlistbox Camera Profile", "Embedded"));
0722     d->inputColorSpaceComboBox->insertItem(RawDecodingSettings::CUSTOMINPUTCS, i18nc("@item:inlistbox Camera Profile", "Custom"));
0723     d->inputColorSpaceComboBox->setDefaultIndex(RawDecodingSettings::NOINPUTCS);
0724     d->inputColorSpaceComboBox->setToolTip(i18nc("@info:whatsthis", "<title>Camera Profile</title>"
0725                                 "<p>Select here the input color space used to decode RAW data.</p>"
0726                                 "<p><ul><li><emphasis strong='true'>None</emphasis>: no "
0727                                 "input color profile is used during RAW decoding.</li>"
0728                                 "<li><emphasis strong='true'>Embedded</emphasis>: use embedded "
0729                                 "color profile from RAW file, if it exists.</li>"
0730                                 "<li><emphasis strong='true'>Custom</emphasis>: use a custom "
0731                                 "input color space profile.</li></ul></p>"));
0732 
0733     d->inIccUrlEdit = new RFileSelector(d->colormanSettings);
0734     d->inIccUrlEdit->setFileDlgMode(QFileDialog::ExistingFile);
0735     d->inIccUrlEdit->setFileDlgFilter(i18n("ICC Files (*.icc; *.icm)"));
0736 
0737     d->outputColorSpaceLabel    = new QLabel(i18nc("@label:listbox", "Workspace:"), d->colormanSettings);
0738     d->outputColorSpaceComboBox = new RComboBox( d->colormanSettings );
0739     d->outputColorSpaceComboBox->insertItem(RawDecodingSettings::RAWCOLOR,       i18nc("@item:inlistbox Workspace", "Raw (no profile)"));
0740     d->outputColorSpaceComboBox->insertItem(RawDecodingSettings::SRGB,           i18nc("@item:inlistbox Workspace", "sRGB"));
0741     d->outputColorSpaceComboBox->insertItem(RawDecodingSettings::ADOBERGB,       i18nc("@item:inlistbox Workspace", "Adobe RGB"));
0742     d->outputColorSpaceComboBox->insertItem(RawDecodingSettings::WIDEGAMMUT,     i18nc("@item:inlistbox Workspace", "Wide Gamut"));
0743     d->outputColorSpaceComboBox->insertItem(RawDecodingSettings::PROPHOTO,       i18nc("@item:inlistbox Workspace", "Pro-Photo"));
0744     d->outputColorSpaceComboBox->insertItem(RawDecodingSettings::CUSTOMOUTPUTCS, i18nc("@item:inlistbox Workspace", "Custom"));
0745     d->outputColorSpaceComboBox->setDefaultIndex(RawDecodingSettings::SRGB);
0746     d->outputColorSpaceComboBox->setToolTip(i18nc("@info:whatsthis", "<title>Workspace</title>"
0747                                 "<p>Select here the output color space used to decode RAW data.</p>"
0748                                 "<p><ul><li><emphasis strong='true'>Raw (no profile)</emphasis>: "
0749                                 "in this mode, no output color space is used during RAW decoding.</li>"
0750                                 "<li><emphasis strong='true'>sRGB</emphasis>: this is an RGB "
0751                                 "color space, created cooperatively by Hewlett-Packard and "
0752                                 "Microsoft. It is the best choice for images destined for the Web "
0753                                 "and portrait photography.</li>"
0754                                 "<li><emphasis strong='true'>Adobe RGB</emphasis>: this color "
0755                                 "space is an extended RGB color space, developed by Adobe. It is "
0756                                 "used for photography applications such as advertising and fine "
0757                                 "art.</li>"
0758                                 "<li><emphasis strong='true'>Wide Gamut</emphasis>: this color "
0759                                 "space is an expanded version of the Adobe RGB color space.</li>"
0760                                 "<li><emphasis strong='true'>Pro-Photo</emphasis>: this color "
0761                                 "space is an RGB color space, developed by Kodak, that offers an "
0762                                 "especially large gamut designed for use with photographic outputs "
0763                                 "in mind.</li>"
0764                                 "<li><emphasis strong='true'>Custom</emphasis>: use a custom "
0765                                 "output color space profile.</li></ul></p>"));
0766 
0767     d->outIccUrlEdit = new RFileSelector(d->colormanSettings);
0768     d->outIccUrlEdit->setFileDlgMode(QFileDialog::ExistingFile);
0769     d->outIccUrlEdit->setFileDlgFilter(i18n("ICC Files (*.icc *.icm)"));
0770 
0771     colormanLayout->addWidget(d->inputColorSpaceLabel,     0, 0, 1, 1);
0772     colormanLayout->addWidget(d->inputColorSpaceComboBox,  0, 1, 1, 2);
0773     colormanLayout->addWidget(d->inIccUrlEdit,             1, 0, 1, 3);
0774     colormanLayout->addWidget(d->outputColorSpaceLabel,    2, 0, 1, 1);
0775     colormanLayout->addWidget(d->outputColorSpaceComboBox, 2, 1, 1, 2);
0776     colormanLayout->addWidget(d->outIccUrlEdit,            3, 0, 1, 3);
0777     colormanLayout->setRowStretch(4, 10);
0778     colormanLayout->setSpacing(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
0779     colormanLayout->setMargin(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
0780 
0781     addItem(d->colormanSettings, KisIconUtils::loadIcon("kdcraw").pixmap(16, 16), i18nc("@label", "Color Management"), QString("colormanagement"), false);
0782 
0783     if (! (advSettings & COLORSPACE))
0784         removeItem(COLORMANAGEMENT);
0785 
0786     addStretch();
0787 
0788     // ---------------------------------------------------------------
0789 
0790     connect(d->unclipColorComboBox, static_cast<void (RComboBox::*)(int)>(&RComboBox::activated),
0791             this, &DcrawSettingsWidget::slotUnclipColorActivated);
0792 
0793     connect(d->whiteBalanceComboBox, static_cast<void (RComboBox::*)(int)>(&RComboBox::activated),
0794             this, &DcrawSettingsWidget::slotWhiteBalanceToggled);
0795 
0796     connect(d->noiseReductionComboBox, static_cast<void (RComboBox::*)(int)>(&RComboBox::activated),
0797             this, &DcrawSettingsWidget::slotNoiseReductionChanged);
0798 
0799     connect(d->enableCACorrectionBox, &QCheckBox::toggled,
0800             this, &DcrawSettingsWidget::slotCACorrectionToggled);
0801 
0802     connect(d->autoCACorrectionBox, &QCheckBox::toggled,
0803             this, &DcrawSettingsWidget::slotAutoCAToggled);
0804 
0805     connect(d->blackPointCheckBox, SIGNAL(toggled(bool)),
0806             d->blackPointSpinBox, SLOT(setEnabled(bool)));
0807 
0808     connect(d->whitePointCheckBox, SIGNAL(toggled(bool)),
0809             d->whitePointSpinBox, SLOT(setEnabled(bool)));
0810 
0811     connect(d->sixteenBitsImage, &QCheckBox::toggled,
0812             this, &DcrawSettingsWidget::slotsixteenBitsImageToggled);
0813 
0814     connect(d->inputColorSpaceComboBox, static_cast<void (RComboBox::*)(int)>(&RComboBox::activated),
0815             this, &DcrawSettingsWidget::slotInputColorSpaceChanged);
0816 
0817     connect(d->outputColorSpaceComboBox, static_cast<void (RComboBox::*)(int)>(&RComboBox::activated),
0818             this, &DcrawSettingsWidget::slotOutputColorSpaceChanged);
0819 
0820     connect(d->expoCorrectionBox, &QCheckBox::toggled,
0821             this, &DcrawSettingsWidget::slotExposureCorrectionToggled);
0822 
0823     connect(d->expoCorrectionShiftSpinBox, &RDoubleNumInput::valueChanged,
0824             this, &DcrawSettingsWidget::slotExpoCorrectionShiftChanged);
0825 
0826     // Wrapper to emit signal when something is changed in settings.
0827 
0828     connect(d->inIccUrlEdit->lineEdit(), &QLineEdit::textChanged,
0829             this, &DcrawSettingsWidget::signalSettingsChanged);
0830 
0831     connect(d->outIccUrlEdit->lineEdit(), &QLineEdit::textChanged,
0832             this, &DcrawSettingsWidget::signalSettingsChanged);
0833 
0834     connect(d->whiteBalanceComboBox, static_cast<void (RComboBox::*)(int)>(&RComboBox::activated),
0835             this, &DcrawSettingsWidget::signalSettingsChanged);
0836 
0837     connect(d->RAWQualityComboBox, static_cast<void (RComboBox::*)(int)>(&RComboBox::activated),
0838             this, &DcrawSettingsWidget::slotRAWQualityChanged);
0839 
0840     connect(d->unclipColorComboBox, static_cast<void (RComboBox::*)(int)>(&RComboBox::activated),
0841             this, &DcrawSettingsWidget::signalSettingsChanged);
0842 
0843     connect(d->inputColorSpaceComboBox, static_cast<void (RComboBox::*)(int)>(&RComboBox::activated),
0844             this, &DcrawSettingsWidget::signalSettingsChanged);
0845 
0846     connect(d->outputColorSpaceComboBox, static_cast<void (RComboBox::*)(int)>(&RComboBox::activated),
0847             this, &DcrawSettingsWidget::signalSettingsChanged);
0848 
0849     connect(d->blackPointCheckBox, &QCheckBox::toggled,
0850             this, &DcrawSettingsWidget::signalSettingsChanged);
0851 
0852     connect(d->whitePointCheckBox, &QCheckBox::toggled,
0853             this, &DcrawSettingsWidget::signalSettingsChanged);
0854 
0855     connect(d->sixteenBitsImage, &QCheckBox::toggled,
0856             this, &DcrawSettingsWidget::signalSettingsChanged);
0857 
0858     connect(d->fixColorsHighlightsBox, &QCheckBox::toggled,
0859             this, &DcrawSettingsWidget::signalSettingsChanged);
0860 
0861     connect(d->autoBrightnessBox, &QCheckBox::toggled,
0862             this, &DcrawSettingsWidget::signalSettingsChanged);
0863 
0864     connect(d->fourColorCheckBox, &QCheckBox::toggled,
0865             this, &DcrawSettingsWidget::signalSettingsChanged);
0866 
0867     connect(d->dontStretchPixelsCheckBox, &QCheckBox::toggled,
0868             this, &DcrawSettingsWidget::signalSettingsChanged);
0869 
0870     connect(d->refineInterpolationBox, &QCheckBox::toggled,
0871             this, &DcrawSettingsWidget::signalSettingsChanged);
0872 
0873     connect(d->customWhiteBalanceSpinBox, &RIntNumInput::valueChanged,
0874             this, &DcrawSettingsWidget::signalSettingsChanged);
0875 
0876     connect(d->reconstructSpinBox, &RIntNumInput::valueChanged,
0877             this, &DcrawSettingsWidget::signalSettingsChanged);
0878 
0879     connect(d->blackPointSpinBox, &RIntNumInput::valueChanged,
0880             this, &DcrawSettingsWidget::signalSettingsChanged);
0881 
0882     connect(d->whitePointSpinBox, &RIntNumInput::valueChanged,
0883             this, &DcrawSettingsWidget::signalSettingsChanged);
0884 
0885     connect(d->NRSpinBox1, &RIntNumInput::valueChanged,
0886             this, &DcrawSettingsWidget::signalSettingsChanged);
0887 
0888     connect(d->NRSpinBox2, &RIntNumInput::valueChanged,
0889             this, &DcrawSettingsWidget::signalSettingsChanged);
0890 
0891     connect(d->medianFilterPassesSpinBox, &RIntNumInput::valueChanged,
0892             this, &DcrawSettingsWidget::signalSettingsChanged);
0893 
0894     connect(d->customWhiteBalanceGreenSpinBox, &RDoubleNumInput::valueChanged,
0895             this, &DcrawSettingsWidget::signalSettingsChanged);
0896 
0897     connect(d->caRedMultSpinBox, &RDoubleNumInput::valueChanged,
0898             this, &DcrawSettingsWidget::signalSettingsChanged);
0899 
0900     connect(d->caBlueMultSpinBox, &RDoubleNumInput::valueChanged,
0901             this, &DcrawSettingsWidget::signalSettingsChanged);
0902 
0903     connect(d->brightnessSpinBox, &RDoubleNumInput::valueChanged,
0904             this, &DcrawSettingsWidget::signalSettingsChanged);
0905 
0906     connect(d->expoCorrectionHighlightSpinBox, &RDoubleNumInput::valueChanged,
0907             this, &DcrawSettingsWidget::signalSettingsChanged);
0908 }
0909 
0910 DcrawSettingsWidget::~DcrawSettingsWidget()
0911 {
0912     delete d;
0913 }
0914 
0915 void DcrawSettingsWidget::updateMinimumWidth()
0916 {
0917     int width = 0;
0918 
0919     for (int i = 0; i < count(); i++)
0920     {
0921         if (widget(i)->width() > width)
0922             width = widget(i)->width();
0923     }
0924 
0925     setMinimumWidth(width);
0926 }
0927 
0928 RFileSelector* DcrawSettingsWidget::inputProfileUrlEdit() const
0929 {
0930     return d->inIccUrlEdit;
0931 }
0932 
0933 RFileSelector* DcrawSettingsWidget::outputProfileUrlEdit() const
0934 {
0935     return d->outIccUrlEdit;
0936 }
0937 
0938 void DcrawSettingsWidget::resetToDefault()
0939 {
0940     setSettings(RawDecodingSettings());
0941 }
0942 
0943 void DcrawSettingsWidget::slotsixteenBitsImageToggled(bool b)
0944 {
0945     setEnabledBrightnessSettings(!b);
0946     emit signalSixteenBitsImageToggled(d->sixteenBitsImage->isChecked());
0947 }
0948 
0949 void DcrawSettingsWidget::slotWhiteBalanceToggled(int v)
0950 {
0951     if (v == 3)
0952     {
0953         d->customWhiteBalanceSpinBox->setEnabled(true);
0954         d->customWhiteBalanceGreenSpinBox->setEnabled(true);
0955         d->customWhiteBalanceLabel->setEnabled(true);
0956         d->customWhiteBalanceGreenLabel->setEnabled(true);
0957     }
0958     else
0959     {
0960         d->customWhiteBalanceSpinBox->setEnabled(false);
0961         d->customWhiteBalanceGreenSpinBox->setEnabled(false);
0962         d->customWhiteBalanceLabel->setEnabled(false);
0963         d->customWhiteBalanceGreenLabel->setEnabled(false);
0964     }
0965 }
0966 
0967 void DcrawSettingsWidget::slotUnclipColorActivated(int v)
0968 {
0969     if (v == 3)     // Reconstruct Highlight method
0970     {
0971         d->reconstructLabel->setEnabled(true);
0972         d->reconstructSpinBox->setEnabled(true);
0973     }
0974     else
0975     {
0976         d->reconstructLabel->setEnabled(false);
0977         d->reconstructSpinBox->setEnabled(false);
0978     }
0979 }
0980 
0981 void DcrawSettingsWidget::slotNoiseReductionChanged(int item)
0982 {
0983     d->NRSpinBox1->setEnabled(true);
0984     d->NRLabel1->setEnabled(true);
0985     d->NRSpinBox2->setEnabled(true);
0986     d->NRLabel2->setEnabled(true);
0987     d->NRLabel1->setText(i18nc("@label", "Threshold:"));
0988     d->NRSpinBox1->setToolTip(i18nc("@info:whatsthis", "<title>Threshold</title>"
0989                                 "<p>Set here the noise reduction threshold value to use.</p>"));
0990 
0991     switch(item)
0992     {
0993         case RawDecodingSettings::WAVELETSNR:
0994         case RawDecodingSettings::FBDDNR:
0995         case RawDecodingSettings::LINENR:
0996             d->NRSpinBox2->setVisible(false);
0997             d->NRLabel2->setVisible(false);
0998             break;
0999 
1000         case RawDecodingSettings::IMPULSENR:
1001             d->NRLabel1->setText(i18nc("@label", "Luminance:"));
1002             d->NRSpinBox1->setToolTip(i18nc("@info:whatsthis", "<title>Luminance</title>"
1003                                 "<p>Amount of Luminance impulse noise reduction.</p>"));
1004             d->NRLabel2->setText(i18nc("@label", "Chrominance:"));
1005             d->NRSpinBox2->setToolTip(i18nc("@info:whatsthis", "<title>Chrominance</title>"
1006                                 "<p>Amount of Chrominance impulse noise reduction.</p>"));
1007             d->NRSpinBox2->setVisible(true);
1008             d->NRLabel2->setVisible(true);
1009             break;
1010 
1011         default:
1012             d->NRSpinBox1->setEnabled(false);
1013             d->NRLabel1->setEnabled(false);
1014             d->NRSpinBox2->setEnabled(false);
1015             d->NRLabel2->setEnabled(false);
1016             d->NRSpinBox2->setVisible(false);
1017             d->NRLabel2->setVisible(false);
1018             break;
1019     }
1020 
1021     emit signalSettingsChanged();
1022 }
1023 
1024 void DcrawSettingsWidget::slotCACorrectionToggled(bool b)
1025 {
1026     d->autoCACorrectionBox->setEnabled(b);
1027     slotAutoCAToggled(d->autoCACorrectionBox->isChecked());
1028 }
1029 
1030 void DcrawSettingsWidget::slotAutoCAToggled(bool b)
1031 {
1032     if (b)
1033     {
1034         d->caRedMultSpinBox->setValue(0.0);
1035         d->caBlueMultSpinBox->setValue(0.0);
1036     }
1037 
1038     bool mult = (!b) && (d->autoCACorrectionBox->isEnabled());
1039     d->caRedMultSpinBox->setEnabled(mult);
1040     d->caBlueMultSpinBox->setEnabled(mult);
1041     d->caRedMultLabel->setEnabled(mult);
1042     d->caBlueMultLabel->setEnabled(mult);
1043     emit signalSettingsChanged();
1044 }
1045 
1046 void DcrawSettingsWidget::slotExposureCorrectionToggled(bool b)
1047 {
1048     d->expoCorrectionShiftLabel->setEnabled(b);
1049     d->expoCorrectionShiftSpinBox->setEnabled(b);
1050     d->expoCorrectionHighlightLabel->setEnabled(b);
1051     d->expoCorrectionHighlightSpinBox->setEnabled(b);
1052 
1053     slotExpoCorrectionShiftChanged(d->expoCorrectionShiftSpinBox->value());
1054 }
1055 
1056 void DcrawSettingsWidget::slotExpoCorrectionShiftChanged(double ev)
1057 {
1058     // Only enable Highligh exposure correction if Shift correction is >= 1.0, else this settings do not take effect.
1059     bool b = (ev >= 1.0);
1060 
1061     d->expoCorrectionHighlightLabel->setEnabled(b);
1062     d->expoCorrectionHighlightSpinBox->setEnabled(b);
1063 
1064     emit signalSettingsChanged();
1065 }
1066 
1067 void DcrawSettingsWidget::slotInputColorSpaceChanged(int item)
1068 {
1069     d->inIccUrlEdit->setEnabled(item == RawDecodingSettings::CUSTOMINPUTCS);
1070 }
1071 
1072 void DcrawSettingsWidget::slotOutputColorSpaceChanged(int item)
1073 {
1074     d->outIccUrlEdit->setEnabled(item == RawDecodingSettings::CUSTOMOUTPUTCS);
1075 }
1076 
1077 void DcrawSettingsWidget::slotRAWQualityChanged(int quality)
1078 {
1079     switch(quality)
1080     {
1081         case RawDecodingSettings::DCB:
1082         case RawDecodingSettings::VCD_AHD:
1083             // These options can be only available if Libraw use GPL2 pack.
1084             d->medianFilterPassesLabel->setEnabled(KDcraw::librawUseGPL2DemosaicPack());
1085             d->medianFilterPassesSpinBox->setEnabled(KDcraw::librawUseGPL2DemosaicPack());
1086             d->refineInterpolationBox->setEnabled(KDcraw::librawUseGPL2DemosaicPack());
1087             break;
1088 
1089         case RawDecodingSettings::PL_AHD:
1090         case RawDecodingSettings::AFD:
1091         case RawDecodingSettings::VCD:
1092         case RawDecodingSettings::LMMSE:
1093         case RawDecodingSettings::AMAZE:
1094             d->medianFilterPassesLabel->setEnabled(false);
1095             d->medianFilterPassesSpinBox->setEnabled(false);
1096             d->refineInterpolationBox->setEnabled(false);
1097             break;
1098 
1099         default: // BILINEAR, VNG, PPG, AHD
1100             d->medianFilterPassesLabel->setEnabled(true);
1101             d->medianFilterPassesSpinBox->setEnabled(true);
1102             d->refineInterpolationBox->setEnabled(false);
1103             break;
1104     }
1105 
1106     emit signalSettingsChanged();
1107 }
1108 
1109 void DcrawSettingsWidget::setEnabledBrightnessSettings(bool b)
1110 {
1111     d->brightnessLabel->setEnabled(b);
1112     d->brightnessSpinBox->setEnabled(b);
1113 }
1114 
1115 bool DcrawSettingsWidget::brightnessSettingsIsEnabled() const
1116 {
1117     return d->brightnessSpinBox->isEnabled();
1118 }
1119 
1120 void DcrawSettingsWidget::setSettings(const RawDecodingSettings& settings)
1121 {
1122     d->sixteenBitsImage->setChecked(settings.sixteenBitsImage);
1123 
1124     switch(settings.whiteBalance)
1125     {
1126         case RawDecodingSettings::CAMERA:
1127             d->whiteBalanceComboBox->setCurrentIndex(1);
1128             break;
1129         case RawDecodingSettings::AUTO:
1130             d->whiteBalanceComboBox->setCurrentIndex(2);
1131             break;
1132         case RawDecodingSettings::CUSTOM:
1133             d->whiteBalanceComboBox->setCurrentIndex(3);
1134             break;
1135         default:
1136             d->whiteBalanceComboBox->setCurrentIndex(0);
1137             break;
1138     }
1139     slotWhiteBalanceToggled(d->whiteBalanceComboBox->currentIndex());
1140 
1141     d->customWhiteBalanceSpinBox->setValue(settings.customWhiteBalance);
1142     d->customWhiteBalanceGreenSpinBox->setValue(settings.customWhiteBalanceGreen);
1143     d->fourColorCheckBox->setChecked(settings.RGBInterpolate4Colors);
1144     d->autoBrightnessBox->setChecked(settings.autoBrightness);
1145     d->fixColorsHighlightsBox->setChecked(settings.fixColorsHighlights);
1146 
1147     switch(settings.unclipColors)
1148     {
1149         case 0:
1150             d->unclipColorComboBox->setCurrentIndex(0);
1151             break;
1152         case 1:
1153             d->unclipColorComboBox->setCurrentIndex(1);
1154             break;
1155         case 2:
1156             d->unclipColorComboBox->setCurrentIndex(2);
1157             break;
1158         default:         // Reconstruct Highlight method
1159             d->unclipColorComboBox->setCurrentIndex(3);
1160             d->reconstructSpinBox->setValue(settings.unclipColors-3);
1161             break;
1162     }
1163     slotUnclipColorActivated(d->unclipColorComboBox->currentIndex());
1164 
1165     d->dontStretchPixelsCheckBox->setChecked(settings.DontStretchPixels);
1166     d->brightnessSpinBox->setValue(settings.brightness);
1167     d->blackPointCheckBox->setChecked(settings.enableBlackPoint);
1168     d->blackPointSpinBox->setEnabled(settings.enableBlackPoint);
1169     d->blackPointSpinBox->setValue(settings.blackPoint);
1170     d->whitePointCheckBox->setChecked(settings.enableWhitePoint);
1171     d->whitePointSpinBox->setEnabled(settings.enableWhitePoint);
1172     d->whitePointSpinBox->setValue(settings.whitePoint);
1173 
1174     int q = settings.RAWQuality;
1175 
1176     // If Libraw do not support GPL2 pack, reset to BILINEAR.
1177     if (!KDcraw::librawUseGPL2DemosaicPack())
1178     {
1179         for (int i=RawDecodingSettings::DCB ; i <=RawDecodingSettings::LMMSE ; ++i)
1180         {
1181             if (q == i)
1182             {
1183                 q = RawDecodingSettings::BILINEAR;
1184                 qCDebug(LIBKDCRAW_LOG) << "Libraw GPL2 pack not available. Raw quality set to Bilinear";
1185                 break;
1186             }
1187         }
1188     }
1189 
1190     // If Libraw do not support GPL3 pack, reset to BILINEAR.
1191     if (!KDcraw::librawUseGPL3DemosaicPack() && (q == RawDecodingSettings::AMAZE))
1192     {
1193         q = RawDecodingSettings::BILINEAR;
1194         qCDebug(LIBKDCRAW_LOG) << "Libraw GPL3 pack not available. Raw quality set to Bilinear";
1195     }
1196 
1197     d->RAWQualityComboBox->setCurrentIndex(q);
1198 
1199     switch(q)
1200     {
1201         case RawDecodingSettings::DCB:
1202             d->medianFilterPassesSpinBox->setValue(settings.dcbIterations);
1203             d->refineInterpolationBox->setChecked(settings.dcbEnhanceFl);
1204             break;
1205         case RawDecodingSettings::VCD_AHD:
1206             d->medianFilterPassesSpinBox->setValue(settings.eeciRefine);
1207             d->refineInterpolationBox->setChecked(settings.eeciRefine);
1208             break;
1209         default:
1210             d->medianFilterPassesSpinBox->setValue(settings.medianFilterPasses);
1211             d->refineInterpolationBox->setChecked(false); // option not used.
1212             break;
1213     }
1214 
1215     slotRAWQualityChanged(q);
1216 
1217     d->inputColorSpaceComboBox->setCurrentIndex((int)settings.inputColorSpace);
1218     slotInputColorSpaceChanged((int)settings.inputColorSpace);
1219     d->outputColorSpaceComboBox->setCurrentIndex((int)settings.outputColorSpace);
1220     slotOutputColorSpaceChanged((int)settings.outputColorSpace);
1221 
1222     d->noiseReductionComboBox->setCurrentIndex(settings.NRType);
1223     slotNoiseReductionChanged(settings.NRType);
1224     d->NRSpinBox1->setValue(settings.NRThreshold);
1225     d->NRSpinBox2->setValue(settings.NRChroThreshold);
1226 
1227     d->enableCACorrectionBox->setChecked(settings.enableCACorrection);
1228     d->caRedMultSpinBox->setValue(settings.caMultiplier[0]);
1229     d->caBlueMultSpinBox->setValue(settings.caMultiplier[1]);
1230     d->autoCACorrectionBox->setChecked((settings.caMultiplier[0] == 0.0) && (settings.caMultiplier[1] == 0.0));
1231     slotCACorrectionToggled(settings.enableCACorrection);
1232 
1233     d->expoCorrectionBox->setChecked(settings.expoCorrection);
1234     slotExposureCorrectionToggled(settings.expoCorrection);
1235     d->expoCorrectionShiftSpinBox->setValue(d->shiftExpoFromLinearToEv(settings.expoCorrectionShift));
1236     d->expoCorrectionHighlightSpinBox->setValue(settings.expoCorrectionHighlight);
1237 
1238     d->inIccUrlEdit->lineEdit()->setText(settings.inputProfile);
1239     d->outIccUrlEdit->lineEdit()->setText(settings.outputProfile);
1240 }
1241 
1242 RawDecodingSettings DcrawSettingsWidget::settings() const
1243 {
1244     RawDecodingSettings prm;
1245     prm.sixteenBitsImage = d->sixteenBitsImage->isChecked();
1246 
1247     switch(d->whiteBalanceComboBox->currentIndex())
1248     {
1249         case 1:
1250             prm.whiteBalance = RawDecodingSettings::CAMERA;
1251             break;
1252         case 2:
1253             prm.whiteBalance = RawDecodingSettings::AUTO;
1254             break;
1255         case 3:
1256             prm.whiteBalance = RawDecodingSettings::CUSTOM;
1257             break;
1258         default:
1259             prm.whiteBalance = RawDecodingSettings::NONE;
1260             break;
1261     }
1262 
1263     prm.customWhiteBalance      = d->customWhiteBalanceSpinBox->value();
1264     prm.customWhiteBalanceGreen = d->customWhiteBalanceGreenSpinBox->value();
1265     prm.RGBInterpolate4Colors   = d->fourColorCheckBox->isChecked();
1266     prm.autoBrightness          = d->autoBrightnessBox->isChecked();
1267     prm.fixColorsHighlights     = d->fixColorsHighlightsBox->isChecked();
1268 
1269     switch(d->unclipColorComboBox->currentIndex())
1270     {
1271         case 0:
1272             prm.unclipColors = 0;
1273             break;
1274         case 1:
1275             prm.unclipColors = 1;
1276             break;
1277         case 2:
1278             prm.unclipColors = 2;
1279             break;
1280         default:         // Reconstruct Highlight method
1281             prm.unclipColors =  d->reconstructSpinBox->value()+3;
1282             break;
1283     }
1284 
1285     prm.DontStretchPixels    = d->dontStretchPixelsCheckBox->isChecked();
1286     prm.brightness           = d->brightnessSpinBox->value();
1287     prm.enableBlackPoint     = d->blackPointCheckBox->isChecked();
1288     prm.blackPoint           = d->blackPointSpinBox->value();
1289     prm.enableWhitePoint     = d->whitePointCheckBox->isChecked();
1290     prm.whitePoint           = d->whitePointSpinBox->value();
1291 
1292     prm.RAWQuality           = (RawDecodingSettings::DecodingQuality)d->RAWQualityComboBox->currentIndex();
1293     switch(prm.RAWQuality)
1294     {
1295         case RawDecodingSettings::DCB:
1296             prm.dcbIterations      = d->medianFilterPassesSpinBox->value();
1297             prm.dcbEnhanceFl       = d->refineInterpolationBox->isChecked();
1298             break;
1299         case RawDecodingSettings::VCD_AHD:
1300             prm.esMedPasses        = d->medianFilterPassesSpinBox->value();
1301             prm.eeciRefine         = d->refineInterpolationBox->isChecked();
1302             break;
1303         default:
1304             prm.medianFilterPasses = d->medianFilterPassesSpinBox->value();
1305             break;
1306     }
1307 
1308     prm.NRType = (RawDecodingSettings::NoiseReduction)d->noiseReductionComboBox->currentIndex();
1309     switch (prm.NRType)
1310     {
1311         case RawDecodingSettings::NONR:
1312         {
1313             prm.NRThreshold     = 0;
1314             prm.NRChroThreshold = 0;
1315             break;
1316         }
1317         case RawDecodingSettings::WAVELETSNR:
1318         case RawDecodingSettings::FBDDNR:
1319         case RawDecodingSettings::LINENR:
1320         {
1321             prm.NRThreshold     = d->NRSpinBox1->value();
1322             prm.NRChroThreshold = 0;
1323             break;
1324         }
1325         default:    // IMPULSENR
1326         {
1327             prm.NRThreshold     = d->NRSpinBox1->value();
1328             prm.NRChroThreshold = d->NRSpinBox2->value();
1329             break;
1330         }
1331     }
1332 
1333     prm.enableCACorrection      = d->enableCACorrectionBox->isChecked();
1334     prm.caMultiplier[0]         = d->caRedMultSpinBox->value();
1335     prm.caMultiplier[1]         = d->caBlueMultSpinBox->value();
1336 
1337     prm.expoCorrection          = d->expoCorrectionBox->isChecked();
1338     prm.expoCorrectionShift     = d->shiftExpoFromEvToLinear(d->expoCorrectionShiftSpinBox->value());
1339     prm.expoCorrectionHighlight = d->expoCorrectionHighlightSpinBox->value();
1340 
1341     prm.inputColorSpace         = (RawDecodingSettings::InputColorSpace)(d->inputColorSpaceComboBox->currentIndex());
1342     prm.outputColorSpace        = (RawDecodingSettings::OutputColorSpace)(d->outputColorSpaceComboBox->currentIndex());
1343     prm.inputProfile            = d->inIccUrlEdit->lineEdit()->text();
1344     prm.outputProfile           = d->outIccUrlEdit->lineEdit()->text();
1345 
1346     return prm;
1347 }
1348 
1349 void DcrawSettingsWidget::writeSettings(KConfigGroup& group)
1350 {
1351     RawDecodingSettings prm = settings();
1352     {
1353             group.writeEntry(OPTIONFIXCOLORSHIGHLIGHTSENTRY, prm.fixColorsHighlights);
1354             group.writeEntry(OPTIONDECODESIXTEENBITENTRY, prm.sixteenBitsImage);
1355             group.writeEntry(OPTIONWHITEBALANCEENTRY, (int)prm.whiteBalance);
1356             group.writeEntry(OPTIONCUSTOMWHITEBALANCEENTRY, prm.customWhiteBalance);
1357             group.writeEntry(OPTIONCUSTOMWBGREENENTRY, prm.customWhiteBalanceGreen);
1358             group.writeEntry(OPTIONFOURCOLORRGBENTRY, prm.RGBInterpolate4Colors);
1359             group.writeEntry(OPTIONUNCLIPCOLORSENTRY, prm.unclipColors);
1360             group.writeEntry(OPTIONDONTSTRETCHPIXELSENTRY, prm.DontStretchPixels);
1361             group.writeEntry(OPTIONNOISEREDUCTIONTYPEENTRY, (int)prm.NRType);
1362             group.writeEntry(OPTIONBRIGHTNESSMULTIPLIERENTRY, prm.brightness);
1363             group.writeEntry(OPTIONUSEBLACKPOINTENTRY, prm.enableBlackPoint);
1364             group.writeEntry(OPTIONBLACKPOINTENTRY, prm.blackPoint);
1365             group.writeEntry(OPTIONUSEWHITEPOINTENTRY, prm.enableWhitePoint);
1366             group.writeEntry(OPTIONWHITEPOINTENTRY, prm.whitePoint);
1367             group.writeEntry(OPTIONMEDIANFILTERPASSESENTRY, prm.medianFilterPasses);
1368             group.writeEntry(OPTIONNOISEREDUCTIONTHRESHOLDENTRY, prm.NRThreshold);
1369             group.writeEntry(OPTIONUSECACORRECTIONENTRY, prm.enableCACorrection);
1370             group.writeEntry(OPTIONCAREDMULTIPLIERENTRY, prm.caMultiplier[0]);
1371             group.writeEntry(OPTIONCABLUEMULTIPLIERENTRY, prm.caMultiplier[1]);
1372             group.writeEntry(OPTIONDECODINGQUALITYENTRY, (int)prm.RAWQuality);
1373             group.writeEntry(OPTIONOUTPUTCOLORSPACEENTRY, (int)prm.outputColorSpace);
1374             group.writeEntry(OPTIONAUTOBRIGHTNESSENTRY, prm.autoBrightness);
1375 
1376             //-- Extended demosaicing settings ----------------------------------------------------------
1377 
1378             group.writeEntry(OPTIONDCBITERATIONSENTRY, prm.dcbIterations);
1379             group.writeEntry(OPTIONDCBENHANCEFLENTRY, prm.dcbEnhanceFl);
1380             group.writeEntry(OPTIONEECIREFINEENTRY, prm.eeciRefine);
1381             group.writeEntry(OPTIONESMEDPASSESENTRY, prm.esMedPasses);
1382             group.writeEntry(OPTIONNRCHROMINANCETHRESHOLDENTRY, prm.NRChroThreshold);
1383             group.writeEntry(OPTIONEXPOCORRECTIONENTRY, prm.expoCorrection);
1384             group.writeEntry(OPTIONEXPOCORRECTIONSHIFTENTRY, prm.expoCorrectionShift);
1385             group.writeEntry(OPTIONEXPOCORRECTIONHIGHLIGHTENTRY, prm.expoCorrectionHighlight);
1386     }
1387     RExpanderBox::writeSettings(group);
1388 }
1389 
1390 void DcrawSettingsWidget::readSettings(KConfigGroup& group)
1391 {
1392     RawDecodingSettings prm;
1393     {
1394             prm.fixColorsHighlights = group.readEntry(OPTIONFIXCOLORSHIGHLIGHTSENTRY, prm.fixColorsHighlights);
1395             prm.sixteenBitsImage = group.readEntry(OPTIONDECODESIXTEENBITENTRY, prm.sixteenBitsImage);
1396             prm.whiteBalance =
1397                 (RawDecodingSettings::WhiteBalance)group.readEntry(OPTIONWHITEBALANCEENTRY, (int)prm.whiteBalance);
1398             prm.customWhiteBalance = group.readEntry(OPTIONCUSTOMWHITEBALANCEENTRY, prm.customWhiteBalance);
1399             prm.customWhiteBalanceGreen = group.readEntry(OPTIONCUSTOMWBGREENENTRY, prm.customWhiteBalanceGreen);
1400             prm.RGBInterpolate4Colors = group.readEntry(OPTIONFOURCOLORRGBENTRY, prm.RGBInterpolate4Colors);
1401             prm.unclipColors = group.readEntry(OPTIONUNCLIPCOLORSENTRY, prm.unclipColors);
1402             prm.DontStretchPixels = group.readEntry(OPTIONDONTSTRETCHPIXELSENTRY, prm.DontStretchPixels);
1403             prm.NRType =
1404                 (RawDecodingSettings::NoiseReduction)group.readEntry(OPTIONNOISEREDUCTIONTYPEENTRY, (int)prm.NRType);
1405             prm.brightness = group.readEntry(OPTIONBRIGHTNESSMULTIPLIERENTRY, prm.brightness);
1406             prm.enableBlackPoint = group.readEntry(OPTIONUSEBLACKPOINTENTRY, prm.enableBlackPoint);
1407             prm.blackPoint = group.readEntry(OPTIONBLACKPOINTENTRY, prm.blackPoint);
1408             prm.enableWhitePoint = group.readEntry(OPTIONUSEWHITEPOINTENTRY, prm.enableWhitePoint);
1409             prm.whitePoint = group.readEntry(OPTIONWHITEPOINTENTRY, prm.whitePoint);
1410             prm.medianFilterPasses = group.readEntry(OPTIONMEDIANFILTERPASSESENTRY, prm.medianFilterPasses);
1411             prm.NRThreshold = group.readEntry(OPTIONNOISEREDUCTIONTHRESHOLDENTRY, prm.NRThreshold);
1412             prm.enableCACorrection = group.readEntry(OPTIONUSECACORRECTIONENTRY, prm.enableCACorrection);
1413             prm.caMultiplier[0] = group.readEntry(OPTIONCAREDMULTIPLIERENTRY, prm.caMultiplier[0]);
1414             prm.caMultiplier[1] = group.readEntry(OPTIONCABLUEMULTIPLIERENTRY, prm.caMultiplier[1]);
1415             prm.RAWQuality =
1416                 (RawDecodingSettings::DecodingQuality)group.readEntry(OPTIONDECODINGQUALITYENTRY, (int)prm.RAWQuality);
1417             prm.outputColorSpace = (RawDecodingSettings::OutputColorSpace)group.readEntry(OPTIONOUTPUTCOLORSPACEENTRY,
1418                                                                                           (int)prm.outputColorSpace);
1419             prm.autoBrightness = group.readEntry(OPTIONAUTOBRIGHTNESSENTRY, prm.autoBrightness);
1420 
1421             //-- Extended demosaicing settings ----------------------------------------------------------
1422 
1423             prm.dcbIterations = group.readEntry(OPTIONDCBITERATIONSENTRY, prm.dcbIterations);
1424             prm.dcbEnhanceFl = group.readEntry(OPTIONDCBENHANCEFLENTRY, prm.dcbEnhanceFl);
1425             prm.eeciRefine = group.readEntry(OPTIONEECIREFINEENTRY, prm.eeciRefine);
1426             prm.esMedPasses = group.readEntry(OPTIONESMEDPASSESENTRY, prm.esMedPasses);
1427             prm.NRChroThreshold = group.readEntry(OPTIONNRCHROMINANCETHRESHOLDENTRY, prm.NRChroThreshold);
1428             prm.expoCorrection = group.readEntry(OPTIONEXPOCORRECTIONENTRY, prm.expoCorrection);
1429             prm.expoCorrectionShift = group.readEntry(OPTIONEXPOCORRECTIONSHIFTENTRY, prm.expoCorrectionShift);
1430             prm.expoCorrectionHighlight =
1431                 group.readEntry(OPTIONEXPOCORRECTIONHIGHLIGHTENTRY, prm.expoCorrectionHighlight);
1432     }
1433     setSettings(prm);
1434     RExpanderBox::readSettings(group);
1435 }
1436 
1437 } // NameSpace KDcrawIface