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

#include <WGShadeLineEditor.h>

+ Inheritance diagram for WGShadeLineEditor:

Signals

void sigEditorClosed (int lineIndex)
 

Public Member Functions

WGConfig::ShadeLine configuration () const
 
QIcon generateIcon (const WGConfig::ShadeLine &cfg)
 
void setConfiguration (const WGConfig::ShadeLine &cfg, int lineIndex)
 
 WGShadeLineEditor (QWidget *parent=nullptr)
 
 ~WGShadeLineEditor ()
 

Protected Member Functions

void hideEvent (QHideEvent *event) override
 

Private Slots

void slotPatchCountChanged (int value)
 
void slotSliderModeChanged (bool enabled)
 
void slotValueChanged ()
 

Private Attributes

WGShadeSliderm_iconSlider
 
int m_lineIndex {0}
 
KisVisualColorModelSP m_model
 
WGShadeSliderm_previewLine
 
QScopedPointer< Ui_WGShadeLineEditor > m_ui
 

Detailed Description

Definition at line 20 of file WGShadeLineEditor.h.

Constructor & Destructor Documentation

◆ WGShadeLineEditor()

WGShadeLineEditor::WGShadeLineEditor ( QWidget * parent = nullptr)
explicit

Definition at line 15 of file WGShadeLineEditor.cpp.

16 : QFrame(parent, Qt::Popup)
18 , m_ui(new Ui_WGShadeLineEditor)
21{
22 setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
23
24 m_model->slotSetColorSpace(KoColorSpaceRegistry::instance()->rgb8());
25 m_model->slotSetColor(KoColor(QColor(190, 50, 50), m_model->colorSpace()));
26
27 m_ui->setupUi(this);
28
29 m_previewLine->setObjectName(QString::fromUtf8("previewLine"));
30 m_previewLine->setFixedHeight(24);
31
32 m_ui->verticalLayout->addWidget(m_previewLine);
33
34 m_ui->verticalLayout->setSizeConstraint(QLayout::SetFixedSize);
37 // since this widget is not shown by Qt, a resize event needs to be sent manually
38 QResizeEvent event(QSize(128, 10), m_iconSlider->size());
39 m_iconSlider->resize(128, 10);
40 QCoreApplication::sendEvent(m_iconSlider, &event);
41 m_iconSlider->hide();
42 m_iconSlider->slotSetChannelValues(m_model->channelValues());
43 connect(m_ui->sbRangeHue, SIGNAL(valueChanged(double)), SLOT(slotValueChanged()));
44 connect(m_ui->sbRangeSaturation, SIGNAL(valueChanged(double)), SLOT(slotValueChanged()));
45 connect(m_ui->sbRangeValue, SIGNAL(valueChanged(double)), SLOT(slotValueChanged()));
46 connect(m_ui->sbOffsetHue, SIGNAL(valueChanged(double)), SLOT(slotValueChanged()));
47 connect(m_ui->sbOffsetSaturation, SIGNAL(valueChanged(double)), SLOT(slotValueChanged()));
48 connect(m_ui->sbOffsetValue, SIGNAL(valueChanged(double)), SLOT(slotValueChanged()));
49 connect(m_ui->sbPatchCount, SIGNAL(valueChanged(int)), SLOT(slotPatchCountChanged(int)));
50 connect(m_ui->rbSlider, SIGNAL(toggled(bool)), SLOT(slotSliderModeChanged(bool)));
51 // disable spinBox when slider mode set
52 connect(m_ui->rbColorPatches, SIGNAL(toggled(bool)), m_ui->sbPatchCount, SLOT(setEnabled(bool)));
53}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
QSharedPointer< WGSelectorDisplayConfig > WGSelectorDisplayConfigSP
The KisVisualColorModel class allows manipulating a KoColor using various color models.
void slotPatchCountChanged(int value)
void slotSliderModeChanged(bool enabled)
WGShadeSlider * m_previewLine
KisVisualColorModelSP m_model
WGShadeSlider * m_iconSlider
QScopedPointer< Ui_WGShadeLineEditor > m_ui
void setModel(KisVisualColorModelSP model)
void slotSetChannelValues(const QVector4D &values)
static KoColorSpaceRegistry * instance()

References connect(), KoColorSpaceRegistry::instance(), m_iconSlider, m_model, m_previewLine, m_ui, WGShadeSlider::setModel(), slotPatchCountChanged(), WGShadeSlider::slotSetChannelValues(), slotSliderModeChanged(), and slotValueChanged().

◆ ~WGShadeLineEditor()

WGShadeLineEditor::~WGShadeLineEditor ( )

Definition at line 55 of file WGShadeLineEditor.cpp.

56{
57
58}

Member Function Documentation

◆ configuration()

WGConfig::ShadeLine WGShadeLineEditor::configuration ( ) const

Definition at line 60 of file WGShadeLineEditor.cpp.

61{
63 cfg.gradient = QVector4D(m_ui->sbRangeHue->value(),
64 m_ui->sbRangeSaturation->value(),
65 m_ui->sbRangeValue->value(),
66 0);
67 cfg.offset = QVector4D(m_ui->sbOffsetHue->value(),
68 m_ui->sbOffsetSaturation->value(),
69 m_ui->sbOffsetValue->value(),
70 0);
71 cfg.patchCount = m_ui->rbSlider->isChecked() ? -1 : m_ui->sbPatchCount->value();
72 return cfg;
73}
QVector4D offset
Definition WGConfig.h:88
QVector4D gradient
Definition WGConfig.h:87

References WGConfig::ShadeLine::gradient, m_ui, WGConfig::ShadeLine::offset, and WGConfig::ShadeLine::patchCount.

◆ generateIcon()

QIcon WGShadeLineEditor::generateIcon ( const WGConfig::ShadeLine & cfg)

Definition at line 93 of file WGShadeLineEditor.cpp.

94{
97 return QIcon(QPixmap::fromImage(*m_iconSlider->background()));
98}
const QImage * background()
void setDisplayMode(bool slider, int numPatches=-1)
void setGradient(const QVector4D &range, const QVector4D &offset)

References WGShadeSlider::background(), WGConfig::ShadeLine::gradient, m_iconSlider, WGConfig::ShadeLine::offset, WGConfig::ShadeLine::patchCount, WGShadeSlider::setDisplayMode(), and WGShadeSlider::setGradient().

◆ hideEvent()

void WGShadeLineEditor::hideEvent ( QHideEvent * event)
overrideprotected

Definition at line 100 of file WGShadeLineEditor.cpp.

101{
103 QWidget::hideEvent(event);
104}
void sigEditorClosed(int lineIndex)

References m_lineIndex, and sigEditorClosed().

◆ setConfiguration()

void WGShadeLineEditor::setConfiguration ( const WGConfig::ShadeLine & cfg,
int lineIndex )

Definition at line 75 of file WGShadeLineEditor.cpp.

76{
77 m_ui->sbRangeHue->setValue(cfg.gradient.x());
78 m_ui->sbRangeSaturation->setValue(cfg.gradient.y());
79 m_ui->sbRangeValue->setValue(cfg.gradient.z());
80 m_ui->sbOffsetHue->setValue(cfg.offset.x());
81 m_ui->sbOffsetSaturation->setValue(cfg.offset.y());
82 m_ui->sbOffsetValue->setValue(cfg.offset.z());
83 if (cfg.patchCount > 0) {
84 m_ui->rbColorPatches->setChecked(true);
85 m_ui->sbPatchCount->setValue(cfg.patchCount);
86 }
87 else {
88 m_ui->rbSlider->setChecked(true);
89 }
90 m_lineIndex = lineIndex;
91}

References WGConfig::ShadeLine::gradient, m_lineIndex, m_ui, WGConfig::ShadeLine::offset, and WGConfig::ShadeLine::patchCount.

◆ sigEditorClosed

void WGShadeLineEditor::sigEditorClosed ( int lineIndex)
signal

◆ slotPatchCountChanged

void WGShadeLineEditor::slotPatchCountChanged ( int value)
privateslot

Definition at line 112 of file WGShadeLineEditor.cpp.

113{
115}
float value(const T *src, size_t ch)

References m_previewLine, WGShadeSlider::setDisplayMode(), and value().

◆ slotSliderModeChanged

void WGShadeLineEditor::slotSliderModeChanged ( bool enabled)
privateslot

Definition at line 117 of file WGShadeLineEditor.cpp.

118{
119 m_previewLine->setDisplayMode(enabled, m_ui->sbPatchCount->value());
120}

References m_previewLine, m_ui, and WGShadeSlider::setDisplayMode().

◆ slotValueChanged

void WGShadeLineEditor::slotValueChanged ( )
privateslot

Member Data Documentation

◆ m_iconSlider

WGShadeSlider* WGShadeLineEditor::m_iconSlider
private

Definition at line 46 of file WGShadeLineEditor.h.

◆ m_lineIndex

int WGShadeLineEditor::m_lineIndex {0}
private

Definition at line 47 of file WGShadeLineEditor.h.

47{0};

◆ m_model

KisVisualColorModelSP WGShadeLineEditor::m_model
private

Definition at line 43 of file WGShadeLineEditor.h.

◆ m_previewLine

WGShadeSlider* WGShadeLineEditor::m_previewLine
private

Definition at line 45 of file WGShadeLineEditor.h.

◆ m_ui

QScopedPointer<Ui_WGShadeLineEditor> WGShadeLineEditor::m_ui
private

Definition at line 44 of file WGShadeLineEditor.h.


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