diff --git a/krita/pics/svg/dark_ratio.svg b/krita/pics/svg/dark_ratio.svg
new file mode 100644
index 0000000000..3e92e7c490
--- /dev/null
+++ b/krita/pics/svg/dark_ratio.svg
@@ -0,0 +1,1522 @@
+
+
+
+
diff --git a/krita/pics/svg/light_ratio.svg b/krita/pics/svg/light_ratio.svg
new file mode 100644
index 0000000000..1dff1f1506
--- /dev/null
+++ b/krita/pics/svg/light_ratio.svg
@@ -0,0 +1,1522 @@
+
+
+
+
diff --git a/krita/pics/svg/svg-icons.qrc b/krita/pics/svg/svg-icons.qrc
index 0418ee66a3..5d6418703d 100644
--- a/krita/pics/svg/svg-icons.qrc
+++ b/krita/pics/svg/svg-icons.qrc
@@ -1,155 +1,157 @@
broken-preset.svgz
dark_addblankframe.svg
dark_addcolor.svg
dark_addduplicateframe.svg
dark_deletekeyframe.svg
dark_docker_lock_a.svg
dark_docker_lock_b.svg
dark_layer-locked.svg
dark_layer-unlocked.svg
dark_nextframe.svg
dark_nextkeyframe.svg
dark_lastframe.svg
dark_prevkeyframe.svg
dark_firstframe.svg
dark_pallete_librarysvg.svg
dark_passthrough-disabled.svg
dark_passthrough-enabled.svg
dark_prevframe.svg
dark_selection-mode_ants.svg
dark_selection-mode_invisible.svg
dark_selection-mode_mask.svg
dark_transparency-disabled.svg
dark_transparency-enabled.svg
dark_trim-to-image.svg
dark_warning.svg
delete.svgz
layer-style-disabled.svg
layer-style-enabled.svg
light_addblankframe.svg
light_addcolor.svg
light_addduplicateframe.svg
light_deletekeyframe.svg
light_docker_lock_a.svg
light_docker_lock_b.svg
light_layer-locked.svg
light_layer-unlocked.svg
light_nextframe.svg
light_pallete_library.svg
light_passthrough-disabled.svgz
light_passthrough-enabled.svgz
light_prevframe.svg
light_nextkeyframe.svg
light_lastframe.svg
light_prevkeyframe.svg
light_firstframe.svg
light_selection-mode_ants.svg
light_selection-mode_invisible.svg
light_selection-mode_mask.svg
light_timeline_keyframe.svg
light_transparency-disabled.svg
light_transparency-enabled.svg
light_trim-to-image.svg
light_warning.svg
paintop_presets_disabled.svgz
paintop_settings_01.svgz
selection-info.svg
selection-mode_invisible.svg
svg-icons.qrc
transparency-locked.svg
transparency-unlocked.svg
workspace-chooser.svg
light_lazyframeOn.svg
light_lazyframeOff.svg
dark_lazyframeOn.svg
dark_lazyframeOff.svg
dark_mirror-view.svg
light_mirror-view.svg
dark_rotation-reset.svg
light_rotation-reset.svg
light_smoothing-basic.svg
light_smoothing-no.svg
light_smoothing-stabilizer.svg
light_smoothing-weighted.svg
dark_smoothing-basic.svg
dark_smoothing-no.svg
dark_smoothing-stabilizer.svg
dark_smoothing-weighted.svg
light_merge-layer-below.svg
dark_merge-layer-below.svg
light_rotate-canvas-left.svg
light_rotate-canvas-right.svg
dark_rotate-canvas-left.svg
dark_rotate-canvas-right.svg
light_gmic.svg
dark_gmic.svg
light_split-layer.svg
dark_split-layer.svg
light_color-to-alpha.svg
dark_color-to-alpha.svg
light_preset-switcher.svg
dark_preset-switcher.svg
dark_animation_play.svg
dark_animation_stop.svg
dark_dropframe.svg
dark_droppedframes.svg
light_animation_play.svg
light_animation_stop.svg
light_dropframe.svg
light_droppedframes.svg
dark_landscape.svg
dark_portrait.svg
light_landscape.svg
light_portrait.svg
dark_interpolation_constant.svg
dark_interpolation_linear.svg
dark_interpolation_bezier.svg
dark_interpolation_sharp.svg
dark_interpolation_smooth.svg
light_interpolation_bezier.svg
light_interpolation_constant.svg
light_interpolation_linear.svg
light_interpolation_sharp.svg
light_interpolation_smooth.svg
dark_audio-none.svg
dark_audio-volume-high.svg
dark_audio-volume-mute.svg
dark_keyframe-add.svg
dark_keyframe-remove.svg
dark_zoom-fit.svg
dark_zoom-horizontal.svg
dark_zoom-vertical.svg
light_audio-none.svg
light_audio-volume-high.svg
light_audio-volume-mute.svg
light_keyframe-add.svg
light_keyframe-remove.svg
light_zoom-fit.svg
light_zoom-horizontal.svg
light_zoom-vertical.svg
dark_showColoring.svg
dark_showMarks.svg
dark_showColoringOff.svg
dark_showMarksOff.svg
dark_updateColorize.svg
light_showColoring.svg
light_showMarks.svg
light_showColoringOff.svg
light_showMarksOff.svg
light_updateColorize.svg
light_wheel-light.svg
light_wheel-rings.svg
light_wheel-sectors.svg
dark_wheel-light.svg
dark_wheel-rings.svg
dark_wheel-sectors.svg
dark_infinity.svg
light_infinity.svg
dark_gamut-mask-on.svg
dark_gamut-mask-off.svg
light_gamut-mask-off.svg
light_gamut-mask-on.svg
+ dark_ratio.svg
+ light_ratio.svg
diff --git a/libs/widgets/kis_color_input.cpp b/libs/widgets/kis_color_input.cpp
index 330cf4965a..0ff533e202 100644
--- a/libs/widgets/kis_color_input.cpp
+++ b/libs/widgets/kis_color_input.cpp
@@ -1,397 +1,416 @@
/*
* Copyright (c) 2008 Cyrille Berger
* Copyright (c) 2011 Sven Langkamp
* Copyright (c) 2015 Moritz Molch
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_color_input.h"
#include
#ifdef HAVE_OPENEXR
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "kis_double_parse_spin_box.h"
#include "kis_int_parse_spin_box.h"
KisColorInput::KisColorInput(QWidget* parent, const KoChannelInfo* channelInfo, KoColor* color, KoColorDisplayRendererInterface *displayRenderer, bool usePercentage) :
QWidget(parent), m_channelInfo(channelInfo), m_color(color), m_displayRenderer(displayRenderer),
m_usePercentage(usePercentage)
{
}
void KisColorInput::init()
{
QHBoxLayout* m_layout = new QHBoxLayout(this);
m_layout->setContentsMargins(0,0,0,0);
m_layout->setSpacing(1);
QLabel* m_label = new QLabel(i18n("%1:", m_channelInfo->name()), this);
m_layout->addWidget(m_label);
m_colorSlider = new KoColorSlider(Qt::Horizontal, this, m_displayRenderer);
m_colorSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
m_layout->addWidget(m_colorSlider);
QWidget* m_input = createInput();
m_colorSlider->setFixedHeight(m_input->sizeHint().height());
m_layout->addWidget(m_input);
}
KisIntegerColorInput::KisIntegerColorInput(QWidget* parent, const KoChannelInfo* channelInfo, KoColor* color, KoColorDisplayRendererInterface *displayRenderer, bool usePercentage) :
KisColorInput(parent, channelInfo, color, displayRenderer, usePercentage)
{
init();
}
void KisIntegerColorInput::setValue(int v)
{
quint8* data = m_color->data() + m_channelInfo->pos();
switch (m_channelInfo->channelValueType()) {
case KoChannelInfo::UINT8:
*(reinterpret_cast(data)) = v;
break;
case KoChannelInfo::UINT16:
*(reinterpret_cast(data)) = v;
break;
case KoChannelInfo::UINT32:
*(reinterpret_cast(data)) = v;
break;
default:
Q_ASSERT(false);
}
emit(updated());
}
void KisIntegerColorInput::update()
{
KoColor min = *m_color;
KoColor max = *m_color;
quint8* data = m_color->data() + m_channelInfo->pos();
quint8* dataMin = min.data() + m_channelInfo->pos();
quint8* dataMax = max.data() + m_channelInfo->pos();
m_intNumInput->blockSignals(true);
m_colorSlider->blockSignals(true);
switch (m_channelInfo->channelValueType()) {
case KoChannelInfo::UINT8:
if (m_usePercentage) {
m_intNumInput->setMaximum(100);
m_intNumInput->setValue(round(*(reinterpret_cast(data))*1.0 / 255.0 * 100.0));
} else {
m_intNumInput->setMaximum(0xFF);
m_intNumInput->setValue(*(reinterpret_cast(data)));
}
m_colorSlider->setValue(*(reinterpret_cast(data)));
*(reinterpret_cast(dataMin)) = 0x0;
*(reinterpret_cast(dataMax)) = 0xFF;
break;
case KoChannelInfo::UINT16:
if (m_usePercentage) {
m_intNumInput->setMaximum(100);
m_intNumInput->setValue(round(*(reinterpret_cast(data))*1.0 / 65535.0 * 100.0));
} else {
m_intNumInput->setMaximum(0xFFFF);
m_intNumInput->setValue(*(reinterpret_cast(data)));
}
m_colorSlider->setValue(*(reinterpret_cast(data)));
*(reinterpret_cast(dataMin)) = 0x0;
*(reinterpret_cast(dataMax)) = 0xFFFF;
break;
case KoChannelInfo::UINT32:
if (m_usePercentage) {
m_intNumInput->setMaximum(100);
m_intNumInput->setValue(round(*(reinterpret_cast(data))*1.0 / 4294967295.0 * 100.0));
} else {
m_intNumInput->setMaximum(0xFFFF);
m_intNumInput->setValue(*(reinterpret_cast(data)));
}
m_colorSlider->setValue(*(reinterpret_cast(data)));
*(reinterpret_cast(dataMin)) = 0x0;
*(reinterpret_cast(dataMax)) = 0xFFFFFFFF;
break;
default:
Q_ASSERT(false);
}
m_colorSlider->setColors(min, max);
m_intNumInput->blockSignals(false);
m_colorSlider->blockSignals(false);
}
QWidget* KisIntegerColorInput::createInput()
{
m_intNumInput = new KisIntParseSpinBox(this);
m_intNumInput->setMinimum(0);
m_colorSlider->setMinimum(0);
+
+ if (m_usePercentage) {
+ m_intNumInput->setSuffix("%");
+ } else {
+ m_intNumInput->setSuffix("");
+ }
+
switch (m_channelInfo->channelValueType()) {
case KoChannelInfo::UINT8:
if (m_usePercentage) {
m_intNumInput->setMaximum(100);
} else {
m_intNumInput->setMaximum(0xFF);
}
m_colorSlider->setMaximum(0xFF);
break;
case KoChannelInfo::UINT16:
if (m_usePercentage) {
m_intNumInput->setMaximum(100);
} else {
m_intNumInput->setMaximum(0xFFFF);
}
m_colorSlider->setMaximum(0xFFFF);
break;
case KoChannelInfo::UINT32:
if (m_usePercentage) {
m_intNumInput->setMaximum(100);
} else {
m_intNumInput->setMaximum(0xFFFFFFFF);
}
m_colorSlider->setMaximum(0xFFFFFFFF);
break;
default:
Q_ASSERT(false);
}
connect(m_colorSlider, SIGNAL(valueChanged(int)), this, SLOT(onColorSliderChanged(int)));
connect(m_intNumInput, SIGNAL(valueChanged(int)), this, SLOT(onNumInputChanged(int)));
return m_intNumInput;
}
+void KisIntegerColorInput::setPercentageWise(bool val)
+{
+ m_usePercentage = val;
+
+ if (m_usePercentage) {
+ m_intNumInput->setSuffix("%");
+ } else {
+ m_intNumInput->setSuffix("");
+ }
+}
+
void KisIntegerColorInput::onColorSliderChanged(int val)
{
m_intNumInput->blockSignals(true);
if (m_usePercentage) {
switch (m_channelInfo->channelValueType()) {
case KoChannelInfo::UINT8:
m_intNumInput->setValue(round((val*1.0) / 255.0 * 100.0));
break;
case KoChannelInfo::UINT16:
m_intNumInput->setValue(round((val*1.0) / 65535.0 * 100.0));
break;
case KoChannelInfo::UINT32:
m_intNumInput->setValue(round((val*1.0) / 4294967295.0 * 100.0));
break;
default:
Q_ASSERT(false);
}
} else {
m_intNumInput->setValue(val);
}
m_intNumInput->blockSignals(false);
setValue(val);
}
void KisIntegerColorInput::onNumInputChanged(int val)
{
m_colorSlider->blockSignals(true);
if (m_usePercentage) {
switch (m_channelInfo->channelValueType()) {
case KoChannelInfo::UINT8:
m_colorSlider->setValue((val*1.0)/100.0 * 255.0);
m_colorSlider->blockSignals(false);
setValue((val*1.0)/100.0 * 255.0);
break;
case KoChannelInfo::UINT16:
m_colorSlider->setValue((val*1.0)/100.0 * 65535.0);
m_colorSlider->blockSignals(false);
setValue((val*1.0)/100.0 * 65535.0);
break;
case KoChannelInfo::UINT32:
m_colorSlider->setValue((val*1.0)/100.0 * 4294967295.0);
m_colorSlider->blockSignals(false);
setValue((val*1.0)/100.0 * 4294967295.0);
break;
default:
Q_ASSERT(false);
}
} else {
m_colorSlider->setValue(val);
m_colorSlider->blockSignals(false);
setValue(val);
}
}
KisFloatColorInput::KisFloatColorInput(QWidget* parent, const KoChannelInfo* channelInfo, KoColor* color, KoColorDisplayRendererInterface *displayRenderer, bool usePercentage) :
KisColorInput(parent, channelInfo, color, displayRenderer, usePercentage)
{
init();
}
void KisFloatColorInput::setValue(double v)
{
quint8* data = m_color->data() + m_channelInfo->pos();
switch (m_channelInfo->channelValueType()) {
#ifdef HAVE_OPENEXR
case KoChannelInfo::FLOAT16:
*(reinterpret_cast(data)) = v;
break;
#endif
case KoChannelInfo::FLOAT32:
*(reinterpret_cast(data)) = v;
break;
default:
Q_ASSERT(false);
}
emit(updated());
}
QWidget* KisFloatColorInput::createInput()
{
m_dblNumInput = new KisDoubleParseSpinBox(this);
m_dblNumInput->setMinimum(0);
m_dblNumInput->setMaximum(1.0);
connect(m_colorSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderChanged(int)));
connect(m_dblNumInput, SIGNAL(valueChanged(double)), this, SLOT(setValue(double)));
m_dblNumInput->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
m_dblNumInput->setMinimumWidth(60);
m_dblNumInput->setMaximumWidth(60);
return m_dblNumInput;
}
void KisFloatColorInput::sliderChanged(int i)
{
const qreal floatRange = m_maxValue - m_minValue;
m_dblNumInput->setValue(m_minValue + (i / 255.0) * floatRange);
}
void KisFloatColorInput::update()
{
KoColor min = *m_color;
KoColor max = *m_color;
quint8* data = m_color->data() + m_channelInfo->pos();
quint8* dataMin = min.data() + m_channelInfo->pos();
quint8* dataMax = max.data() + m_channelInfo->pos();
qreal value = 1.0;
m_minValue = m_displayRenderer->minVisibleFloatValue(m_channelInfo);
m_maxValue = m_displayRenderer->maxVisibleFloatValue(m_channelInfo);
switch (m_channelInfo->channelValueType()) {
#ifdef HAVE_OPENEXR
case KoChannelInfo::FLOAT16:
value = *(reinterpret_cast(data));
m_minValue = qMin(value, m_minValue);
m_maxValue = qMax(value, m_maxValue);
*(reinterpret_cast(dataMin)) = m_minValue;
*(reinterpret_cast(dataMax)) = m_maxValue;
break;
#endif
case KoChannelInfo::FLOAT32:
value = *(reinterpret_cast(data));
m_minValue = qMin(value, m_minValue);
m_maxValue = qMax(value, m_maxValue);
*(reinterpret_cast(dataMin)) = m_minValue;
*(reinterpret_cast(dataMax)) = m_maxValue;
break;
default:
Q_ASSERT(false);
}
m_dblNumInput->setMinimum(m_minValue);
m_dblNumInput->setMaximum(m_maxValue);
// ensure at least 3 significant digits are always shown
int newPrecision = 2 + qMax(qreal(0.0), std::ceil(-std::log10(m_maxValue)));
if (newPrecision != m_dblNumInput->decimals()) {
m_dblNumInput->setDecimals(newPrecision);
m_dblNumInput->updateGeometry();
}
m_colorSlider->setColors(min, max);
const qreal floatRange = m_maxValue - m_minValue;
m_dblNumInput->setValue(value);
m_colorSlider->setValue((value - m_minValue) / floatRange * 255);
}
KisHexColorInput::KisHexColorInput(QWidget* parent, KoColor* color, KoColorDisplayRendererInterface *displayRenderer, bool usePercentage) :
KisColorInput(parent, 0, color, displayRenderer, usePercentage)
{
QHBoxLayout* m_layout = new QHBoxLayout(this);
m_layout->setContentsMargins(0,0,0,0);
m_layout->setSpacing(1);
QLabel* m_label = new QLabel(i18n("Color name:"), this);
m_label->setMinimumWidth(50);
m_layout->addWidget(m_label);
QWidget* m_input = createInput();
m_input->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
m_layout->addWidget(m_input);
}
void KisHexColorInput::setValue()
{
QString valueString = m_hexInput->text();
valueString.remove(QChar('#'));
QList channels = m_color->colorSpace()->channels();
channels = KoChannelInfo::displayOrderSorted(channels);
Q_FOREACH (KoChannelInfo* channel, channels) {
if (channel->channelType() == KoChannelInfo::COLOR) {
Q_ASSERT(channel->channelValueType() == KoChannelInfo::UINT8);
quint8* data = m_color->data() + channel->pos();
int value = valueString.left(2).toInt(0, 16);
*(reinterpret_cast(data)) = value;
valueString.remove(0, 2);
}
}
emit(updated());
}
void KisHexColorInput::update()
{
QString hexString("#");
QList channels = m_color->colorSpace()->channels();
channels = KoChannelInfo::displayOrderSorted(channels);
Q_FOREACH (KoChannelInfo* channel, channels) {
if (channel->channelType() == KoChannelInfo::COLOR) {
Q_ASSERT(channel->channelValueType() == KoChannelInfo::UINT8);
quint8* data = m_color->data() + channel->pos();
hexString.append(QString("%1").arg(*(reinterpret_cast(data)), 2, 16, QChar('0')));
}
}
m_hexInput->setText(hexString);
}
QWidget* KisHexColorInput::createInput()
{
m_hexInput = new QLineEdit(this);
+ m_hexInput->setAlignment(Qt::AlignRight);
int digits = 2*m_color->colorSpace()->colorChannelCount();
QString pattern = QString("#?[a-fA-F0-9]{%1,%2}").arg(digits).arg(digits);
m_hexInput->setValidator(new QRegExpValidator(QRegExp(pattern), this));
connect(m_hexInput, SIGNAL(editingFinished()), this, SLOT(setValue()));
return m_hexInput;
}
diff --git a/libs/widgets/kis_color_input.h b/libs/widgets/kis_color_input.h
index a6a92196f8..51d910be68 100644
--- a/libs/widgets/kis_color_input.h
+++ b/libs/widgets/kis_color_input.h
@@ -1,109 +1,111 @@
/*
* Copyright (c) 2008 Cyrille Berger
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _KIS_COLOR_INPUT_H_
#define _KIS_COLOR_INPUT_H_
#include
class KoChannelInfo;
class KoColor;
class QWidget;
class QSpinBox;
class QDoubleSpinBox;
class KisIntParseSpinBox;
class KisDoubleParseSpinBox;
class KoColorSlider;
class QLineEdit;
#include
#include "kritawidgets_export.h"
class KRITAWIDGETS_EXPORT KisColorInput : public QWidget
{
Q_OBJECT
public:
KisColorInput(QWidget* parent, const KoChannelInfo*, KoColor* color, KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance(), bool usePercentage = false);
inline bool usePercentage() const {
return m_usePercentage;
}
- inline void setPercentageWise(bool val) {
+ virtual inline void setPercentageWise(bool val) {
m_usePercentage = val;
}
+
protected:
void init();
virtual QWidget* createInput() = 0;
Q_SIGNALS:
void updated();
protected:
const KoChannelInfo* m_channelInfo;
KoColor* m_color;
KoColorSlider* m_colorSlider;
KoColorDisplayRendererInterface *m_displayRenderer;
bool m_usePercentage;
};
class KRITAWIDGETS_EXPORT KisIntegerColorInput : public KisColorInput
{
Q_OBJECT
public:
KisIntegerColorInput(QWidget* parent, const KoChannelInfo*, KoColor* color, KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance(), bool usePercentage = false);
protected:
QWidget* createInput() override;
+ void setPercentageWise(bool val) override;
public Q_SLOTS:
void setValue(int);
void update();
private Q_SLOTS:
void onColorSliderChanged(int);
void onNumInputChanged(int);
private:
KisIntParseSpinBox* m_intNumInput;
};
class KRITAWIDGETS_EXPORT KisFloatColorInput : public KisColorInput
{
Q_OBJECT
public:
KisFloatColorInput(QWidget* parent, const KoChannelInfo*, KoColor* color, KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance(), bool usePercentage = false);
protected:
QWidget* createInput() override;
public Q_SLOTS:
void setValue(double);
void sliderChanged(int);
void update();
private:
KisDoubleParseSpinBox* m_dblNumInput;
qreal m_minValue;
qreal m_maxValue;
};
class KRITAWIDGETS_EXPORT KisHexColorInput : public KisColorInput
{
Q_OBJECT
public:
KisHexColorInput(QWidget* parent, KoColor* color, KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance(), bool usePercentage = false);
protected:
QWidget* createInput() override;
public Q_SLOTS:
void setValue();
void update();
private:
QLineEdit* m_hexInput;
};
#endif
diff --git a/libs/widgets/kis_double_parse_spin_box.cpp b/libs/widgets/kis_double_parse_spin_box.cpp
index 4131d701bd..9297a90e0b 100644
--- a/libs/widgets/kis_double_parse_spin_box.cpp
+++ b/libs/widgets/kis_double_parse_spin_box.cpp
@@ -1,240 +1,242 @@
/*
* Copyright (c) 2016 Laurent Valentin Jospin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_double_parse_spin_box.h"
#include "kis_num_parser.h"
#include
#include
#include
#include
#include
#include // for qIsNaN
KisDoubleParseSpinBox::KisDoubleParseSpinBox(QWidget *parent) :
QDoubleSpinBox(parent),
boolLastValid(true),
lastExprParsed(QStringLiteral("0.0"))
{
+ setAlignment(Qt::AlignRight);
+
connect(this, SIGNAL(noMoreParsingError()),
this, SLOT(clearErrorStyle()));
//hack to let the clearError be called, even if the value changed method is the one from QDoubleSpinBox.
connect(this, SIGNAL(valueChanged(double)),
this, SLOT(clearError()));
connect(this, SIGNAL(errorWhileParsing(QString)),
this, SLOT(setErrorStyle()));
oldValue = value();
warningIcon = new QLabel(this);
if (QFile(":/./16_light_warning.svg").exists()) {
warningIcon->setPixmap(QIcon(":/./16_light_warning.svg").pixmap(16, 16));
} else {
warningIcon->setText("!");
}
warningIcon->setStyleSheet("background:transparent;");
warningIcon->move(1, 1);
warningIcon->setVisible(false);
isOldPaletteSaved = false;
areOldMarginsSaved = false;
}
KisDoubleParseSpinBox::~KisDoubleParseSpinBox()
{
}
double KisDoubleParseSpinBox::valueFromText(const QString & text) const
{
lastExprParsed = text;
bool ok;
double ret;
if ( (suffix().isEmpty() || !text.endsWith(suffix())) &&
(prefix().isEmpty() || !text.startsWith(prefix())) ) {
ret = KisNumericParser::parseSimpleMathExpr(text, &ok);
} else {
QString expr = text;
if (text.endsWith(suffix())) {
expr.remove(text.size()-suffix().size(), suffix().size());
}
if(text.startsWith(prefix())){
expr.remove(0, prefix().size());
}
lastExprParsed = expr;
ret = KisNumericParser::parseSimpleMathExpr(expr, &ok);
}
if(qIsNaN(ret) || qIsInf(ret)){
ok = false;
}
if (!ok) {
if (boolLastValid) {
oldValue = value();
}
boolLastValid = false;
ret = oldValue; //in case of error set to minimum.
} else {
if (!boolLastValid) {
oldValue = ret;
}
boolLastValid = true;
}
return ret;
}
QString KisDoubleParseSpinBox::textFromValue(double val) const
{
if (!boolLastValid) {
emit errorWhileParsing(lastExprParsed);
return lastExprParsed;
}
emit noMoreParsingError();
double v = KisNumericParser::parseSimpleMathExpr(veryCleanText());
v = QString("%1").arg(v, 0, 'f', decimals()).toDouble();
if (hasFocus() && (v == value() || (v > maximum() && value() == maximum()) || (v < minimum() && value() == minimum())) ) { //solve a very annoying bug where the formula can collapse while editing. With this trick the formula is not lost until focus is lost.
return veryCleanText();
}
return QDoubleSpinBox::textFromValue(val);
}
QString KisDoubleParseSpinBox::veryCleanText() const
{
return cleanText();
}
QValidator::State KisDoubleParseSpinBox::validate ( QString & input, int & pos ) const
{
Q_UNUSED(input);
Q_UNUSED(pos);
return QValidator::Acceptable;
}
void KisDoubleParseSpinBox::stepBy(int steps)
{
boolLastValid = true; //reset to valid state so we can use the up and down buttons.
emit noMoreParsingError();
QDoubleSpinBox::stepBy(steps);
}
void KisDoubleParseSpinBox::setValue(double value)
{
if(value == oldValue && hasFocus()){ //avoid to reset the button when it set the value of something that will recall this slot.
return;
}
QDoubleSpinBox::setValue(value);
if (!hasFocus()) {
clearError();
}
}
void KisDoubleParseSpinBox::setErrorStyle()
{
if (!boolLastValid) {
//setStyleSheet(_oldStyleSheet + "Background: red; color: white; padding-left: 18px;");
if (!isOldPaletteSaved) {
oldPalette = palette();
}
isOldPaletteSaved = true;
QPalette nP = oldPalette;
nP.setColor(QPalette::Background, Qt::red);
nP.setColor(QPalette::Base, Qt::red);
nP.setColor(QPalette::Text, Qt::white);
setPalette(nP);
if (!areOldMarginsSaved) {
oldMargins = lineEdit()->textMargins();
}
areOldMarginsSaved = true;
if (width() - height() >= 3*height()) { //if we have twice as much place as needed by the warning icon then display it.
QMargins newMargins = oldMargins;
newMargins.setLeft( newMargins.left() + height() - 4 );
lineEdit()->setTextMargins(newMargins);
int h = warningIcon->height();
int hp = height()-2;
if (h != hp) {
warningIcon->resize(hp, hp);
if (QFile(":/./16_light_warning.svg").exists()) {
warningIcon->setPixmap(QIcon(":/./16_light_warning.svg").pixmap(hp-7, hp-7));
}
}
warningIcon->move(oldMargins.left()+4, 1);
warningIcon->setVisible(true);
}
}
}
void KisDoubleParseSpinBox::clearErrorStyle()
{
if (boolLastValid) {
warningIcon->setVisible(false);
//setStyleSheet(QString());
setPalette(oldPalette);
isOldPaletteSaved = false;
lineEdit()->setTextMargins(oldMargins);
areOldMarginsSaved = false;
}
}
void KisDoubleParseSpinBox::clearError()
{
boolLastValid = true;
emit noMoreParsingError();
oldValue = value();
clearErrorStyle();
}
diff --git a/libs/widgets/kis_int_parse_spin_box.cpp b/libs/widgets/kis_int_parse_spin_box.cpp
index 06420cef90..21c2707295 100644
--- a/libs/widgets/kis_int_parse_spin_box.cpp
+++ b/libs/widgets/kis_int_parse_spin_box.cpp
@@ -1,252 +1,254 @@
/*
* Copyright (c) 2016 Laurent Valentin Jospin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_int_parse_spin_box.h"
#include "kis_num_parser.h"
#include
#include
#include
#include
#include
KisIntParseSpinBox::KisIntParseSpinBox(QWidget *parent) :
QSpinBox(parent),
boolLastValid(true)
{
+ setAlignment(Qt::AlignRight);
+
lastExprParsed = new QString("0");
connect(this, SIGNAL(noMoreParsingError()),
this, SLOT(clearErrorStyle()));
//hack to let the clearError be called, even if the value changed method is the one from QSpinBox.
connect(this, SIGNAL(valueChanged(int)),
this, SLOT(clearError()));
connect(this, SIGNAL(errorWhileParsing(QString)),
this, SLOT(setErrorStyle()));
oldVal = value();
warningIcon = new QLabel(this);
if (QFile(":/./16_light_warning.svg").exists()) {
warningIcon->setPixmap(QIcon(":/./16_light_warning.svg").pixmap(16, 16));
} else {
warningIcon->setText("!");
}
warningIcon->setStyleSheet("background:transparent;");
warningIcon->move(1, 1);
warningIcon->setVisible(false);
isOldPaletteSaved = false;
areOldMarginsSaved = false;
}
KisIntParseSpinBox::~KisIntParseSpinBox()
{
//needed to avoid a segfault during destruction.
delete lastExprParsed;
}
int KisIntParseSpinBox::valueFromText(const QString & text) const
{
*lastExprParsed = text;
bool ok;
int val;
if ( (suffix().isEmpty() || !text.endsWith(suffix())) &&
(prefix().isEmpty() || !text.startsWith(prefix())) ) {
val = KisNumericParser::parseIntegerMathExpr(text, &ok);
} else {
QString expr = text;
if (text.endsWith(suffix())) {
expr.remove(text.size()-suffix().size(), suffix().size());
}
if(text.startsWith(prefix())){
expr.remove(0, prefix().size());
}
*lastExprParsed = expr;
val = KisNumericParser::parseIntegerMathExpr(expr, &ok);
}
if (text.trimmed().isEmpty()) { //an empty text is considered valid in this case.
ok = true;
}
if (!ok) {
if (boolLastValid == true) {
oldVal = value();
}
boolLastValid = false;
//emit errorWhileParsing(text); //if uncommented become red every time the string is wrong.
val = oldVal;
} else {
if (boolLastValid == false) {
oldVal = val;
}
boolLastValid = true;
//emit noMoreParsingError();
}
return val;
}
QString KisIntParseSpinBox::textFromValue(int val) const
{
if (!boolLastValid) {
emit errorWhileParsing(*lastExprParsed);
return *lastExprParsed;
}
emit noMoreParsingError();
int v = KisNumericParser::parseIntegerMathExpr(cleanText());
if (hasFocus() && (v == value() || (v >= maximum() && value() == maximum()) || (v <= minimum() && value() == minimum())) ) { //solve a very annoying bug where the formula can collapse while editing. With this trick the formula is not lost until focus is lost.
return cleanText();
}
return QSpinBox::textFromValue(val);
}
QValidator::State KisIntParseSpinBox::validate ( QString & input, int & pos ) const
{
Q_UNUSED(input);
Q_UNUSED(pos);
//this simple definition is sufficient for the moment
//TODO: see if needed to get something more complex.
return QValidator::Acceptable;
}
void KisIntParseSpinBox::stepBy(int steps)
{
boolLastValid = true;
emit noMoreParsingError();
QSpinBox::stepBy(steps);
}
void KisIntParseSpinBox::setValue(int val)
{
if(val == oldVal && hasFocus()){ //avoid to reset the button when it set the value of something that will recall this slot.
return;
}
if (!hasFocus()) {
clearError();
}
QSpinBox::setValue(val);
}
void KisIntParseSpinBox::setErrorStyle()
{
if (!boolLastValid) {
//setStyleSheet(_oldStyleSheet + "Background: red; color: white; padding-left: 18px;");
if (!isOldPaletteSaved) {
oldPalette = palette();
}
isOldPaletteSaved = true;
QPalette nP = oldPalette;
nP.setColor(QPalette::Background, Qt::red);
nP.setColor(QPalette::Base, Qt::red);
nP.setColor(QPalette::Text, Qt::white);
setPalette(nP);
if (!areOldMarginsSaved) {
oldMargins = lineEdit()->textMargins();
}
areOldMarginsSaved = true;
if (width() - height() >= 3*height()) { //if we have twice as much place as needed by the warning icon then display it.
QMargins newMargins = oldMargins;
newMargins.setLeft( newMargins.left() + height() - 4 );
lineEdit()->setTextMargins(newMargins);
int h = warningIcon->height();
int hp = height()-2;
if (h != hp) {
warningIcon->resize(hp, hp);
if (QFile(":/./16_light_warning.svg").exists()) {
warningIcon->setPixmap(QIcon(":/./16_light_warning.svg").pixmap(hp-7, hp-7));
}
}
warningIcon->move(oldMargins.left()+4, 1);
warningIcon->setVisible(true);
}
}
}
void KisIntParseSpinBox::clearErrorStyle()
{
if (boolLastValid) {
warningIcon->setVisible(false);
//setStyleSheet(QString());
setPalette(oldPalette);
isOldPaletteSaved = false;
lineEdit()->setTextMargins(oldMargins);
areOldMarginsSaved = false;
}
}
void KisIntParseSpinBox::clearError()
{
boolLastValid = true;
emit noMoreParsingError();
oldVal = value();
clearErrorStyle();
}
diff --git a/plugins/dockers/specificcolorselector/CMakeLists.txt b/plugins/dockers/specificcolorselector/CMakeLists.txt
index b05aff26e3..97f7ab2cdd 100644
--- a/plugins/dockers/specificcolorselector/CMakeLists.txt
+++ b/plugins/dockers/specificcolorselector/CMakeLists.txt
@@ -1,8 +1,14 @@
set(KRITA_SPECIFICCOLORSELECTOR_SOURCES
specificcolorselector.cc
specificcolorselector_dock.cc
kis_specific_color_selector_widget.cc
)
+
+ki18n_wrap_ui(KRITA_SPECIFICCOLORSELECTOR_SOURCES
+ wdgSpecificColorSelectorWidget.ui
+)
+
+
add_library(kritaspecificcolorselector MODULE ${KRITA_SPECIFICCOLORSELECTOR_SOURCES})
target_link_libraries(kritaspecificcolorselector kritaui ${OPENEXR_LIBRARIES})
install(TARGETS kritaspecificcolorselector DESTINATION ${KRITA_PLUGIN_INSTALL_DIR})
diff --git a/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.cc b/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.cc
index 2608495ebe..9e6c056a1c 100644
--- a/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.cc
+++ b/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.cc
@@ -1,256 +1,269 @@
/*
* Copyright (c) 2008 Cyrille Berger
* Copyright (c) 2015 Moritz Molch
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_specific_color_selector_widget.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
+#include
+#include
+#include "ui_wdgSpecificColorSelectorWidget.h"
KisSpecificColorSelectorWidget::KisSpecificColorSelectorWidget(QWidget* parent)
: QWidget(parent)
, m_colorSpace(0)
, m_spacer(0)
, m_updateCompressor(new KisSignalCompressor(10, KisSignalCompressor::POSTPONE, this))
, m_customColorSpaceSelected(false)
, m_displayConverter(0)
{
- m_layout = new QVBoxLayout(this);
- m_layout->setContentsMargins(0,0,0,0);
- m_layout->setSpacing(1);
+ m_ui = new Ui_wdgSpecificColorSelectorWidget();
+ m_ui->setupUi(this);
+
m_updateAllowed = true;
connect(m_updateCompressor, SIGNAL(timeout()), SLOT(updateTimeout()));
m_colorspaceSelector = new KisColorSpaceSelector(this);
- m_colorspaceSelector->layout()->setSpacing(1);
connect(m_colorspaceSelector, SIGNAL(colorSpaceChanged(const KoColorSpace*)), this, SLOT(setCustomColorSpace(const KoColorSpace*)));
- m_chkShowColorSpaceSelector = new QCheckBox(i18n("Show Colorspace Selector"), this);
- connect(m_chkShowColorSpaceSelector, SIGNAL(toggled(bool)), m_colorspaceSelector, SLOT(setVisible(bool)));
+ m_ui->colorspacePopupButton->setPopupWidget(m_colorspaceSelector);
- m_chkUsePercentage = new QCheckBox(i18n("Use Percentage"), this);
- connect(m_chkUsePercentage, SIGNAL(toggled(bool)), this, SLOT(onChkUsePercentageChanged(bool)));
+ connect(m_ui->chkUsePercentage, SIGNAL(toggled(bool)), this, SLOT(onChkUsePercentageChanged(bool)));
KConfigGroup cfg = KSharedConfig::openConfig()->group(QString());
- m_chkShowColorSpaceSelector->setChecked(cfg.readEntry("SpecificColorSelector/ShowColorSpaceSelector", true));
- m_chkUsePercentage->setChecked(cfg.readEntry("SpecificColorSelector/UsePercentage", false));
+ m_ui->chkUsePercentage->setChecked(cfg.readEntry("SpecificColorSelector/UsePercentage", false));
+ m_ui->chkUsePercentage->setIcon(KisIconUtils::loadIcon("ratio"));
- m_colorspaceSelector->setVisible(m_chkShowColorSpaceSelector->isChecked());
m_colorspaceSelector->showColorBrowserButton(false);
- m_layout->addWidget(m_chkShowColorSpaceSelector);
- m_layout->addWidget(m_chkUsePercentage);
- m_layout->addWidget(m_colorspaceSelector);
-
m_spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding);
- m_layout->addItem(m_spacer);
+ m_ui->slidersLayout->addItem(m_spacer);
}
KisSpecificColorSelectorWidget::~KisSpecificColorSelectorWidget()
{
KConfigGroup cfg = KSharedConfig::openConfig()->group(QString());
- cfg.writeEntry("SpecificColorSelector/ShowColorSpaceSelector", m_chkShowColorSpaceSelector->isChecked());
- cfg.writeEntry("SpecificColorSelector/UsePercentage", m_chkUsePercentage->isChecked());
+ cfg.writeEntry("SpecificColorSelector/UsePercentage", m_ui->chkUsePercentage->isChecked());
}
bool KisSpecificColorSelectorWidget::customColorSpaceUsed()
{
return m_customColorSpaceSelected;
}
+void KisSpecificColorSelectorWidget::resizeEvent(QResizeEvent *event)
+{
+ QWidget::resizeEvent(event);
+
+ if (m_colorSpace) {
+ QString elidedColorspaceName = m_ui->colorspacePopupButton->fontMetrics().elidedText(
+ m_colorSpace->name(), Qt::ElideRight,
+ m_ui->colorspacePopupButton->width()
+ );
+ m_ui->colorspacePopupButton->setText(elidedColorspaceName);
+ }
+}
+
void KisSpecificColorSelectorWidget::setDisplayConverter(KisDisplayColorConverter *displayConverter)
{
const bool needsForceUpdate = m_displayConverter != displayConverter;
m_displayConverter = displayConverter;
if (m_displayConverter) {
m_converterConnection.clear();
m_converterConnection.addConnection(m_displayConverter, SIGNAL(displayConfigurationChanged()), this, SLOT(rereadCurrentColorSpace()));
}
rereadCurrentColorSpace(needsForceUpdate);
}
void KisSpecificColorSelectorWidget::rereadCurrentColorSpace(bool force)
{
if (m_displayConverter && !m_customColorSpaceSelected) {
m_colorSpace = m_displayConverter->paintingColorSpace();
}
setColorSpace(m_colorSpace, force);
setColor(m_color);
}
void KisSpecificColorSelectorWidget::setColorSpace(const KoColorSpace* cs, bool force)
{
Q_ASSERT(cs);
dbgPlugins << cs->id() << " " << cs->profile()->name();
if (*m_colorSpace == *cs && !force) {
Q_FOREACH (KisColorInput* input, m_inputs) {
input->update();
}
return;
}
if (cs->colorDepthId() == Integer8BitsColorDepthID || cs->colorDepthId() == Integer16BitsColorDepthID) {
- m_chkUsePercentage->setVisible(true);
+ m_ui->chkUsePercentage->setVisible(true);
} else {
- m_chkUsePercentage->setVisible(false);
+ m_ui->chkUsePercentage->setVisible(false);
}
m_colorSpace = KoColorSpaceRegistry::instance()->colorSpace(cs->colorModelId().id(), cs->colorDepthId().id(), cs->profile());
Q_ASSERT(m_colorSpace);
Q_ASSERT(*m_colorSpace == *cs);
+
+ QString elidedColorspaceName = m_ui->colorspacePopupButton->fontMetrics().elidedText(
+ m_colorSpace->name(), Qt::ElideRight,
+ m_ui->colorspacePopupButton->width()
+ );
+ m_ui->colorspacePopupButton->setText(elidedColorspaceName);
+
m_color = KoColor(m_color, m_colorSpace);
Q_FOREACH (KisColorInput* input, m_inputs) {
delete input;
}
m_inputs.clear();
- m_layout->removeItem(m_spacer);
+ m_ui->slidersLayout->removeItem(m_spacer);
QList channels = KoChannelInfo::displayOrderSorted(m_colorSpace->channels());
KoColorDisplayRendererInterface *displayRenderer =
m_displayConverter ?
m_displayConverter->displayRendererInterface() :
KisDisplayColorConverter::dumbConverterInstance()->displayRendererInterface();
Q_FOREACH (KoChannelInfo* channel, channels) {
if (channel->channelType() == KoChannelInfo::COLOR) {
KisColorInput* input = 0;
switch (channel->channelValueType()) {
case KoChannelInfo::UINT8:
case KoChannelInfo::UINT16:
case KoChannelInfo::UINT32: {
- input = new KisIntegerColorInput(this, channel, &m_color, displayRenderer, m_chkUsePercentage->isChecked());
+ input = new KisIntegerColorInput(this, channel, &m_color, displayRenderer, m_ui->chkUsePercentage->isChecked());
}
break;
case KoChannelInfo::FLOAT16:
case KoChannelInfo::FLOAT32: {
input = new KisFloatColorInput(this, channel, &m_color, displayRenderer);
}
break;
default:
Q_ASSERT(false);
input = 0;
}
if (input) {
connect(input, SIGNAL(updated()), this, SLOT(update()));
connect(this, SIGNAL(updated()), input, SLOT(update()));
m_inputs.append(input);
- m_layout->addWidget(input);
+ m_ui->slidersLayout->addWidget(input);
}
}
}
QList labels;
int labelWidth = 0;
Q_FOREACH (KisColorInput* input, m_inputs) {
Q_FOREACH (QLabel* label, input->findChildren()) {
labels.append(label);
labelWidth = qMax(labelWidth, label->sizeHint().width());
}
}
Q_FOREACH (QLabel *label, labels) {
label->setMinimumWidth(labelWidth);
}
bool allChannels8Bit = true;
Q_FOREACH (KoChannelInfo* channel, channels) {
if (channel->channelType() == KoChannelInfo::COLOR && channel->channelValueType() != KoChannelInfo::UINT8) {
allChannels8Bit = false;
}
}
if (allChannels8Bit) {
KisColorInput* input = new KisHexColorInput(this, &m_color, displayRenderer);
m_inputs.append(input);
- m_layout->addWidget(input);
+ m_ui->slidersLayout->addWidget(input);
connect(input, SIGNAL(updated()), this, SLOT(update()));
connect(this, SIGNAL(updated()), input, SLOT(update()));
}
- m_layout->addItem(m_spacer);
+ m_ui->slidersLayout->addItem(m_spacer);
m_colorspaceSelector->blockSignals(true);
m_colorspaceSelector->setCurrentColorSpace(cs);
m_colorspaceSelector->blockSignals(false);
m_updateAllowed = false;
emit(updated());
m_updateAllowed = true;
}
void KisSpecificColorSelectorWidget::update()
{
if (m_updateAllowed) {
m_updateCompressor->start();
}
}
void KisSpecificColorSelectorWidget::setColor(const KoColor& c)
{
m_updateAllowed = false;
m_color.fromKoColor(c);
emit(updated());
m_updateAllowed = true;
}
void KisSpecificColorSelectorWidget::updateTimeout()
{
emit(colorChanged(m_color));
}
void KisSpecificColorSelectorWidget::setCustomColorSpace(const KoColorSpace *colorSpace)
{
m_customColorSpaceSelected = true;
setColorSpace(colorSpace);
setColor(m_color);
}
void KisSpecificColorSelectorWidget::onChkUsePercentageChanged(bool isChecked)
{
for (auto input: m_inputs) {
input->setPercentageWise(isChecked);
}
emit(updated());
}
-#include "moc_kis_specific_color_selector_widget.cpp"
diff --git a/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.h b/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.h
index 83a2218969..2b2b3c9340 100644
--- a/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.h
+++ b/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.h
@@ -1,73 +1,80 @@
/*
* Copyright (c) 2008 Cyrille Berger
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _KIS_SPECIFIC_COLOR_SELECTOR_WIDGET_H_
#define _KIS_SPECIFIC_COLOR_SELECTOR_WIDGET_H_
#include
#include
#include "kis_signal_auto_connection.h"
+#include "ui_wdgSpecificColorSelectorWidget.h"
+
+
class KoColorSpace;
class QVBoxLayout;
class KisColorInput;
class KisColorSpaceSelector;
class QCheckBox;
class KisSignalCompressor;
class QSpacerItem;
class KisDisplayColorConverter;
+class KisPopupButton;
class KisSpecificColorSelectorWidget : public QWidget
{
Q_OBJECT
public:
KisSpecificColorSelectorWidget(QWidget* parent);
~KisSpecificColorSelectorWidget() override;
bool customColorSpaceUsed();
+
+protected:
+ void resizeEvent(QResizeEvent* event) override;
+
public Q_SLOTS:
void setDisplayConverter(KisDisplayColorConverter *colorConverter);
void setColorSpace(const KoColorSpace *cs, bool force = false);
void setColor(const KoColor&);
private Q_SLOTS:
void update();
void updateTimeout();
void setCustomColorSpace(const KoColorSpace *);
void rereadCurrentColorSpace(bool force = false);
void onChkUsePercentageChanged(bool);
Q_SIGNALS:
void colorChanged(const KoColor&);
void updated();
private:
QList m_inputs;
const KoColorSpace* m_colorSpace;
- QVBoxLayout *m_layout;
QSpacerItem *m_spacer;
KoColor m_color;
bool m_updateAllowed;
KisSignalCompressor *m_updateCompressor;
KisColorSpaceSelector *m_colorspaceSelector;
bool m_customColorSpaceSelected;
- QCheckBox *m_chkShowColorSpaceSelector;
- QCheckBox *m_chkUsePercentage;
+ Ui_wdgSpecificColorSelectorWidget* m_ui;
+
KisDisplayColorConverter *m_displayConverter;
KisSignalAutoConnectionsStore m_converterConnection;
};
#endif
diff --git a/plugins/dockers/specificcolorselector/wdgSpecificColorSelectorWidget.ui b/plugins/dockers/specificcolorselector/wdgSpecificColorSelectorWidget.ui
new file mode 100644
index 0000000000..9f0e2169e4
--- /dev/null
+++ b/plugins/dockers/specificcolorselector/wdgSpecificColorSelectorWidget.ui
@@ -0,0 +1,116 @@
+
+
+ wdgSpecificColorSelectorWidget
+
+
+
+ 0
+ 0
+ 268
+ 207
+
+
+
+ Form
+
+
+ -
+
+
+ QLayout::SetDefaultConstraint
+
+
-
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+ Use percentage
+
+
+
+
+
+
+
+
+
+ 20
+ 20
+
+
+
+ true
+
+
+
+
+
+ -
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+ KisPopupButton
+ QPushButton
+
+
+
+
+
+