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

#include <slider_and_spin_box_sync.h>

+ Inheritance diagram for SliderAndSpinBoxSync:

Public Slots

void slotParentValueChanged ()
 

Public Member Functions

 SliderAndSpinBoxSync (KisDoubleSliderSpinBox *slider, QSpinBox *spinBox, IntFunction parentValueOp)
 
 ~SliderAndSpinBoxSync () override
 

Private Types

using IntFunction = std::function<int()>
 

Private Slots

void sliderChanged (qreal value)
 
void spinBoxChanged (int value)
 

Private Attributes

bool m_blockUpdates
 
IntFunction m_parentValueOp
 
KisDoubleSliderSpinBoxm_slider
 
QSpinBox * m_spinBox
 

Detailed Description

Syncs a slider measured in percentage with a spin box measuring real value getting value from parentValueOp.

E.g.

parentValueOp() — total system memory in MiB slider — percentage of the memory we can use spinBox — amount o fmemory we can use in MiB slotParentValueChanged() — should be called every time total memory changes

Definition at line 28 of file slider_and_spin_box_sync.h.

Member Typedef Documentation

◆ IntFunction

using SliderAndSpinBoxSync::IntFunction = std::function<int()>
private

Definition at line 31 of file slider_and_spin_box_sync.h.

Constructor & Destructor Documentation

◆ SliderAndSpinBoxSync()

SliderAndSpinBoxSync::SliderAndSpinBoxSync ( KisDoubleSliderSpinBox * slider,
QSpinBox * spinBox,
IntFunction parentValueOp )

Definition at line 16 of file slider_and_spin_box_sync.cpp.

19 : m_slider(slider),
20 m_spinBox(spinBox),
21 m_parentValueOp(parentValueOp),
22 m_blockUpdates(false)
23{
24 connect(m_slider, SIGNAL(valueChanged(qreal)), SLOT(sliderChanged(qreal)));
25 connect(m_spinBox, SIGNAL(valueChanged(int)), SLOT(spinBoxChanged(int)));
26}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisDoubleSliderSpinBox * m_slider

References connect(), m_slider, m_spinBox, sliderChanged(), and spinBoxChanged().

◆ ~SliderAndSpinBoxSync()

SliderAndSpinBoxSync::~SliderAndSpinBoxSync ( )
override

Definition at line 28 of file slider_and_spin_box_sync.cpp.

29{
30
31}

Member Function Documentation

◆ sliderChanged

void SliderAndSpinBoxSync::sliderChanged ( qreal value)
privateslot

Definition at line 43 of file slider_and_spin_box_sync.cpp.

43 {
44 if (m_blockUpdates) return;
45 m_blockUpdates = true;
46
47 m_spinBox->setValue(value * m_parentValueOp() / 100);
48
49 m_blockUpdates = false;
50}
float value(const T *src, size_t ch)

References m_blockUpdates, m_parentValueOp, m_spinBox, and value().

◆ slotParentValueChanged

void SliderAndSpinBoxSync::slotParentValueChanged ( )
slot

Definition at line 33 of file slider_and_spin_box_sync.cpp.

34{
35 int parentValue = m_parentValueOp();
36
37 m_spinBox->setRange(m_slider->minimum() * parentValue / 100,
38 m_slider->maximum() * parentValue / 100);
39
40 sliderChanged(m_slider->value());
41}

References m_parentValueOp, m_slider, m_spinBox, and sliderChanged().

◆ spinBoxChanged

void SliderAndSpinBoxSync::spinBoxChanged ( int value)
privateslot

Definition at line 52 of file slider_and_spin_box_sync.cpp.

53{
54 if (m_blockUpdates) return;
55 m_blockUpdates = true;
56
57 m_slider->setValue(qreal(value) * 100 / m_parentValueOp());
58
59 m_blockUpdates = false;
60}
void setValue(qreal newValue)

References m_blockUpdates, m_parentValueOp, m_slider, KisDoubleSliderSpinBox::setValue(), and value().

Member Data Documentation

◆ m_blockUpdates

bool SliderAndSpinBoxSync::m_blockUpdates
private

Definition at line 52 of file slider_and_spin_box_sync.h.

◆ m_parentValueOp

IntFunction SliderAndSpinBoxSync::m_parentValueOp
private

Definition at line 50 of file slider_and_spin_box_sync.h.

◆ m_slider

KisDoubleSliderSpinBox* SliderAndSpinBoxSync::m_slider
private

Definition at line 48 of file slider_and_spin_box_sync.h.

◆ m_spinBox

QSpinBox* SliderAndSpinBoxSync::m_spinBox
private

Definition at line 49 of file slider_and_spin_box_sync.h.


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