70 m_ui->hueColorLine->setColorComponent(QtColorLine::Hue);
71 m_ui->saturationColorLine->setColorComponent(QtColorLine::Saturation);
72 m_ui->valueColorLine->setColorComponent(QtColorLine::Value);
73 m_ui->alphaColorLine->setColorComponent(QtColorLine::Alpha);
75 m_model =
new QtGradientStopsModel(
this);
76 m_ui->gradientStopsWidget->setGradientStopsModel(
m_model);
79 connect(
m_model, &QtGradientStopsModel::stopMoved,
80 this, &QtGradientStopsControllerPrivate::slotStopMoved);
87 connect(m_model, &QtGradientStopsModel::stopAdded,
88 this, &QtGradientStopsControllerPrivate::slotStopAdded);
92 connect(m_ui->hueColorLine, &QtColorLine::colorChanged,
93 this, &QtGradientStopsControllerPrivate::slotChangeHueColor);
94 connect(m_ui->saturationColorLine, &QtColorLine::colorChanged,
95 this, &QtGradientStopsControllerPrivate::slotChangeSaturationColor);
96 connect(m_ui->valueColorLine, &QtColorLine::colorChanged,
97 this, &QtGradientStopsControllerPrivate::slotChangeValueColor);
98 connect(m_ui->alphaColorLine, &QtColorLine::colorChanged,
99 this, &QtGradientStopsControllerPrivate::slotChangeAlphaColor);
100 connect(m_ui->colorButton, &QtColorButton::colorChanged,
101 this, &QtGradientStopsControllerPrivate::slotChangeColor);
103 connect(m_ui->hueSpinBox, &QSpinBox::valueChanged,
104 this, &QtGradientStopsControllerPrivate::slotChangeHue);
105 connect(m_ui->saturationSpinBox, &QSpinBox::valueChanged,
106 this, &QtGradientStopsControllerPrivate::slotChangeSaturation);
107 connect(m_ui->valueSpinBox, &QSpinBox::valueChanged,
108 this, &QtGradientStopsControllerPrivate::slotChangeValue);
109 connect(m_ui->alphaSpinBox, &QSpinBox::valueChanged,
110 this, &QtGradientStopsControllerPrivate::slotChangeAlpha);
112 connect(m_ui->positionSpinBox, &QDoubleSpinBox::valueChanged,
113 this, &QtGradientStopsControllerPrivate::slotChangePosition);
115 connect(m_ui->zoomSpinBox, &QSpinBox::valueChanged,
116 this, &QtGradientStopsControllerPrivate::slotChangeZoom);
117 connect(m_ui->zoomInButton, &QToolButton::clicked,
118 this, &QtGradientStopsControllerPrivate::slotZoomIn);
119 connect(m_ui->zoomOutButton, &QToolButton::clicked,
120 this, &QtGradientStopsControllerPrivate::slotZoomOut);
121 connect(m_ui->zoomAllButton, &QToolButton::clicked,
122 this, &QtGradientStopsControllerPrivate::slotZoomAll);
123 connect(m_ui->gradientStopsWidget, &QtGradientStopsWidget::zoomChanged,
124 this, &QtGradientStopsControllerPrivate::slotZoomChanged);
126 connect(m_ui->hsvRadioButton, &QRadioButton::clicked,
127 this, &QtGradientStopsControllerPrivate::slotHsvClicked);
128 connect(m_ui->rgbRadioButton, &QRadioButton::clicked,
129 this, &QtGradientStopsControllerPrivate::slotRgbClicked);
132 m_ui->zoomInButton->setIcon(QIcon(
":/qt-project.org/qtgradienteditor/images/zoomin.png"_L1));
133 m_ui->zoomOutButton->setIcon(QIcon(
":/qt-project.org/qtgradienteditor/images/zoomout.png"_L1));
139 m_ui->positionLabel->setEnabled(enable);
140 m_ui->colorLabel->setEnabled(enable);
141 m_ui->hLabel->setEnabled(enable);
142 m_ui->sLabel->setEnabled(enable);
143 m_ui->vLabel->setEnabled(enable);
144 m_ui->aLabel->setEnabled(enable);
145 m_ui->hueLabel->setEnabled(enable);
146 m_ui->saturationLabel->setEnabled(enable);
147 m_ui->valueLabel->setEnabled(enable);
148 m_ui->alphaLabel->setEnabled(enable);
150 m_ui->positionSpinBox->setEnabled(enable);
151 m_ui->colorButton->setEnabled(enable);
153 m_ui->hueColorLine->setEnabled(enable);
154 m_ui->saturationColorLine->setEnabled(enable);
155 m_ui->valueColorLine->setEnabled(enable);
156 m_ui->alphaColorLine->setEnabled(enable);
158 m_ui->hueSpinBox->setEnabled(enable);
159 m_ui->saturationSpinBox->setEnabled(enable);
160 m_ui->valueSpinBox->setEnabled(enable);
161 m_ui->alphaSpinBox->setEnabled(enable);
202 QString h = QCoreApplication::translate(
"qdesigner_internal::QtGradientStopsController",
"H");
203 QString s = QCoreApplication::translate(
"qdesigner_internal::QtGradientStopsController",
"S");
204 QString v = QCoreApplication::translate(
"qdesigner_internal::QtGradientStopsController",
"V");
206 m_ui->hLabel->setText(h);
207 m_ui->sLabel->setText(s);
208 m_ui->vLabel->setText(v);
210 h = QCoreApplication::translate(
"qdesigner_internal::QtGradientStopsController",
"Hue");
211 s = QCoreApplication::translate(
"qdesigner_internal::QtGradientStopsController",
"Sat");
212 v = QCoreApplication::translate(
"qdesigner_internal::QtGradientStopsController",
"Val");
214 const QString hue = QCoreApplication::translate(
"qdesigner_internal::QtGradientStopsController",
"Hue");
215 const QString saturation = QCoreApplication::translate(
"qdesigner_internal::QtGradientStopsController",
"Saturation");
216 const QString value = QCoreApplication::translate(
"qdesigner_internal::QtGradientStopsController",
"Value");
218 m_ui->hLabel->setToolTip(hue);
219 m_ui->hueLabel->setText(h);
220 m_ui->hueColorLine->setToolTip(hue);
221 m_ui->hueColorLine->setColorComponent(QtColorLine::Hue);
223 m_ui->sLabel->setToolTip(saturation);
224 m_ui->saturationLabel->setText(s);
225 m_ui->saturationColorLine->setToolTip(saturation);
226 m_ui->saturationColorLine->setColorComponent(QtColorLine::Saturation);
228 m_ui->vLabel->setToolTip(value);
229 m_ui->valueLabel->setText(v);
230 m_ui->valueColorLine->setToolTip(value);
231 m_ui->valueColorLine->setColorComponent(QtColorLine::Value);
238 QString r = QCoreApplication::translate(
"qdesigner_internal::QtGradientStopsController",
"R");
239 QString g = QCoreApplication::translate(
"qdesigner_internal::QtGradientStopsController",
"G");
240 QString b = QCoreApplication::translate(
"qdesigner_internal::QtGradientStopsController",
"B");
242 m_ui->hLabel->setText(r);
243 m_ui->sLabel->setText(g);
244 m_ui->vLabel->setText(b);
246 QString red = QCoreApplication::translate(
"qdesigner_internal::QtGradientStopsController",
"Red");
247 QString green = QCoreApplication::translate(
"qdesigner_internal::QtGradientStopsController",
"Green");
248 QString blue = QCoreApplication::translate(
"qdesigner_internal::QtGradientStopsController",
"Blue");
250 m_ui->hLabel->setToolTip(red);
251 m_ui->hueLabel->setText(red);
252 m_ui->hueColorLine->setToolTip(red);
253 m_ui->hueColorLine->setColorComponent(QtColorLine::Red);
255 m_ui->sLabel->setToolTip(green);
256 m_ui->saturationLabel->setText(green);
257 m_ui->saturationColorLine->setToolTip(green);
258 m_ui->saturationColorLine->setColorComponent(QtColorLine::Green);
260 m_ui->vLabel->setToolTip(blue);
261 m_ui->valueLabel->setText(blue);
262 m_ui->valueColorLine->setToolTip(blue);
263 m_ui->valueColorLine->setColorComponent(QtColorLine::Blue);
270 m_ui->hueSpinBox->blockSignals(
true);
271 m_ui->saturationSpinBox->blockSignals(
true);
272 m_ui->valueSpinBox->blockSignals(
true);
273 m_ui->alphaSpinBox->blockSignals(
true);
274 if (
m_ui->hsvRadioButton->isChecked()) {
275 if (
m_ui->hueSpinBox->maximum() != 359)
276 m_ui->hueSpinBox->setMaximum(359);
277 if (
m_ui->hueSpinBox->value() != color.hue())
278 m_ui->hueSpinBox->setValue(color.hue());
279 if (
m_ui->saturationSpinBox->value() != color.saturation())
280 m_ui->saturationSpinBox->setValue(color.saturation());
281 if (
m_ui->valueSpinBox->value() != color.value())
282 m_ui->valueSpinBox->setValue(color.value());
284 if (
m_ui->hueSpinBox->maximum() != 255)
285 m_ui->hueSpinBox->setMaximum(255);
286 if (
m_ui->hueSpinBox->value() != color.red())
287 m_ui->hueSpinBox->setValue(color.red());
288 if (
m_ui->saturationSpinBox->value() != color.green())
289 m_ui->saturationSpinBox->setValue(color.green());
290 if (
m_ui->valueSpinBox->value() != color.blue())
291 m_ui->valueSpinBox->setValue(color.blue());
293 m_ui->alphaSpinBox->setValue(color.alpha());
294 m_ui->hueSpinBox->blockSignals(
false);
295 m_ui->saturationSpinBox->blockSignals(
false);
296 m_ui->valueSpinBox->blockSignals(
false);
297 m_ui->alphaSpinBox->blockSignals(
false);
396 const qreal pos = current->position();
402 const qreal minPos = pos - first->position() - 0.0004999;
403 const qreal maxPos = pos + 1.0 - last->position() + 0.0004999;
410 if (first->position() == 0.0)
412 if (last->position() == 1.0)
416 const int spinMin = qRound(
m_ui->positionSpinBox->minimum() * 1000);
417 const int spinMax = qRound(
m_ui->positionSpinBox->maximum() * 1000);
419 const int newMin = qRound(min * 1000);
420 const int newMax = qRound(max * 1000);
422 m_ui->positionSpinBox->blockSignals(
true);
423 if (spinMin != newMin || spinMax != newMax) {
424 m_ui->positionSpinBox->setRange(
double(newMin) / 1000,
double(newMax) / 1000);
426 if (
m_ui->positionSpinBox->value() != pos)
427 m_ui->positionSpinBox->setValue(pos);
428 m_ui->positionSpinBox->blockSignals(
false);