summaryrefslogtreecommitdiffstats
path: root/digikam/utilities/setup/setupdcraw.cpp
blob: 929e1d4fef8e1080ee3abcbcf030abc9807da2b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/* ============================================================
 *
 * This file is a part of digiKam project
 * http://www.digikam.org
 *
 * Date        : 2007-02-06
 * Description : setup RAW decoding settings.
 *
 * Copyright (C) 2007-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
 *
 * This program is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General
 * Public License as published by the Free Software Foundation;
 * either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * ============================================================ */

// TQt includes.

#include <tqlayout.h>
#include <tqlabel.h>
#include <tqcolor.h>
#include <tqhbox.h>
#include <tqvgroupbox.h>
#include <tqlabel.h>
#include <tqwhatsthis.h>
#include <tqcheckbox.h>
#include <tqcombobox.h>

// KDE includes.

#include <tdelocale.h>
#include <kiconloader.h>
#include <kdialog.h>
#include <tdeconfig.h>
#include <tdeapplication.h>

// LibKDcraw includes.

#include <libkdcraw/version.h>
#include <libkdcraw/dcrawsettingswidget.h>

// Local includes.

#include "drawdecoding.h"
#include "setupdcraw.h"
#include "setupdcraw.moc"

using namespace KDcrawIface;

namespace Digikam
{

class SetupDcrawPriv
{
public:


    SetupDcrawPriv()
    {
        dcrawSettings = 0;
    }

    KDcrawIface::DcrawSettingsWidget *dcrawSettings;
};

SetupDcraw::SetupDcraw(TQWidget* parent )
          : TQWidget(parent)
{
    d = new SetupDcrawPriv;
    TQVBoxLayout *layout = new TQVBoxLayout(parent, 0, KDialog::spacingHint());
    d->dcrawSettings    = new DcrawSettingsWidget(parent, DcrawSettingsWidget::SIXTEENBITS);
    d->dcrawSettings->setItemIconSet(0, SmallIconSet("kdcraw"));
    d->dcrawSettings->setItemIconSet(1, SmallIconSet("whitebalance"));
    d->dcrawSettings->setItemIconSet(2, SmallIconSet("lensdistortion"));
    layout->addWidget(d->dcrawSettings);
    layout->addStretch();

    connect(d->dcrawSettings, TQT_SIGNAL(signalSixteenBitsImageToggled(bool)),
            this, TQT_SLOT(slotSixteenBitsImageToggled(bool)));

    readSettings();
}

SetupDcraw::~SetupDcraw()
{
    delete d;
}

void SetupDcraw::slotSixteenBitsImageToggled(bool)
{
    // Dcraw do not provide a way to set brigness of image in 16 bits color depth.
    // We always set on this option. We drive brightness adjustment in digiKam Raw image loader.
    d->dcrawSettings->setEnabledBrightnessSettings(true);
}

void SetupDcraw::applySettings()
{
    TDEConfig* config = kapp->config();
    config->setGroup("ImageViewer Settings");
    config->writeEntry("SixteenBitsImage",        d->dcrawSettings->sixteenBits());
    config->writeEntry("WhiteBalance",            d->dcrawSettings->whiteBalance());
    config->writeEntry("CustomWhiteBalance",      d->dcrawSettings->customWhiteBalance());
    config->writeEntry("CustomWhiteBalanceGreen", d->dcrawSettings->customWhiteBalanceGreen());
    config->writeEntry("RGBInterpolate4Colors",   d->dcrawSettings->useFourColor());
    config->writeEntry("DontStretchPixels",       d->dcrawSettings->useDontStretchPixels());
    config->writeEntry("EnableNoiseReduction",    d->dcrawSettings->useNoiseReduction());
    config->writeEntry("NRThreshold",             d->dcrawSettings->NRThreshold());
    config->writeEntry("EnableCACorrection",      d->dcrawSettings->useCACorrection());
    config->writeEntry("caRedMultiplier",         d->dcrawSettings->caRedMultiplier());
    config->writeEntry("caBlueMultiplier",        d->dcrawSettings->caBlueMultiplier());
    config->writeEntry("UnclipColors",            d->dcrawSettings->unclipColor());
    config->writeEntry("RAWBrightness",           d->dcrawSettings->brightness());
    config->writeEntry("RAWQuality",              d->dcrawSettings->quality());
    config->writeEntry("MedianFilterPasses",      d->dcrawSettings->medianFilterPasses());
    config->sync();
}

void SetupDcraw::readSettings()
{
    TDEConfig* config = kapp->config();
    config->setGroup("ImageViewer Settings");
    d->dcrawSettings->setSixteenBits(config->readBoolEntry("SixteenBitsImage", false));
    d->dcrawSettings->setNoiseReduction(config->readBoolEntry("EnableNoiseReduction", false));
    d->dcrawSettings->setNRThreshold(config->readNumEntry("NRThreshold", 100));
    d->dcrawSettings->setUseCACorrection(config->readBoolEntry("EnableCACorrection", false));
    d->dcrawSettings->setcaRedMultiplier(config->readDoubleNumEntry("caRedMultiplier", 1.0));
    d->dcrawSettings->setcaBlueMultiplier(config->readDoubleNumEntry("caBlueMultiplier", 1.0));
    d->dcrawSettings->setDontStretchPixels(config->readBoolEntry("DontStretchPixels", false));
    d->dcrawSettings->setUnclipColor(config->readNumEntry("UnclipColors", 0));
    d->dcrawSettings->setWhiteBalance((DRawDecoding::WhiteBalance)
                                      config->readNumEntry("WhiteBalance",
                                      DRawDecoding::CAMERA));
    d->dcrawSettings->setCustomWhiteBalance(config->readNumEntry("CustomWhiteBalance", 6500));
    d->dcrawSettings->setCustomWhiteBalanceGreen(config->readDoubleNumEntry("CustomWhiteBalanceGreen", 1.0));
    d->dcrawSettings->setFourColor(config->readBoolEntry("RGBInterpolate4Colors", false));
    d->dcrawSettings->setQuality((DRawDecoding::DecodingQuality)
                                  config->readNumEntry("RAWQuality",
                                  DRawDecoding::BILINEAR));
    d->dcrawSettings->setBrightness(config->readDoubleNumEntry("RAWBrightness", 1.0));
    d->dcrawSettings->setMedianFilterPasses(config->readNumEntry("MedianFilterPasses", 0));
}

}  // namespace Digikam