Krita Source Code Documentation
Loading...
Searching...
No Matches
KisSelectionPropertySlider.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2018 Jouni Pentikäinen <joupent@gmail.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
9
11
13
15{
16 KisSignalCompressor *signalCompressor {nullptr};
19
21 : signalCompressor(new KisSignalCompressor(100, KisSignalCompressor::FIRST_ACTIVE, q))
22 {}
23};
24
27 , m_d(new Private(this))
28{
29 connect(m_d->signalCompressor, SIGNAL(timeout()), SLOT(slotCompressedUpdate()));
30}
31
34
35void KisSelectionPropertySliderBase::setTextTemplates(const QString &normalTemplate, const QString &mixedTemplate)
36{
37 m_d->normalTemplate = normalTemplate;
38 m_d->mixedTemplate = mixedTemplate;
39 KisSpinBoxI18nHelper::setText(static_cast<QDoubleSpinBox *>(this), normalTemplate);
40}
41
42void KisSelectionPropertySliderBase::setInternalValue(qreal _value, bool blockUpdateSignal)
43{
44 static const qreal eps = 1e-3;
45
46 if (!hasSelection()) return;
47
48 setPrivateValue(_value);
49
50 const qreal newValue = value();
51 const qreal commonValue = getCommonValue();
52 if (qAbs(commonValue - newValue) < eps) {
53 return;
54 }
55
56 if(!blockUpdateSignal) {
57 m_d->signalCompressor->start();
58 }
59}
60
62{
63 emit(valueChanged(value()));
64}
65
66void KisSelectionPropertySliderBase::setSelectionValue(qreal commonValue, bool mixed)
67{
68 if (mixed) {
69 setInternalValue(0.0, true); // BUG:409131
70 KisSpinBoxI18nHelper::setText(static_cast<QDoubleSpinBox *>(this), m_d->mixedTemplate);
71 } else {
72 setValue(commonValue);
73 KisSpinBoxI18nHelper::setText(static_cast<QDoubleSpinBox *>(this), m_d->normalTemplate);
74 }
75}
76
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)
void setPrivateValue(qreal newValue)
const QScopedPointer< Private > m_d
virtual bool hasSelection() const =0
virtual qreal getCommonValue() const =0
void setTextTemplates(const QString &normalTemplate, const QString &mixedTemplate)
void setInternalValue(qreal value, bool blockUpdateSignal) override
void setSelectionValue(qreal commonValue, bool mixed)
KisShapePropertySlider(QWidget *parent=nullptr)
const qreal eps
void setText(QSpinBox *spinBox, const QStringView textTemplate)