-
Notifications
You must be signed in to change notification settings - Fork 10
/
rgbadjustments.cpp
146 lines (126 loc) · 4.4 KB
/
rgbadjustments.cpp
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
#include "rgbadjustments.h"
#include "ui_rgbadjustments.h"
rgbAdjustments::rgbAdjustments(QWidget *parent) :
QDialog(parent),
ui(new Ui::rgbAdjustments)
{
ui->setupUi(this);
this->setWindowTitle("RGB Levels");
emitUpdateSignal = false;
connect(ui->redSlider, &QSlider::valueChanged,
[=](const int &newValue) {
ui->redSpin->blockSignals(true);
ui->redSpin->setValue(newValue);
ui->redSpin->blockSignals(false);
redLevel = newValue / 100.0;
if(emitUpdateSignal)
emit haveRGBLevels(redLevel, greenLevel, blueLevel, gammaLevel, false);
});
connect(ui->greenSlider, &QSlider::valueChanged,
[=](const int &newValue) {
ui->greenSpin->blockSignals(true);
ui->greenSpin->setValue(newValue);
ui->greenSpin->blockSignals(false);
greenLevel = newValue / 100.0;
if(emitUpdateSignal)
emit haveRGBLevels(redLevel, greenLevel, blueLevel, gammaLevel, false);
});
connect(ui->blueSlider, &QSlider::valueChanged,
[=](const int &newValue) {
ui->blueSpin->blockSignals(true);
ui->blueSpin->setValue(newValue);
ui->blueSpin->blockSignals(false);
blueLevel = newValue / 100.0;
if(emitUpdateSignal)
emit haveRGBLevels(redLevel, greenLevel, blueLevel, gammaLevel, false);
});
connect(ui->redSpin, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
[=](const int &newValue) {
ui->redSlider->blockSignals(true);
ui->redSlider->setValue(newValue);
ui->redSlider->blockSignals(false);
redLevel = newValue / 100.0;
if(emitUpdateSignal)
emit haveRGBLevels(redLevel, greenLevel, blueLevel, gammaLevel, false);
});
connect(ui->greenSpin, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
[=](const int &newValue) {
ui->greenSlider->blockSignals(true);
ui->greenSlider->setValue(newValue);
ui->greenSlider->blockSignals(false);
greenLevel = newValue / 100.0;
if(emitUpdateSignal)
emit haveRGBLevels(redLevel, greenLevel, blueLevel, gammaLevel, false);
});
connect(ui->blueSpin, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
[=](const int &newValue) {
ui->blueSlider->blockSignals(true);
ui->blueSlider->setValue(newValue);
ui->blueSlider->blockSignals(false);
blueLevel = newValue / 100.0;
if(emitUpdateSignal)
emit haveRGBLevels(redLevel, greenLevel, blueLevel, gammaLevel, false);
});
connect(ui->gammaSlider, &QSlider::valueChanged,
[=](const int &newValue) {
ui->gammaSpin->setValue(newValue / 1000.0);
});
emitUpdateSignal = true;
ui->gammaSlider->setEnabled(false);
ui->gammaSpin->setEnabled(false);
}
rgbAdjustments::~rgbAdjustments()
{
delete ui;
}
void rgbAdjustments::setRGBLevels(double r, double g, double b, double gamma)
{
emitUpdateSignal = false;
ui->redSpin->setValue((int)(r*100));
ui->greenSpin->setValue((int)(g*100));
ui->blueSpin->setValue((int)(b*100));
ui->gammaSpin->setValue(gamma);
gammaLevel = gamma;
oldGammaLevel = gamma;
if(gamma == 0.0)
{
ui->gammaEnableChk->setChecked(false);
} else {
ui->gammaEnableChk->setChecked(true);
}
on_gammaEnableChk_clicked();
emitUpdateSignal = true;
}
void rgbAdjustments::on_gammaSpin_valueChanged(double newValue)
{
ui->gammaSlider->blockSignals(true);
ui->gammaSlider->setValue(newValue * 1000);
ui->gammaSlider->blockSignals(false);
gammaLevel = newValue;
if(emitUpdateSignal)
emit haveRGBLevels(redLevel, greenLevel, blueLevel, gammaLevel, false);
}
void rgbAdjustments::on_gammaEnableChk_clicked()
{
bool checked = ui->gammaEnableChk->isChecked();
if(checked)
{
ui->gammaSpin->setEnabled(true);
ui->gammaSlider->setEnabled(true);
ui->gammaSpin->setValue(oldGammaLevel);
} else {
oldGammaLevel = gammaLevel;
gammaLevel = 1.0;
ui->gammaSpin->setValue(gammaLevel);
ui->gammaSpin->setEnabled(false);
ui->gammaSlider->setEnabled(false);
}
}
void rgbAdjustments::on_closeBtn_clicked()
{
this->close();
}
void rgbAdjustments::on_reprocessBtn_clicked()
{
emit haveRGBLevels(redLevel, greenLevel, blueLevel, gammaLevel, true);
}