Changeset View
Changeset View
Standalone View
Standalone View
libs/widgets/kis_color_input.cpp
Show First 20 Lines • Show All 146 Lines • ▼ Show 20 Line(s) | 97 | { | |||
---|---|---|---|---|---|
147 | m_colorSlider->blockSignals(false); | 147 | m_colorSlider->blockSignals(false); | ||
148 | } | 148 | } | ||
149 | 149 | | |||
150 | QWidget* KisIntegerColorInput::createInput() | 150 | QWidget* KisIntegerColorInput::createInput() | ||
151 | { | 151 | { | ||
152 | m_intNumInput = new KisIntParseSpinBox(this); | 152 | m_intNumInput = new KisIntParseSpinBox(this); | ||
153 | m_intNumInput->setMinimum(0); | 153 | m_intNumInput->setMinimum(0); | ||
154 | m_colorSlider->setMinimum(0); | 154 | m_colorSlider->setMinimum(0); | ||
155 | | ||||
156 | if (m_usePercentage) { | ||||
157 | m_intNumInput->setSuffix("%"); | ||||
158 | } else { | ||||
159 | m_intNumInput->setSuffix(""); | ||||
160 | } | ||||
161 | | ||||
155 | switch (m_channelInfo->channelValueType()) { | 162 | switch (m_channelInfo->channelValueType()) { | ||
156 | case KoChannelInfo::UINT8: | 163 | case KoChannelInfo::UINT8: | ||
157 | if (m_usePercentage) { | 164 | if (m_usePercentage) { | ||
158 | m_intNumInput->setMaximum(100); | 165 | m_intNumInput->setMaximum(100); | ||
159 | } else { | 166 | } else { | ||
160 | m_intNumInput->setMaximum(0xFF); | 167 | m_intNumInput->setMaximum(0xFF); | ||
161 | } | 168 | } | ||
162 | m_colorSlider->setMaximum(0xFF); | 169 | m_colorSlider->setMaximum(0xFF); | ||
Show All 17 Lines | |||||
180 | default: | 187 | default: | ||
181 | Q_ASSERT(false); | 188 | Q_ASSERT(false); | ||
182 | } | 189 | } | ||
183 | connect(m_colorSlider, SIGNAL(valueChanged(int)), this, SLOT(onColorSliderChanged(int))); | 190 | connect(m_colorSlider, SIGNAL(valueChanged(int)), this, SLOT(onColorSliderChanged(int))); | ||
184 | connect(m_intNumInput, SIGNAL(valueChanged(int)), this, SLOT(onNumInputChanged(int))); | 191 | connect(m_intNumInput, SIGNAL(valueChanged(int)), this, SLOT(onNumInputChanged(int))); | ||
185 | return m_intNumInput; | 192 | return m_intNumInput; | ||
186 | } | 193 | } | ||
187 | 194 | | |||
195 | void KisIntegerColorInput::setPercentageWise(bool val) | ||||
196 | { | ||||
197 | m_usePercentage = val; | ||||
198 | | ||||
199 | if (m_usePercentage) { | ||||
200 | m_intNumInput->setSuffix("%"); | ||||
201 | } else { | ||||
202 | m_intNumInput->setSuffix(""); | ||||
203 | } | ||||
204 | } | ||||
205 | | ||||
188 | void KisIntegerColorInput::onColorSliderChanged(int val) | 206 | void KisIntegerColorInput::onColorSliderChanged(int val) | ||
189 | { | 207 | { | ||
190 | m_intNumInput->blockSignals(true); | 208 | m_intNumInput->blockSignals(true); | ||
191 | if (m_usePercentage) { | 209 | if (m_usePercentage) { | ||
192 | switch (m_channelInfo->channelValueType()) { | 210 | switch (m_channelInfo->channelValueType()) { | ||
193 | case KoChannelInfo::UINT8: | 211 | case KoChannelInfo::UINT8: | ||
194 | m_intNumInput->setValue(round((val*1.0) / 255.0 * 100.0)); | 212 | m_intNumInput->setValue(round((val*1.0) / 255.0 * 100.0)); | ||
195 | break; | 213 | break; | ||
▲ Show 20 Lines • Show All 186 Lines • ▼ Show 20 Line(s) | 395 | Q_FOREACH (KoChannelInfo* channel, channels) { | |||
382 | } | 400 | } | ||
383 | } | 401 | } | ||
384 | m_hexInput->setText(hexString); | 402 | m_hexInput->setText(hexString); | ||
385 | } | 403 | } | ||
386 | 404 | | |||
387 | QWidget* KisHexColorInput::createInput() | 405 | QWidget* KisHexColorInput::createInput() | ||
388 | { | 406 | { | ||
389 | m_hexInput = new QLineEdit(this); | 407 | m_hexInput = new QLineEdit(this); | ||
408 | m_hexInput->setAlignment(Qt::AlignRight); | ||||
390 | 409 | | |||
391 | int digits = 2*m_color->colorSpace()->colorChannelCount(); | 410 | int digits = 2*m_color->colorSpace()->colorChannelCount(); | ||
392 | QString pattern = QString("#?[a-fA-F0-9]{%1,%2}").arg(digits).arg(digits); | 411 | QString pattern = QString("#?[a-fA-F0-9]{%1,%2}").arg(digits).arg(digits); | ||
393 | m_hexInput->setValidator(new QRegExpValidator(QRegExp(pattern), this)); | 412 | m_hexInput->setValidator(new QRegExpValidator(QRegExp(pattern), this)); | ||
394 | connect(m_hexInput, SIGNAL(editingFinished()), this, SLOT(setValue())); | 413 | connect(m_hexInput, SIGNAL(editingFinished()), this, SLOT(setValue())); | ||
395 | return m_hexInput; | 414 | return m_hexInput; | ||
396 | } | 415 | } | ||
397 | 416 | |