Krita Source Code Documentation
Loading...
Searching...
No Matches
slider_and_spin_box_sync.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2015 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
9#include <QSpinBox>
10#include "kis_slider_spin_box.h"
11
12#include "kis_debug.h"
13#include "kis_signals_blocker.h"
14
15
17 QSpinBox *spinBox,
18 IntFunction parentValueOp)
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}
27
32
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}
42
44 if (m_blockUpdates) return;
45 m_blockUpdates = true;
46
47 m_spinBox->setValue(value * m_parentValueOp() / 100);
48
49 m_blockUpdates = false;
50}
51
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}
float value(const T *src, size_t ch)
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
This class is a spinbox in which you can click and drag to set the value. A slider like bar is displa...
void setValue(qreal newValue)
SliderAndSpinBoxSync(KisDoubleSliderSpinBox *slider, QSpinBox *spinBox, IntFunction parentValueOp)
KisDoubleSliderSpinBox * m_slider
std::function< int()> IntFunction