• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • krita API Reference
  • KDE Home
  • Contact Us
 

plugins/paintops/libpaintop

  • sources
  • kfour-appscomplete
  • krita
  • plugins
  • paintops
  • libpaintop
kis_color_option.cpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2009, 2010 Lukáš Tvrdý ([email protected])
3  *
4  * SPDX-License-Identifier: GPL-2.0-or-later
5  */
6 
7 #include "kis_color_option.h"
8 #include <klocalizedstring.h>
9 
10 #include "ui_wdgcoloroptions.h"
11 
12 class KisColorOptionsWidget: public QWidget, public Ui::WdgColorOptions
13 {
14 public:
15  KisColorOptionsWidget(QWidget *parent = 0)
16  : QWidget(parent) {
17  setupUi(this);
18 
19  hueSlider->setRange(-180, 180);
20  hueSlider->setValue(0);
21 
22  saturationSlider->setRange(-100, 100);
23  saturationSlider->setValue(0);
24 
25  valueSlider->setRange(-100, 100);
26  valueSlider->setValue(0);
27 
28  }
29 };
30 
31 KisColorOption::KisColorOption()
32  : KisPaintOpOption(KisPaintOpOption::COLOR, false)
33 {
34  m_checkable = false;
35  m_options = new KisColorOptionsWidget();
36 
37  setObjectName("KisColorOption");
38 
39  // ui
40  connect(m_options->randomHSVCHBox, SIGNAL(toggled(bool)), SLOT(setHSVEnabled(bool)));
41  // settings
42  connect(m_options->randomOpacityCHBox, SIGNAL(toggled(bool)), SLOT(emitSettingChanged()));
43  connect(m_options->randomHSVCHBox, SIGNAL(toggled(bool)), SLOT(emitSettingChanged()));
44  connect(m_options->hueSlider, SIGNAL(valueChanged(int)), SLOT(emitSettingChanged()));
45  connect(m_options->saturationSlider, SIGNAL(valueChanged(int)), SLOT(emitSettingChanged()));
46  connect(m_options->valueSlider, SIGNAL(valueChanged(int)), SLOT(emitSettingChanged()));
47  connect(m_options->sampleInputCHBox, SIGNAL(toggled(bool)), SLOT(emitSettingChanged()));
48  connect(m_options->colorPerParticleCHBox, SIGNAL(toggled(bool)), SLOT(emitSettingChanged()));
49  connect(m_options->fillBackgroundCHBox, SIGNAL(toggled(bool)), SLOT(emitSettingChanged()));
50  connect(m_options->mixBgColorCHBox, SIGNAL(toggled(bool)), SLOT(emitSettingChanged()));
51 
52  setConfigurationPage(m_options);
53 }
54 
55 KisColorOption::~KisColorOption()
56 {
57  // delete m_options;
58 }
59 
60 void KisColorOption::writeOptionSetting(KisPropertiesConfigurationSP setting) const
61 {
62  setting->setProperty(COLOROP_HUE, hue());
63  setting->setProperty(COLOROP_SATURATION, saturation());
64  setting->setProperty(COLOROP_VALUE, value());
65 
66  setting->setProperty(COLOROP_USE_RANDOM_HSV, useRandomHSV());
67  setting->setProperty(COLOROP_USE_RANDOM_OPACITY, useRandomOpacity());
68  setting->setProperty(COLOROP_SAMPLE_COLOR, sampleInputColor());
69 
70  setting->setProperty(COLOROP_FILL_BG, fillBackground());
71  setting->setProperty(COLOROP_COLOR_PER_PARTICLE, colorPerParticle());
72  setting->setProperty(COLOROP_MIX_BG_COLOR, mixBgColor());
73 }
74 
75 void KisColorOption::readOptionSetting(const KisPropertiesConfigurationSP setting)
76 {
77  m_options->hueSlider->setValue(setting->getInt(COLOROP_HUE, 0));
78  m_options->saturationSlider->setValue(setting->getInt(COLOROP_SATURATION, 0));
79  m_options->valueSlider->setValue(setting->getInt(COLOROP_VALUE, 0));
80  m_options->randomOpacityCHBox->setChecked(setting->getBool(COLOROP_USE_RANDOM_OPACITY));
81  m_options->randomHSVCHBox->setChecked(setting->getBool(COLOROP_USE_RANDOM_HSV, false));
82  setHSVEnabled(m_options->randomHSVCHBox->isChecked());
83  m_options->sampleInputCHBox->setChecked(setting->getBool(COLOROP_SAMPLE_COLOR, false));
84  m_options->fillBackgroundCHBox->setChecked(setting->getBool(COLOROP_FILL_BG, false));
85  m_options->colorPerParticleCHBox->setChecked(setting->getBool(COLOROP_COLOR_PER_PARTICLE, false));
86  m_options->mixBgColorCHBox->setChecked(setting->getBool(COLOROP_MIX_BG_COLOR, false));
87 }
88 
89 void KisColorOption::setHSVEnabled(bool enabled)
90 {
91  m_options->hueSlider->setEnabled(enabled);
92  m_options->saturationSlider->setEnabled(enabled);
93  m_options->valueSlider->setEnabled(enabled);
94 }
95 
96 bool KisColorOption::useRandomOpacity() const
97 {
98  return m_options->randomOpacityCHBox->isChecked();
99 }
100 
101 bool KisColorOption::useRandomHSV() const
102 {
103  return m_options->randomHSVCHBox->isChecked();
104 }
105 
106 int KisColorOption::hue() const
107 {
108  return m_options->hueSlider->value();
109 }
110 
111 
112 int KisColorOption::saturation() const
113 {
114  return m_options->saturationSlider->value();
115 }
116 
117 
118 int KisColorOption::value() const
119 {
120  return m_options->valueSlider->value();
121 }
122 
123 
124 bool KisColorOption::sampleInputColor() const
125 {
126  return m_options->sampleInputCHBox->isChecked();
127 }
128 
129 
130 
131 bool KisColorOption::colorPerParticle() const
132 {
133  return m_options->colorPerParticleCHBox->isChecked();
134 }
135 
136 
137 bool KisColorOption::fillBackground() const
138 {
139  return m_options->fillBackgroundCHBox->isChecked();
140 }
141 
142 
143 bool KisColorOption::mixBgColor() const
144 {
145  return m_options->mixBgColorCHBox->isChecked();
146 }
147 
148 void KisColorProperties::fillProperties(const KisPropertiesConfigurationSP setting)
149 {
150  hue = setting->getInt(COLOROP_HUE, 0);
151  saturation = setting->getInt(COLOROP_SATURATION, 0);
152  value = setting->getInt(COLOROP_VALUE, 0);
153  useRandomOpacity = setting->getBool(COLOROP_USE_RANDOM_OPACITY, false);
154  useRandomHSV = setting->getBool(COLOROP_USE_RANDOM_HSV, false);
155  sampleInputColor = setting->getBool(COLOROP_SAMPLE_COLOR, false);
156  fillBackground = setting->getBool(COLOROP_FILL_BG, false);
157  colorPerParticle = setting->getBool(COLOROP_COLOR_PER_PARTICLE, false);
158  mixBgColor = setting->getBool(COLOROP_MIX_BG_COLOR, false);
159 }
COLOROP_HUE
const QString COLOROP_HUE
Definition: kis_color_option.h:13
KisColorOption::useRandomHSV
bool useRandomHSV() const
Definition: kis_color_option.cpp:101
KisColorOption::KisColorOption
KisColorOption()
Definition: kis_color_option.cpp:31
KisColorOption::value
int value() const
Definition: kis_color_option.cpp:118
KisColorProperties::sampleInputColor
bool sampleInputColor
Definition: kis_color_option.h:65
KisColorProperties::useRandomHSV
bool useRandomHSV
Definition: kis_color_option.h:63
QWidget
KisColorProperties::useRandomOpacity
bool useRandomOpacity
Definition: kis_color_option.h:64
COLOROP_COLOR_PER_PARTICLE
const QString COLOROP_COLOR_PER_PARTICLE
Definition: kis_color_option.h:22
COLOROP_USE_RANDOM_OPACITY
const QString COLOROP_USE_RANDOM_OPACITY
Definition: kis_color_option.h:18
KisColorOption::colorPerParticle
bool colorPerParticle() const
Definition: kis_color_option.cpp:131
KisColorOption::useRandomOpacity
bool useRandomOpacity() const
Definition: kis_color_option.cpp:96
COLOROP_USE_RANDOM_HSV
const QString COLOROP_USE_RANDOM_HSV
Definition: kis_color_option.h:17
COLOROP_MIX_BG_COLOR
const QString COLOROP_MIX_BG_COLOR
Definition: kis_color_option.h:23
KisColorProperties::saturation
int saturation
Definition: kis_color_option.h:72
KisColorProperties::fillProperties
void fillProperties(const KisPropertiesConfigurationSP setting)
fill the class members with related properties
Definition: kis_color_option.cpp:148
kis_color_option.h
COLOROP_VALUE
const QString COLOROP_VALUE
Definition: kis_color_option.h:15
COLOROP_FILL_BG
const QString COLOROP_FILL_BG
Definition: kis_color_option.h:21
KisColorOption::writeOptionSetting
void writeOptionSetting(KisPropertiesConfigurationSP setting) const override
Definition: kis_color_option.cpp:60
QWidget::setupUi
void setupUi(QWidget *widget)
KisColorProperties::fillBackground
bool fillBackground
Definition: kis_color_option.h:67
KisColorOption::mixBgColor
bool mixBgColor() const
Definition: kis_color_option.cpp:143
KisPaintOpOption
KisColorProperties::hue
int hue
Definition: kis_color_option.h:71
KisColorOption::fillBackground
bool fillBackground() const
Definition: kis_color_option.cpp:137
KisColorOption::hue
int hue() const
Definition: kis_color_option.cpp:106
KisColorOption::sampleInputColor
bool sampleInputColor() const
Definition: kis_color_option.cpp:124
COLOROP_SAMPLE_COLOR
const QString COLOROP_SAMPLE_COLOR
Definition: kis_color_option.h:19
KisColorProperties::value
int value
Definition: kis_color_option.h:73
KisColorProperties::mixBgColor
bool mixBgColor
Definition: kis_color_option.h:69
KisColorOption::readOptionSetting
void readOptionSetting(const KisPropertiesConfigurationSP setting) override
Definition: kis_color_option.cpp:75
KisColorOption::~KisColorOption
~KisColorOption() override
Definition: kis_color_option.cpp:55
KisColorProperties::colorPerParticle
bool colorPerParticle
Definition: kis_color_option.h:68
QObject::parent
QObject * parent() const
COLOROP_SATURATION
const QString COLOROP_SATURATION
Definition: kis_color_option.h:14
KisColorOption::saturation
int saturation() const
Definition: kis_color_option.cpp:112
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Apr 18 2021 23:38:44 by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

plugins/paintops/libpaintop

Skip menu "plugins/paintops/libpaintop"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

krita API Reference

Skip menu "krita API Reference"
  • libs
  •   KritaBasicFlakes
  •   brush
  •   KritaUndo2
  •   KritaFlake
  •   image
  •   KritaPlugin
  •   Krita
  •   KritaPigment
  •   KritaResources
  •   KritaStore
  •   ui
  •   KritaWidgets
  •   KritaWidgetUtils
  • plugins
  •   Assitants
  •   Extensions
  •   Filters
  •   Generators
  •   Formats
  •           src
  •   PaintOps
  •     libpaintop

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal