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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201 | /* ============================================================
*
* This file is a part of digiKam project
* https://www.digikam.org
*
* Date : 2010-02-11
* Description : Color Balance settings view.
*
* SPDX-FileCopyrightText: 2010-2026 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* ============================================================ */
#include "cbsettings.h"
// Qt includes
#include <QGridLayout>
#include <QSlider>
#include <QLabel>
#include <QString>
#include <QFile>
#include <QTextStream>
#include <QUrl>
#include <QApplication>
#include <QStyle>
// KDE includes
#include <kconfiggroup.h>
#include <klocalizedstring.h>
// Local includes
#include "dexpanderbox.h"
#include "dnuminput.h"
#include "digikam_debug.h"
namespace Digikam
{
class Q_DECL_HIDDEN CBSettings::Private
{
public:
Private() = default;
const QString configRedAdjustmentEntry = QLatin1String("RedAdjustment");
const QString configGreenAdjustmentEntry = QLatin1String("GreenAdjustment");
const QString configBlueAdjustmentEntry = QLatin1String("BlueAdjustment");
DIntNumInput* rInput = nullptr;
DIntNumInput* gInput = nullptr;
DIntNumInput* bInput = nullptr;
};
// --------------------------------------------------------
CBSettings::CBSettings(QWidget* const parent)
: QWidget(parent),
d (new Private)
{
const int spacing = layoutSpacing();
QGridLayout* const grid = new QGridLayout(parent);
QLabel* const labelCyan = new QLabel(i18nc("@label: color", "Cyan"));
labelCyan->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
d->rInput = new DIntNumInput();
d->rInput->setRange(-100, 100, 1);
d->rInput->setDefaultValue(0);
d->rInput->setWhatsThis(i18nc("@info", "Set here the cyan/red color adjustment of the image."));
QLabel* const labelRed = new QLabel(i18nc("@label: color", "Red"));
labelRed->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
// -------------------------------------------------------------
QLabel* const labelMagenta = new QLabel(i18nc("@label: color", "Magenta"));
labelMagenta->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
d->gInput = new DIntNumInput();
d->gInput->setRange(-100, 100, 1);
d->gInput->setDefaultValue(0);
d->gInput->setWhatsThis(i18nc("@info", "Set here the magenta/green color adjustment of the image."));
QLabel* const labelGreen = new QLabel(i18nc("@label: color", "Green"));
labelGreen->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
// -------------------------------------------------------------
QLabel* const labelYellow = new QLabel(i18nc("@label: color", "Yellow"));
labelYellow->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
QLabel* const labelBlue = new QLabel(i18nc("@label: color", "Blue"));
labelBlue->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
d->bInput = new DIntNumInput();
d->bInput->setRange(-100, 100, 1);
d->bInput->setDefaultValue(0);
d->bInput->setWhatsThis(i18nc("@info", "Set here the yellow/blue color adjustment of the image."));
// -------------------------------------------------------------
grid->addWidget(labelCyan, 0, 0, 1, 1);
grid->addWidget(d->rInput, 0, 1, 1, 1);
grid->addWidget(labelRed, 0, 2, 1, 1);
grid->addWidget(labelMagenta, 1, 0, 1, 1);
grid->addWidget(d->gInput, 1, 1, 1, 1);
grid->addWidget(labelGreen, 1, 2, 1, 1);
grid->addWidget(labelYellow, 2, 0, 1, 1);
grid->addWidget(d->bInput, 2, 1, 1, 1);
grid->addWidget(labelBlue, 2, 2, 1, 1);
grid->setContentsMargins(spacing, spacing, spacing, spacing);
grid->setSpacing(spacing);
grid->setRowStretch(3, 10);
// -------------------------------------------------------------
connect(d->rInput, SIGNAL(valueChanged(int)),
this, SIGNAL(signalSettingsChanged()));
connect(d->gInput, SIGNAL(valueChanged(int)),
this, SIGNAL(signalSettingsChanged()));
connect(d->bInput, SIGNAL(valueChanged(int)),
this, SIGNAL(signalSettingsChanged()));
}
CBSettings::~CBSettings()
{
delete d;
}
CBContainer CBSettings::settings() const
{
CBContainer prm;
prm.red = ((double)d->rInput->value() + 100.0) / 100.0;
prm.green = ((double)d->gInput->value() + 100.0) / 100.0;
prm.blue = ((double)d->bInput->value() + 100.0) / 100.0;
return prm;
}
void CBSettings::setSettings(const CBContainer& settings)<--- Shadow argument
{
blockSignals(true);
d->rInput->setValue((int)((settings.red * 100.0) - 100.0));
d->gInput->setValue((int)((settings.green * 100.0) - 100.0));
d->bInput->setValue((int)((settings.blue * 100.0) - 100.0));
blockSignals(false);
}
void CBSettings::resetToDefault()
{
blockSignals(true);
d->rInput->slotReset();
d->gInput->slotReset();
d->bInput->slotReset();
blockSignals(false);
}
CBContainer CBSettings::defaultSettings() const
{
CBContainer prm;
prm.red = ((double)d->rInput->defaultValue() + 100.0) / 100.0;
prm.green = ((double)d->gInput->defaultValue() + 100.0) / 100.0;
prm.blue = ((double)d->bInput->defaultValue() + 100.0) / 100.0;
return prm;
}
void CBSettings::readSettings(const KConfigGroup& group)
{
CBContainer prm;
CBContainer defaultPrm = defaultSettings();
prm.red = group.readEntry(d->configRedAdjustmentEntry, defaultPrm.red);
prm.green = group.readEntry(d->configGreenAdjustmentEntry, defaultPrm.green);
prm.blue = group.readEntry(d->configBlueAdjustmentEntry, defaultPrm.blue);
setSettings(prm);
}
void CBSettings::writeSettings(KConfigGroup& group)
{
CBContainer prm = settings();
group.writeEntry(d->configRedAdjustmentEntry, prm.red);
group.writeEntry(d->configGreenAdjustmentEntry, prm.green);
group.writeEntry(d->configBlueAdjustmentEntry, prm.blue);
}
} // namespace Digikam
#include "moc_cbsettings.cpp"
|