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

« back to all changes in this revision

Viewing changes to core/libs/dimg/filters/wb/wbsettings.cpp

  • Committer: Package Import Robot
  • Author(s): Felix Geyer, Rohan Garg, Philip Muškovac, Felix Geyer
  • Date: 2011-09-23 18:18:55 UTC
  • mfrom: (1.2.36 upstream)
  • Revision ID: package-import@ubuntu.com-20110923181855-ifs67wxkugshev9k
Tags: 2:2.1.1-0ubuntu1
[ Rohan Garg ]
* New upstream release (LP: #834190)
  - debian/control
    + Build with libqtwebkit-dev
 - debian/kipi-plugins-common
    + Install libkvkontakte required by kipi-plugins
 - debian/digikam
    + Install panoramagui

[ Philip Muškovac ]
* New upstream release
  - debian/control:
    + Add libcv-dev, libcvaux-dev, libhighgui-dev, libboost-graph1.46-dev,
      libksane-dev, libxml2-dev, libxslt-dev, libqt4-opengl-dev, libqjson-dev,
      libgpod-dev and libqca2-dev to build-deps
    + Add packages for kipi-plugins, libmediawiki, libkface, libkgeomap and
      libkvkontakte
  - debian/rules:
    + Don't build with gphoto2 since it doesn't build with it.
  - Add kubuntu_fix_test_linking.diff to fix linking of the dngconverter test
  - update install files
  - update kubuntu_01_mysqld_executable_name.diff for new cmake layout
    and rename to kubuntu_mysqld_executable_name.diff
* Fix typo in digikam-data description (LP: #804894)
* Fix Vcs links

[ Felix Geyer ]
* Move library data files to the new packages libkface-data, libkgeomap-data
  and libkvkontakte-data.
* Override version of the embedded library packages to 1.0~digikam<version>.
* Exclude the library packages from digikam-dbg to prevent file conflicts in
  the future.
* Call dh_install with --list-missing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ============================================================
 
2
 *
 
3
 * This file is a part of digiKam project
 
4
 * http://www.digikam.org
 
5
 *
 
6
 * Date        : 2010-02-26
 
7
 * Description : White Balance settings view.
 
8
 *
 
9
 * Copyright (C) 2010 by Gilles Caulier <caulier dot gilles at gmail dot com>
 
10
 *
 
11
 * This program is free software; you can redistribute it
 
12
 * and/or modify it under the terms of the GNU General
 
13
 * Public License as published by the Free Software Foundation;
 
14
 * either version 2, or (at your option)
 
15
 * any later version.
 
16
 *
 
17
 * This program is distributed in the hope that it will be useful,
 
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
 * GNU General Public License for more details.
 
21
 *
 
22
 * ============================================================ */
 
23
 
 
24
#include "wbsettings.moc"
 
25
 
 
26
// Qt includes
 
27
 
 
28
#include <QString>
 
29
#include <QButtonGroup>
 
30
#include <QFile>
 
31
#include <QFrame>
 
32
#include <QGridLayout>
 
33
#include <QGroupBox>
 
34
#include <QHBoxLayout>
 
35
#include <QLabel>
 
36
#include <QRegExp>
 
37
#include <QTextStream>
 
38
#include <QToolButton>
 
39
#include <QVBoxLayout>
 
40
 
 
41
// KDE includes
 
42
 
 
43
#include <kdebug.h>
 
44
#include <kurl.h>
 
45
#include <kdialog.h>
 
46
#include <klocale.h>
 
47
#include <kapplication.h>
 
48
#include <kfiledialog.h>
 
49
#include <kglobal.h>
 
50
#include <kglobalsettings.h>
 
51
#include <kmessagebox.h>
 
52
#include <kstandarddirs.h>
 
53
#include <kcombobox.h>
 
54
#include <kseparator.h>
 
55
#include <kiconloader.h>
 
56
 
 
57
// LibKDcraw includes
 
58
 
 
59
#include <libkdcraw/rcombobox.h>
 
60
#include <libkdcraw/rnuminput.h>
 
61
#include <libkdcraw/rexpanderbox.h>
 
62
 
 
63
using namespace KDcrawIface;
 
64
 
 
65
namespace Digikam
 
66
{
 
67
 
 
68
class WBSettingsPriv
 
69
{
 
70
 
 
71
public:
 
72
 
 
73
    enum TemperaturePreset
 
74
    {
 
75
        None        = -1,
 
76
        Candle      = 1850,
 
77
        Lamp40W     = 2680,
 
78
        Lamp100W    = 2800,
 
79
        Lamp200W    = 3000,
 
80
        Sunrise     = 3200,
 
81
        StudioLamp  = 3400,
 
82
        MoonLight   = 4100,
 
83
        Neutral     = 4750,
 
84
        DaylightD50 = 5000,
 
85
        Flash       = 5500,
 
86
        Sun         = 5770,
 
87
        XenonLamp   = 6420,
 
88
        DaylightD65 = 6500
 
89
    };
 
90
 
 
91
public:
 
92
 
 
93
    WBSettingsPriv() :
 
94
        DefaultTemperature(DaylightD65),
 
95
        pickTemperature(0),
 
96
        autoAdjustExposure(0),
 
97
        adjTemperatureLabel(0),
 
98
        temperaturePresetLabel(0),
 
99
        darkLabel(0),
 
100
        blackLabel(0),
 
101
        mainExposureLabel(0),
 
102
        fineExposureLabel(0),
 
103
        gammaLabel(0),
 
104
        saturationLabel(0),
 
105
        greenLabel(0),
 
106
        exposureLabel(0),
 
107
        temperatureLabel(0),
 
108
        temperaturePresetCB(0),
 
109
        temperatureInput(0),
 
110
        darkInput(0),
 
111
        blackInput(0),
 
112
        mainExposureInput(0),
 
113
        fineExposureInput(0),
 
114
        gammaInput(0),
 
115
        saturationInput(0),
 
116
        greenInput(0)
 
117
    {}
 
118
 
 
119
    static const QString    configDarkInputEntry;
 
120
    static const QString    configBlackInputEntry;
 
121
    static const QString    configMainExposureEntry;
 
122
    static const QString    configFineExposureEntry;
 
123
    static const QString    configGammaInputEntry;
 
124
    static const QString    configSaturationInputEntry;
 
125
    static const QString    configGreenInputEntry;
 
126
    static const QString    configTemperatureInputEntry;
 
127
 
 
128
    const int               DefaultTemperature;
 
129
 
 
130
    QToolButton*            pickTemperature;
 
131
    QToolButton*            autoAdjustExposure;
 
132
 
 
133
    QLabel*                 adjTemperatureLabel;
 
134
    QLabel*                 temperaturePresetLabel;
 
135
    QLabel*                 darkLabel;
 
136
    QLabel*                 blackLabel;
 
137
    QLabel*                 mainExposureLabel;
 
138
    QLabel*                 fineExposureLabel;
 
139
    QLabel*                 gammaLabel;
 
140
    QLabel*                 saturationLabel;
 
141
    QLabel*                 greenLabel;
 
142
    QLabel*                 exposureLabel;
 
143
    QLabel*                 temperatureLabel;
 
144
 
 
145
    RComboBox*              temperaturePresetCB;
 
146
 
 
147
    RDoubleNumInput*        temperatureInput;
 
148
    RDoubleNumInput*        darkInput;
 
149
    RDoubleNumInput*        blackInput;
 
150
    RDoubleNumInput*        mainExposureInput;
 
151
    RDoubleNumInput*        fineExposureInput;
 
152
    RDoubleNumInput*        gammaInput;
 
153
    RDoubleNumInput*        saturationInput;
 
154
    RDoubleNumInput*        greenInput;
 
155
 
 
156
public:
 
157
 
 
158
    QString addTemperatureDescription(const QString& desc, TemperaturePreset preset)
 
159
    {
 
160
        int index        = temperaturePresetCB->combo()->findData((int)preset);
 
161
        QString itemText = temperaturePresetCB->combo()->itemText(index);
 
162
        QString tempDesc = QString("<p><b>%1</b>: %2 (%3K).</p>")
 
163
                           .arg(itemText)
 
164
                           .arg(desc)
 
165
                           .arg((int)preset);
 
166
 
 
167
        if (preset == None)
 
168
        {
 
169
            tempDesc.remove(QRegExp("\\(.*\\)"));
 
170
        }
 
171
 
 
172
        return tempDesc;
 
173
    }
 
174
};
 
175
const QString WBSettingsPriv::configDarkInputEntry("Dark");
 
176
const QString WBSettingsPriv::configBlackInputEntry("Black");
 
177
const QString WBSettingsPriv::configMainExposureEntry("MainExposure");
 
178
const QString WBSettingsPriv::configFineExposureEntry("FineExposure");
 
179
const QString WBSettingsPriv::configGammaInputEntry("Gamma");
 
180
const QString WBSettingsPriv::configSaturationInputEntry("Saturation");
 
181
const QString WBSettingsPriv::configGreenInputEntry("Green");
 
182
const QString WBSettingsPriv::configTemperatureInputEntry("Temperature");
 
183
 
 
184
// --------------------------------------------------------
 
185
 
 
186
WBSettings::WBSettings(QWidget* parent)
 
187
    : QWidget(parent),
 
188
      d(new WBSettingsPriv)
 
189
{
 
190
    QGridLayout* grid = new QGridLayout(parent);
 
191
 
 
192
    d->temperatureLabel = new QLabel(i18n("<a href='http://en.wikipedia.org/wiki/Color_temperature'>"
 
193
                                          "Color Temperature</a> (K): "));
 
194
    d->temperatureLabel->setOpenExternalLinks(true);
 
195
 
 
196
    d->adjTemperatureLabel = new QLabel(i18n("Adjustment:"));
 
197
    d->temperatureInput    = new RDoubleNumInput;
 
198
    d->temperatureInput->setDecimals(1);
 
199
    d->temperatureInput->input()->setRange(1750.0, 12000.0, 10.0);
 
200
    d->temperatureInput->setDefaultValue((double)d->DefaultTemperature);
 
201
    d->temperatureInput->setWhatsThis( i18n("Set here the white balance color temperature in Kelvin."));
 
202
 
 
203
    d->temperaturePresetLabel = new QLabel(i18n("Preset:"));
 
204
    d->temperaturePresetCB    = new RComboBox;
 
205
    d->temperaturePresetCB->combo()->addItem(i18n("40W Lamp"),                       QVariant(d->Lamp40W));
 
206
    d->temperaturePresetCB->combo()->addItem(i18n("100W Lamp"),                      QVariant(d->Lamp100W));
 
207
    d->temperaturePresetCB->combo()->addItem(i18n("200W Lamp"),                      QVariant(d->Lamp200W));
 
208
    d->temperaturePresetCB->combo()->addItem(i18n("Candle"),                         QVariant(d->Candle));
 
209
    d->temperaturePresetCB->combo()->addItem(i18n("Daylight D50"),                   QVariant(d->DaylightD50));
 
210
    d->temperaturePresetCB->combo()->addItem(i18n("Daylight D65"),                   QVariant(d->DaylightD65));
 
211
    d->temperaturePresetCB->combo()->addItem(i18n("Moonlight"),                      QVariant(d->MoonLight));
 
212
    d->temperaturePresetCB->combo()->addItem(i18n("Neutral"),                        QVariant(d->Neutral));
 
213
    d->temperaturePresetCB->combo()->addItem(i18n("Photo Flash"),                    QVariant(d->Flash));
 
214
    d->temperaturePresetCB->combo()->addItem(i18n("Studio Lamp"),                    QVariant(d->StudioLamp));
 
215
    d->temperaturePresetCB->combo()->addItem(i18n("Sun"),                            QVariant(d->Sun));
 
216
    d->temperaturePresetCB->combo()->addItem(i18n("Sunrise"),                        QVariant(d->Sunrise));
 
217
    d->temperaturePresetCB->combo()->addItem(i18n("Xenon Lamp"),                     QVariant(d->XenonLamp));
 
218
    d->temperaturePresetCB->combo()->addItem(i18nc("no temperature preset", "None"), QVariant(d->None));
 
219
    d->temperaturePresetCB->setDefaultIndex(d->temperaturePresetCB->combo()->findData(QVariant(d->DefaultTemperature)));
 
220
 
 
221
    QString toolTip = QString("<p>%1</p>").arg(i18n("Select the white balance color temperature preset to use."));
 
222
    toolTip += d->addTemperatureDescription(i18n("40 Watt incandescent lamp"),             d->Lamp40W);
 
223
    toolTip += d->addTemperatureDescription(i18n("100 Watt incandescent lamp"),            d->Lamp100W);
 
224
    toolTip += d->addTemperatureDescription(i18n("200 Watt incandescent lamp"),            d->Lamp200W);
 
225
    toolTip += d->addTemperatureDescription(i18n("candle light"),                          d->Candle);
 
226
    toolTip += d->addTemperatureDescription(i18n("sunny daylight around noon"),            d->DaylightD50);
 
227
    toolTip += d->addTemperatureDescription(i18n("overcast sky light"),                    d->DaylightD65);
 
228
    toolTip += d->addTemperatureDescription(i18n("moon light"),                            d->MoonLight);
 
229
    toolTip += d->addTemperatureDescription(i18n("neutral color temperature"),             d->Neutral);
 
230
    toolTip += d->addTemperatureDescription(i18n("electronic photo flash"),                d->Flash);
 
231
    toolTip += d->addTemperatureDescription(i18n("tungsten lamp used in photo studio or "
 
232
                                            "light at 1 hour from dusk/dawn"),        d->StudioLamp);
 
233
    toolTip += d->addTemperatureDescription(i18n("effective sun temperature"),             d->Sun);
 
234
    toolTip += d->addTemperatureDescription(i18n("sunrise or sunset light"),               d->Sunrise);
 
235
    toolTip += d->addTemperatureDescription(i18n("xenon lamp or light arc"),               d->XenonLamp);
 
236
    toolTip += d->addTemperatureDescription(i18n("no preset value"),                       d->None);
 
237
    d->temperaturePresetCB->setToolTip(toolTip);
 
238
 
 
239
    d->pickTemperature = new QToolButton;
 
240
    d->pickTemperature->setIcon(KIcon("color-picker-grey"));
 
241
    d->pickTemperature->setCheckable(true);
 
242
    d->pickTemperature->setToolTip( i18n( "Temperature tone color picker." ) );
 
243
    d->pickTemperature->setWhatsThis(i18n("With this button, you can pick the color from the original "
 
244
                                          "image used to set the white color balance temperature and "
 
245
                                          "green component."));
 
246
 
 
247
    KSeparator* line = new KSeparator(Qt::Horizontal);
 
248
 
 
249
    // -------------------------------------------------------------
 
250
 
 
251
    d->blackLabel = new QLabel(i18n("Black point:"));
 
252
    d->blackInput = new RDoubleNumInput;
 
253
    d->blackInput->setDecimals(2);
 
254
    d->blackInput->input()->setRange(0.0, 0.05, 0.01, true);
 
255
    d->blackInput->setWhatsThis( i18n("Set here the black level value."));
 
256
    d->blackInput->setDefaultValue(0.0);
 
257
 
 
258
    d->darkLabel = new QLabel(i18n("Shadows:"));
 
259
    d->darkInput = new RDoubleNumInput;
 
260
    d->darkInput->setDecimals(2);
 
261
    d->darkInput->input()->setRange(0.0, 1.0, 0.01, true);
 
262
    d->darkInput->setDefaultValue(0.5);
 
263
    d->darkInput->setWhatsThis( i18n("Set here the shadow noise suppression level."));
 
264
 
 
265
    d->saturationLabel = new QLabel(i18n("Saturation:"));
 
266
    d->saturationInput = new RDoubleNumInput;
 
267
    d->saturationInput->setDecimals(2);
 
268
    d->saturationInput->input()->setRange(0.0, 2.0, 0.01, true);
 
269
    d->saturationInput->setDefaultValue(1.0);
 
270
    d->saturationInput->setWhatsThis( i18n("Set here the saturation value."));
 
271
 
 
272
    d->gammaLabel = new QLabel(i18n("Gamma:"));
 
273
    d->gammaInput = new RDoubleNumInput;
 
274
    d->gammaInput->setDecimals(2);
 
275
    d->gammaInput->input()->setRange(0.1, 3.0, 0.01, true);
 
276
    d->gammaInput->setDefaultValue(1.0);
 
277
    d->gammaInput->setWhatsThis( i18n("Set here the gamma correction value."));
 
278
 
 
279
    d->greenLabel = new QLabel(i18n("Green:"));
 
280
    d->greenInput = new RDoubleNumInput;
 
281
    d->greenInput->setDecimals(2);
 
282
    d->greenInput->input()->setRange(0.2, 2.5, 0.01, true);
 
283
    d->greenInput->setDefaultValue(1.0);
 
284
    d->greenInput->setWhatsThis(i18n("Set here the green component to control the magenta color "
 
285
                                     "cast removal level."));
 
286
 
 
287
    KSeparator* line2 = new KSeparator(Qt::Horizontal);
 
288
 
 
289
    // -------------------------------------------------------------
 
290
 
 
291
    d->exposureLabel = new QLabel(i18n("<a href='http://en.wikipedia.org/wiki/Exposure_value'>"
 
292
                                       "Exposure Compensation</a> (E.V): "));
 
293
    d->exposureLabel->setOpenExternalLinks(true);
 
294
 
 
295
    d->mainExposureLabel  = new QLabel(i18nc("main exposure value", "Main:"));
 
296
    d->autoAdjustExposure = new QToolButton;
 
297
    d->autoAdjustExposure->setIcon(KIconLoader::global()->loadIcon("system-run", KIconLoader::Toolbar));
 
298
    d->autoAdjustExposure->setToolTip( i18n( "Auto exposure adjustments" ) );
 
299
    d->autoAdjustExposure->setWhatsThis(i18n("With this button, you can automatically adjust Exposure "
 
300
                                        "and Black Point values."));
 
301
    d->mainExposureInput = new RDoubleNumInput;
 
302
    d->mainExposureInput->setDecimals(2);
 
303
    d->mainExposureInput->input()->setRange(-6.0, 8.0, 0.1, true);
 
304
    d->mainExposureInput->setDefaultValue(0.0);
 
305
    d->mainExposureInput->setWhatsThis( i18n("Set here the main exposure compensation value in E.V."));
 
306
 
 
307
    d->fineExposureLabel = new QLabel(i18nc("fine exposure adjustment", "Fine:"));
 
308
    d->fineExposureInput = new RDoubleNumInput;
 
309
    d->fineExposureInput->setDecimals(2);
 
310
    d->fineExposureInput->input()->setRange(-0.5, 0.5, 0.01, true);
 
311
    d->fineExposureInput->setDefaultValue(0.0);
 
312
    d->fineExposureInput->setWhatsThis(i18n("This value in E.V will be added to main exposure "
 
313
                                            "compensation value to set fine exposure adjustment."));
 
314
 
 
315
    // -------------------------------------------------------------
 
316
 
 
317
    grid->addWidget(d->temperatureLabel,        0, 0, 1, 6);
 
318
    grid->addWidget(d->adjTemperatureLabel,     1, 0, 1, 1);
 
319
    grid->addWidget(d->pickTemperature,         1, 1, 1, 1);
 
320
    grid->addWidget(d->temperatureInput,        1, 2, 1, 4);
 
321
    grid->addWidget(d->temperaturePresetLabel,  2, 0, 1, 1);
 
322
    grid->addWidget(d->temperaturePresetCB,     2, 2, 1, 4);
 
323
    grid->addWidget(line,                       3, 0, 1, 6);
 
324
    grid->addWidget(d->blackLabel,              4, 0, 1, 1);
 
325
    grid->addWidget(d->blackInput,              4, 1, 1, 5);
 
326
    grid->addWidget(d->darkLabel,               5, 0, 1, 1);
 
327
    grid->addWidget(d->darkInput,               5, 1, 1, 5);
 
328
    grid->addWidget(d->saturationLabel,         6, 0, 1, 1);
 
329
    grid->addWidget(d->saturationInput,         6, 1, 1, 5);
 
330
    grid->addWidget(d->gammaLabel,              7, 0, 1, 1);
 
331
    grid->addWidget(d->gammaInput,              7, 1, 1, 5);
 
332
    grid->addWidget(d->greenLabel,              8, 0, 1, 1);
 
333
    grid->addWidget(d->greenInput,              8, 1, 1, 5);
 
334
    grid->addWidget(line2,                      9, 0, 1, 6);
 
335
    grid->addWidget(d->exposureLabel,          10, 0, 1, 6);
 
336
    grid->addWidget(d->mainExposureLabel,      11, 0, 1, 1);
 
337
    grid->addWidget(d->autoAdjustExposure,     11, 1, 1, 1);
 
338
    grid->addWidget(d->mainExposureInput,      11, 2, 1, 4);
 
339
    grid->addWidget(d->fineExposureLabel,      12, 0, 1, 2);
 
340
    grid->addWidget(d->fineExposureInput,      12, 2, 1, 4);
 
341
    grid->setRowStretch(13, 10);
 
342
    grid->setMargin(KDialog::spacingHint());
 
343
    grid->setSpacing(KDialog::spacingHint());
 
344
 
 
345
    // -------------------------------------------------------------
 
346
 
 
347
    connect(d->temperaturePresetCB, SIGNAL(activated(int)),
 
348
            this, SLOT(slotTemperaturePresetChanged(int)));
 
349
 
 
350
    connect(d->temperatureInput, SIGNAL(valueChanged(double)),
 
351
            this, SLOT(slotTemperatureChanged(double)));
 
352
 
 
353
    connect(d->darkInput, SIGNAL(valueChanged(double)),
 
354
            this, SIGNAL(signalSettingsChanged()));
 
355
 
 
356
    connect(d->blackInput, SIGNAL(valueChanged(double)),
 
357
            this, SIGNAL(signalSettingsChanged()));
 
358
 
 
359
    connect(d->mainExposureInput, SIGNAL(valueChanged(double)),
 
360
            this, SIGNAL(signalSettingsChanged()));
 
361
 
 
362
    connect(d->fineExposureInput, SIGNAL(valueChanged(double)),
 
363
            this, SIGNAL(signalSettingsChanged()));
 
364
 
 
365
    connect(d->gammaInput, SIGNAL(valueChanged(double)),
 
366
            this, SIGNAL(signalSettingsChanged()));
 
367
 
 
368
    connect(d->saturationInput, SIGNAL(valueChanged(double)),
 
369
            this, SIGNAL(signalSettingsChanged()));
 
370
 
 
371
    connect(d->greenInput, SIGNAL(valueChanged(double)),
 
372
            this, SIGNAL(signalSettingsChanged()));
 
373
 
 
374
    connect(d->autoAdjustExposure, SIGNAL(clicked()),
 
375
            this, SIGNAL(signalAutoAdjustExposure()));
 
376
 
 
377
    connect(d->pickTemperature, SIGNAL(released()),
 
378
            this, SIGNAL(signalPickerColorButtonActived()));
 
379
}
 
380
 
 
381
WBSettings::~WBSettings()
 
382
{
 
383
    delete d;
 
384
}
 
385
 
 
386
bool WBSettings::pickTemperatureIsOn()
 
387
{
 
388
    return d->pickTemperature->isChecked();
 
389
}
 
390
 
 
391
void WBSettings::setOnPickTemperature(bool b)
 
392
{
 
393
    d->pickTemperature->setChecked(b);
 
394
}
 
395
 
 
396
void WBSettings::showAdvancedButtons(bool b)
 
397
{
 
398
    d->pickTemperature->setVisible(b);
 
399
    d->autoAdjustExposure->setVisible(b);
 
400
}
 
401
 
 
402
void WBSettings::slotTemperatureChanged(double temperature)
 
403
{
 
404
    int index = d->temperaturePresetCB->combo()->findData(QVariant((int)temperature));
 
405
 
 
406
    if (index == -1)
 
407
    {
 
408
        index = d->temperaturePresetCB->combo()->findData(QVariant((int)d->None));
 
409
    }
 
410
 
 
411
    d->temperaturePresetCB->setCurrentIndex(index);
 
412
 
 
413
    emit signalSettingsChanged();
 
414
}
 
415
 
 
416
void WBSettings::slotTemperaturePresetChanged(int tempPreset)
 
417
{
 
418
    bool ok         = true;
 
419
    int temperature = d->temperaturePresetCB->combo()->itemData(tempPreset).toInt(&ok);
 
420
 
 
421
    if (!ok)
 
422
    {
 
423
        temperature = d->DefaultTemperature;
 
424
    }
 
425
 
 
426
    if (temperature != -1)
 
427
    {
 
428
        d->temperatureInput->setValue((double)temperature);
 
429
    }
 
430
 
 
431
    emit signalSettingsChanged();
 
432
}
 
433
 
 
434
WBContainer WBSettings::settings() const
 
435
{
 
436
    WBContainer prm;
 
437
 
 
438
    prm.black       = d->blackInput->value();
 
439
    prm.exposition  = d->mainExposureInput->value() + d->fineExposureInput->value();
 
440
    prm.temperature = d->temperatureInput->value();
 
441
    prm.green       = d->greenInput->value();
 
442
    prm.dark        = d->darkInput->value();
 
443
    prm.gamma       = d->gammaInput->value();
 
444
    prm.saturation  = d->saturationInput->value();
 
445
 
 
446
    return prm;
 
447
}
 
448
 
 
449
void WBSettings::setSettings(const WBContainer& settings)
 
450
{
 
451
    blockSignals(true);
 
452
 
 
453
    d->blackInput->setValue(settings.black);
 
454
    d->mainExposureInput->setValue(double(int(settings.exposition)));
 
455
    d->fineExposureInput->setValue(settings.exposition - d->mainExposureInput->value());
 
456
    d->temperatureInput->setValue(settings.temperature);
 
457
    d->greenInput->setValue(settings.green);
 
458
    d->darkInput->setValue(settings.dark);
 
459
    d->gammaInput->setValue(settings.gamma);
 
460
    d->saturationInput->setValue(settings.saturation);
 
461
    slotTemperatureChanged(d->temperatureInput->value());
 
462
 
 
463
    blockSignals(false);
 
464
}
 
465
 
 
466
void WBSettings::resetToDefault()
 
467
{
 
468
    blockSignals(true);
 
469
 
 
470
    // Neutral color temperature settings is D65.
 
471
    d->blackInput->slotReset();
 
472
    d->darkInput->slotReset();
 
473
    d->fineExposureInput->slotReset();
 
474
    d->gammaInput->slotReset();
 
475
    d->greenInput->slotReset();
 
476
    d->mainExposureInput->slotReset();
 
477
    d->saturationInput->slotReset();
 
478
    d->temperatureInput->slotReset();
 
479
    d->temperaturePresetCB->slotReset();
 
480
    slotTemperaturePresetChanged(d->temperaturePresetCB->defaultIndex());
 
481
 
 
482
    blockSignals(false);
 
483
}
 
484
 
 
485
WBContainer WBSettings::defaultSettings() const
 
486
{
 
487
    WBContainer prm;
 
488
 
 
489
    prm.black       = d->blackInput->defaultValue();
 
490
    prm.exposition  = d->mainExposureInput->defaultValue() + d->fineExposureInput->defaultValue();
 
491
    prm.temperature = d->temperatureInput->defaultValue();
 
492
    prm.green       = d->greenInput->defaultValue();
 
493
    prm.dark        = d->darkInput->defaultValue();
 
494
    prm.gamma       = d->gammaInput->defaultValue();
 
495
    prm.saturation  = d->saturationInput->defaultValue();
 
496
 
 
497
    return prm;
 
498
}
 
499
 
 
500
void WBSettings::readSettings(KConfigGroup& group)
 
501
{
 
502
    WBContainer prm;
 
503
//    WBContainer defaultPrm = defaultSettings();
 
504
 
 
505
    prm.black       = group.readEntry(d->configBlackInputEntry,       d->blackInput->defaultValue());
 
506
    prm.temperature = group.readEntry(d->configTemperatureInputEntry, d->temperatureInput->defaultValue());
 
507
    prm.green       = group.readEntry(d->configGreenInputEntry,       d->greenInput->defaultValue());
 
508
    prm.dark        = group.readEntry(d->configDarkInputEntry,        d->darkInput->defaultValue());
 
509
    prm.gamma       = group.readEntry(d->configGammaInputEntry,       d->gammaInput->defaultValue());
 
510
    prm.saturation  = group.readEntry(d->configSaturationInputEntry,  d->saturationInput->defaultValue());
 
511
    double fineExpo = group.readEntry(d->configFineExposureEntry,     d->fineExposureInput->defaultValue());
 
512
    prm.exposition  = group.readEntry(d->configMainExposureEntry,     d->mainExposureInput->defaultValue()) + fineExpo;
 
513
 
 
514
    setSettings(prm);
 
515
}
 
516
 
 
517
void WBSettings::writeSettings(KConfigGroup& group)
 
518
{
 
519
//    WBContainer prm = settings();
 
520
 
 
521
    group.writeEntry(d->configDarkInputEntry,        d->darkInput->value());
 
522
    group.writeEntry(d->configBlackInputEntry,       d->blackInput->value());
 
523
    group.writeEntry(d->configMainExposureEntry,     d->mainExposureInput->value());
 
524
    group.writeEntry(d->configFineExposureEntry,     d->fineExposureInput->value());
 
525
    group.writeEntry(d->configGammaInputEntry,       d->gammaInput->value());
 
526
    group.writeEntry(d->configSaturationInputEntry,  d->saturationInput->value());
 
527
    group.writeEntry(d->configGreenInputEntry,       d->greenInput->value());
 
528
    group.writeEntry(d->configTemperatureInputEntry, d->temperatureInput->value());
 
529
}
 
530
 
 
531
void WBSettings::loadSettings()
 
532
{
 
533
    KUrl loadWhiteBalanceFile = KFileDialog::getOpenUrl(KGlobalSettings::documentPath(),
 
534
                                QString( "*" ), kapp->activeWindow(),
 
535
                                QString(i18n("White Color Balance Settings File to Load")));
 
536
 
 
537
    if (loadWhiteBalanceFile.isEmpty())
 
538
    {
 
539
        return;
 
540
    }
 
541
 
 
542
    QFile file(loadWhiteBalanceFile.toLocalFile());
 
543
 
 
544
    if (file.open(QIODevice::ReadOnly))
 
545
    {
 
546
        QTextStream stream(&file);
 
547
 
 
548
        if (stream.readLine() != "# White Color Balance Configuration File V2")
 
549
        {
 
550
            KMessageBox::error(kapp->activeWindow(),
 
551
                               i18n("\"%1\" is not a White Color Balance settings text file.",
 
552
                                    loadWhiteBalanceFile.fileName()));
 
553
            file.close();
 
554
            return;
 
555
        }
 
556
 
 
557
        blockSignals(true);
 
558
        d->temperatureInput->setValue(stream.readLine().toDouble());
 
559
        d->darkInput->setValue(stream.readLine().toDouble());
 
560
        d->blackInput->setValue(stream.readLine().toDouble());
 
561
        d->mainExposureInput->setValue(stream.readLine().toDouble());
 
562
        d->fineExposureInput->setValue(stream.readLine().toDouble());
 
563
        d->gammaInput->setValue(stream.readLine().toDouble());
 
564
        d->saturationInput->setValue(stream.readLine().toDouble());
 
565
        d->greenInput->setValue(stream.readLine().toDouble());
 
566
        slotTemperatureChanged(d->temperatureInput->value());
 
567
        blockSignals(false);
 
568
    }
 
569
    else
 
570
    {
 
571
        KMessageBox::error(kapp->activeWindow(),
 
572
                           i18n("Cannot load settings from the White Color Balance text file."));
 
573
    }
 
574
 
 
575
    file.close();
 
576
}
 
577
 
 
578
void WBSettings::saveAsSettings()
 
579
{
 
580
    KUrl saveWhiteBalanceFile = KFileDialog::getSaveUrl(KGlobalSettings::documentPath(),
 
581
                                QString( "*" ), kapp->activeWindow(),
 
582
                                QString( i18n("White Color Balance Settings File to Save")));
 
583
 
 
584
    if ( saveWhiteBalanceFile.isEmpty() )
 
585
    {
 
586
        return;
 
587
    }
 
588
 
 
589
    QFile file(saveWhiteBalanceFile.toLocalFile());
 
590
 
 
591
    if ( file.open(QIODevice::WriteOnly) )
 
592
    {
 
593
        QTextStream stream( &file );
 
594
        stream << "# White Color Balance Configuration File V2\n";
 
595
        stream << d->temperatureInput->value() << "\n";
 
596
        stream << d->darkInput->value() << "\n";
 
597
        stream << d->blackInput->value() << "\n";
 
598
        stream << d->mainExposureInput->value() << "\n";
 
599
        stream << d->fineExposureInput->value() << "\n";
 
600
        stream << d->gammaInput->value() << "\n";
 
601
        stream << d->saturationInput->value() << "\n";
 
602
        stream << d->greenInput->value() << "\n";
 
603
    }
 
604
    else
 
605
    {
 
606
        KMessageBox::error(kapp->activeWindow(),
 
607
                           i18n("Cannot save settings to the White Color Balance text file."));
 
608
    }
 
609
 
 
610
    file.close();
 
611
}
 
612
 
 
613
}  // namespace Digikam