Krita Source Code Documentation
Loading...
Searching...
No Matches
KisWdgIndexColors Class Reference

#include <kiswdgindexcolors.h>

+ Inheritance diagram for KisWdgIndexColors:

Classes

struct  ColorWidgets
 

Public Member Functions

KisPropertiesConfigurationSP configuration () const override
 
 KisWdgIndexColors (QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags(), int delay=500)
 
void setConfiguration (const KisPropertiesConfigurationSP config) override
 
void setup (QStringList shadesLabels, int ramps)
 
- Public Member Functions inherited from KisConfigWidget
virtual KoCanvasResourcesInterfaceSP canvasResourcesInterface () const
 
virtual void setCanvasResourcesInterface (KoCanvasResourcesInterfaceSP canvasResourcesInterface)
 
virtual void setView (KisViewManager *view)
 
 ~KisConfigWidget () override
 

Private Slots

void slotColorLimitChanged (int value)
 

Private Attributes

QVector< QVector< ColorWidgets > > m_colorSelectors
 
QVector< QSpinBox * > m_stepSpinners
 
Ui::KisWdgIndexColors * ui
 

Additional Inherited Members

- Signals inherited from KisConfigWidget
void sigConfigurationItemChanged ()
 
void sigConfigurationUpdated ()
 
void sigDropLockedConfig (KisPropertiesConfigurationSP p)
 
void sigSaveLockedConfig (KisPropertiesConfigurationSP p)
 
- Protected Member Functions inherited from KisConfigWidget
 KisConfigWidget (QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags(), int delay=200)
 

Detailed Description

Definition at line 20 of file kiswdgindexcolors.h.

Constructor & Destructor Documentation

◆ KisWdgIndexColors()

KisWdgIndexColors::KisWdgIndexColors ( QWidget * parent = 0,
Qt::WindowFlags f = Qt::WindowFlags(),
int delay = 500 )

Definition at line 18 of file kiswdgindexcolors.cpp.

18 : KisConfigWidget(parent, f, delay)
19{
20 ui = new Ui::KisWdgIndexColors;
21 ui->setupUi(this);
22
23 connect(ui->diagCheck, SIGNAL(toggled(bool)), SIGNAL(sigConfigurationItemChanged()));
24 connect(ui->inbetweenSpinBox, SIGNAL(valueChanged(int)), SIGNAL(sigConfigurationItemChanged()));
25 connect(ui->alphaStepsSpinBox, SIGNAL(valueChanged(int)), SIGNAL(sigConfigurationItemChanged()));
26
27 connect(ui->colorLimit, SIGNAL(valueChanged(int)), SLOT(slotColorLimitChanged(int)));
28 connect(ui->colorLimit, SIGNAL(valueChanged(int)), SIGNAL(sigConfigurationItemChanged()));
29
30 connect(ui->colorLimitCheck, SIGNAL(toggled(bool)), SIGNAL(sigConfigurationItemChanged()));
31
32 connect(ui->luminanceSlider, SIGNAL(valueChanged(int)), SIGNAL(sigConfigurationItemChanged()));
33 connect(ui->aSlider, SIGNAL(valueChanged(int)), SIGNAL(sigConfigurationItemChanged()));
34 connect(ui->bSlider, SIGNAL(valueChanged(int)), SIGNAL(sigConfigurationItemChanged()));
35}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void sigConfigurationItemChanged()
KisConfigWidget(QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags(), int delay=200)
void slotColorLimitChanged(int value)
Ui::KisWdgIndexColors * ui

References connect(), KisConfigWidget::sigConfigurationItemChanged(), slotColorLimitChanged(), and ui.

Member Function Documentation

◆ configuration()

KisPropertiesConfigurationSP KisWdgIndexColors::configuration ( ) const
overridevirtual
Returns
the configuration

Implements KisConfigWidget.

Definition at line 112 of file kiswdgindexcolors.cpp.

113{
115
117
118 for(int y = 0; y < 4; ++y)
119 for(int x = 0; x < 4; ++x)
120 {
121 palCfg.colors[y][x] = m_colorSelectors[y][x].button->color().toQColor();
122 palCfg.colorsEnabled[y][x] = m_colorSelectors[y][x].button->isEnabled();
123 }
124
125 for(int y = 0; y < 3; ++y)
126 palCfg.gradientSteps[y] = m_stepSpinners[y]->value();
127
128 palCfg.diagonalGradients = ui->diagCheck->isChecked();
129 palCfg.inbetweenRampSteps = ui->inbetweenSpinBox->value();
130
131 IndexColorPalette pal = palCfg.generate();
132 ui->colorCount->setText(QString::number(pal.numColors()));
133
134 config->setProperty("paletteGen", palCfg.toByteArray());
135
136 config->setProperty("LFactor", ui->luminanceSlider->value() / 100.f);
137 config->setProperty("aFactor", ui->aSlider->value() / 100.f);
138 config->setProperty("bFactor", ui->bSlider->value() / 100.f);
139
140 config->setProperty("reduceColorsEnabled", ui->colorLimitCheck->isChecked());
141 config->setProperty("colorLimit", ui->colorLimit->value());
142
143 config->setProperty("alphaSteps", ui->alphaStepsSpinBox->value());
144 return config;
145}
static KisResourcesInterfaceSP instance()
QVector< QVector< ColorWidgets > > m_colorSelectors
QVector< QSpinBox * > m_stepSpinners

References PaletteGeneratorConfig::colors, PaletteGeneratorConfig::colorsEnabled, PaletteGeneratorConfig::diagonalGradients, PaletteGeneratorConfig::generate(), PaletteGeneratorConfig::gradientSteps, PaletteGeneratorConfig::inbetweenRampSteps, KisGlobalResourcesInterface::instance(), m_colorSelectors, m_stepSpinners, IndexColorPalette::numColors(), PaletteGeneratorConfig::toByteArray(), and ui.

◆ setConfiguration()

void KisWdgIndexColors::setConfiguration ( const KisPropertiesConfigurationSP config)
overridevirtual
Parameters
configthe configuration for this configuration widget.

Implements KisConfigWidget.

Definition at line 147 of file kiswdgindexcolors.cpp.

148{
150 palCfg.fromByteArray(config->getProperty("paletteGen").toByteArray());
151
152 ui->luminanceSlider->setValue(config->getFloat("LFactor")*100);
153 ui->aSlider->setValue(config->getFloat("aFactor")*100);
154 ui->bSlider->setValue(config->getFloat("bFactor")*100);
155 ui->alphaStepsSpinBox->setValue(config->getInt("alphaSteps"));
156 ui->colorLimitCheck->setChecked(config->getBool("reduceColorsEnabled"));
157 ui->colorLimit->setEnabled(config->getBool("reduceColorsEnabled"));
158 ui->colorLimit->setValue(config->getInt("colorLimit"));
159 ui->diagCheck->setChecked(palCfg.diagonalGradients);
160 ui->inbetweenSpinBox->setValue(palCfg.inbetweenRampSteps);
161
162 for(int y = 0; y < 4; ++y)
163 for(int x = 0; x < 4; ++x)
164 {
165 m_colorSelectors[y][x].checkbox->setChecked(palCfg.colorsEnabled[y][x]);
166 m_colorSelectors[y][x].button->setEnabled(palCfg.colorsEnabled[y][x]);
167 KoColor c;
168 c.fromQColor(palCfg.colors[y][x]);
169 m_colorSelectors[y][x].button->setColor(c);
170 }
171
172 for(int y = 0; y < 3; ++y)
174
175 IndexColorPalette pal = palCfg.generate();
176 ui->colorCount->setText(QString::number(pal.numColors()));
177}
void fromQColor(const QColor &c)
Convenient function for converting from a QColor.
Definition KoColor.cpp:213
void fromByteArray(const QByteArray &str)

References PaletteGeneratorConfig::colors, PaletteGeneratorConfig::colorsEnabled, PaletteGeneratorConfig::diagonalGradients, PaletteGeneratorConfig::fromByteArray(), KoColor::fromQColor(), PaletteGeneratorConfig::generate(), PaletteGeneratorConfig::gradientSteps, PaletteGeneratorConfig::inbetweenRampSteps, m_colorSelectors, m_stepSpinners, IndexColorPalette::numColors(), and ui.

◆ setup()

void KisWdgIndexColors::setup ( QStringList shadesLabels,
int ramps )

Definition at line 43 of file kiswdgindexcolors.cpp.

44{
45 int rows = shadesLabels.length();
46 int columns = ramps;
47
48 m_colorSelectors.resize(rows);
49 m_stepSpinners.resize(rows-1);
50 // Labels for the shades
51 for(int row = 0; row < rows; ++row)
52 {
53 QLabel* l = new QLabel(shadesLabels[row], ui->colorsBox);
54 ui->layoutColors->addWidget(l, row+1, 0);
55 m_colorSelectors[row].resize(columns);
56 }
57 // Labels for the ramps
58 /*for(int col = 0; col < columns; ++col)
59 {
60 QLabel* l = new QLabel(rampsLabels[col], ui->colorsBox);
61 l->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
62 ui->layoutColors->addWidget(l, 0, col+1);
63 }*/
64 // Step selectors for the shade gradients
65 for(int row = 0; row < (rows-1); ++row)
66 {
67 QLabel* l0 = new QLabel(shadesLabels[row+1]);
68 QLabel* l1 = new QLabel(QString::fromUtf8("↔"));
69 QLabel* l2 = new QLabel(shadesLabels[row]);
70
71 QSpinBox* s = new KisIntParseSpinBox();
72 s->setMinimum(0);
73 s->setMaximum(32);
74 s->setValue(2);
75
76 connect(s, SIGNAL(valueChanged(int)), this, SIGNAL(sigConfigurationItemChanged()));
77 m_stepSpinners[row] = s;
78
79 ui->layoutRowSteps->addWidget(l0, row, 0);
80 ui->layoutRowSteps->addWidget(l1, row, 1);
81 ui->layoutRowSteps->addWidget(l2, row, 2);
82 ui->layoutRowSteps->addWidget(s, row, 3);
83 }
84 // Color selectors
85 for(int y = 0; y < rows; ++y)
86 for(int x = 0; x < columns; ++x)
87 {
89 QCheckBox* c = new QCheckBox;
90 c->setChecked(false);
91 b->setEnabled(false);
92 b->setMaximumWidth(50);
93 c->setMaximumWidth(21); // Ugh. I hope this won't be causing any issues. Trying to get rid of the unnecessary spacing after it.
94
95 connect(c, SIGNAL(toggled(bool)), b, SLOT(setEnabled(bool)));
96 connect(c, SIGNAL(toggled(bool)), this, SIGNAL(sigConfigurationItemChanged()));
97 connect(b, SIGNAL(changed(KoColor)), this, SIGNAL(sigConfigurationItemChanged()));
98
99 QHBoxLayout* cell = new QHBoxLayout();
100 cell->setSpacing(0);
101 cell->setContentsMargins(0, 0, 0, 0);
102 cell->addWidget(c);
103 cell->addWidget(b);
104 ui->layoutColors->addLayout(cell, 1+y, 1+x);
105
106 m_colorSelectors[y][x].button = b;
107 m_colorSelectors[y][x].checkbox = c;
108 }
109}
A pushbutton to display or allow user selection of a color.
The KisIntParseSpinBox class is a cleverer SpinBox, able to parse arithmetic expressions.

References connect(), m_colorSelectors, m_stepSpinners, KisConfigWidget::sigConfigurationItemChanged(), and ui.

◆ slotColorLimitChanged

void KisWdgIndexColors::slotColorLimitChanged ( int value)
privateslot

Definition at line 37 of file kiswdgindexcolors.cpp.

38{
39 ui->colorLimit->setSuffix(i18ncp("suffix for a spinbox",
40 " color", " colors", value));
41}
float value(const T *src, size_t ch)

References ui, and value().

Member Data Documentation

◆ m_colorSelectors

QVector< QVector<ColorWidgets> > KisWdgIndexColors::m_colorSelectors
private

Definition at line 38 of file kiswdgindexcolors.h.

◆ m_stepSpinners

QVector< QSpinBox* > KisWdgIndexColors::m_stepSpinners
private

Definition at line 39 of file kiswdgindexcolors.h.

◆ ui

Ui::KisWdgIndexColors* KisWdgIndexColors::ui
private

Definition at line 40 of file kiswdgindexcolors.h.


The documentation for this class was generated from the following files: