1
/* ============================================================
3
* This file is a part of digiKam project
4
* http://www.digikam.org
7
* Description : Color Balance settings view.
9
* Copyright (C) 2010 by Gilles Caulier <caulier dot gilles at gmail dot com>
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)
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.
22
* ============================================================ */
24
#include "cbsettings.moc"
28
#include <QGridLayout>
33
#include <QTextStream>
41
#include <kapplication.h>
42
#include <kfiledialog.h>
44
#include <kglobalsettings.h>
45
#include <kmessagebox.h>
46
#include <kstandarddirs.h>
50
#include <libkdcraw/rnuminput.h>
54
#include "rexpanderbox.h"
56
using namespace KDcrawIface;
66
configRedAdjustmentEntry("RedAdjustment"),
67
configGreenAdjustmentEntry("GreenAdjustment"),
68
configBlueAdjustmentEntry("BlueAdjustment"),
74
const QString configRedAdjustmentEntry;
75
const QString configGreenAdjustmentEntry;
76
const QString configBlueAdjustmentEntry;
83
CBSettings::CBSettings(QWidget* parent)
87
QGridLayout* grid = new QGridLayout(parent);
89
QLabel* labelCyan = new QLabel(i18n("Cyan"));
90
labelCyan->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
92
d->rInput = new RIntNumInput();
93
d->rInput->setRange(-100, 100, 1);
94
d->rInput->setSliderEnabled(true);
95
d->rInput->setDefaultValue(0);
96
d->rInput->setWhatsThis(i18n("Set here the cyan/red color adjustment of the image."));
98
QLabel *labelRed = new QLabel(i18n("Red"));
99
labelRed->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
101
// -------------------------------------------------------------
103
QLabel *labelMagenta = new QLabel(i18n("Magenta"));
104
labelMagenta->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
106
d->gInput = new RIntNumInput();
107
d->gInput->setRange(-100, 100, 1);
108
d->gInput->setSliderEnabled(true);
109
d->gInput->setDefaultValue(0);
110
d->gInput->setWhatsThis(i18n("Set here the magenta/green color adjustment of the image."));
112
QLabel *labelGreen = new QLabel(i18n("Green"));
113
labelGreen->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
115
// -------------------------------------------------------------
117
QLabel *labelYellow = new QLabel(i18n("Yellow"));
118
labelYellow->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
120
QLabel *labelBlue = new QLabel(i18n("Blue"));
121
labelBlue->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
123
d->bInput = new RIntNumInput();
124
d->bInput->setRange(-100, 100, 1);
125
d->bInput->setSliderEnabled(true);
126
d->bInput->setDefaultValue(0);
127
d->bInput->setWhatsThis(i18n("Set here the yellow/blue color adjustment of the image."));
129
// -------------------------------------------------------------
131
grid->addWidget(labelCyan, 0, 0, 1, 1);
132
grid->addWidget(d->rInput, 0, 1, 1, 1);
133
grid->addWidget(labelRed, 0, 2, 1, 1);
134
grid->addWidget(labelMagenta, 1, 0, 1, 1);
135
grid->addWidget(d->gInput, 1, 1, 1, 1);
136
grid->addWidget(labelGreen, 1, 2, 1, 1);
137
grid->addWidget(labelYellow, 2, 0, 1, 1);
138
grid->addWidget(d->bInput, 2, 1, 1, 1);
139
grid->addWidget(labelBlue, 2, 2, 1, 1);
140
grid->setMargin(KDialog::spacingHint());
141
grid->setSpacing(KDialog::spacingHint());
142
grid->setRowStretch(3, 10);
144
// -------------------------------------------------------------
146
connect(d->rInput, SIGNAL(valueChanged (int)),
147
this, SIGNAL(signalSettingsChanged()));
149
connect(d->gInput, SIGNAL(valueChanged (int)),
150
this, SIGNAL(signalSettingsChanged()));
152
connect(d->bInput, SIGNAL(valueChanged (int)),
153
this, SIGNAL(signalSettingsChanged()));
156
CBSettings::~CBSettings()
161
CBContainer CBSettings::settings() const
165
prm.red = ((double)d->rInput->value() + 100.0)/100.0;
166
prm.green = ((double)d->gInput->value() + 100.0)/100.0;
167
prm.blue = ((double)d->bInput->value() + 100.0)/100.0;
172
void CBSettings::setSettings(const CBContainer& settings)
175
d->rInput->setValue((int)(settings.red * 100.0) - 100.0);
176
d->gInput->setValue((int)(settings.green * 100.0) - 100.0);
177
d->bInput->setValue((int)(settings.blue * 100.0) - 100.0);
181
void CBSettings::resetToDefault()
184
d->rInput->slotReset();
185
d->gInput->slotReset();
186
d->bInput->slotReset();
190
CBContainer CBSettings::defaultSettings() const
194
prm.red = ((double)d->rInput->defaultValue() + 100.0)/100.0;
195
prm.green = ((double)d->gInput->defaultValue() + 100.0)/100.0;
196
prm.blue = ((double)d->bInput->defaultValue() + 100.0)/100.0;
201
void CBSettings::readSettings(KConfigGroup& group)
204
CBContainer defaultPrm = defaultSettings();
206
prm.red = group.readEntry(d->configRedAdjustmentEntry, defaultPrm.red);
207
prm.green = group.readEntry(d->configGreenAdjustmentEntry, defaultPrm.green);
208
prm.blue = group.readEntry(d->configBlueAdjustmentEntry, defaultPrm.blue);
213
void CBSettings::writeSettings(KConfigGroup& group)
215
CBContainer prm = settings();
217
group.writeEntry(d->configRedAdjustmentEntry, prm.red);
218
group.writeEntry(d->configGreenAdjustmentEntry, prm.green);
219
group.writeEntry(d->configBlueAdjustmentEntry, prm.blue);
222
} // namespace Digikam