11#ifndef KISSLIDERSPINBOXPRIVATE_H
12#define KISSLIDERSPINBOXPRIVATE_H
16#include <QStyleOptionSpinBox>
19#include <QApplication>
24#include <QVariantAnimation>
31#include <ksharedconfig.h>
32#include <kconfiggroup.h>
35#include <klocalizedstring.h>
42template <
typename SpinBoxTypeTP,
typename BaseSpinBoxTypeTP>
48 using ValueType =
decltype(std::declval<SpinBoxType>().value());
54 ValueUpdateMode_UseValueBeforeEditing
59 , m_lineEdit(m_q->lineEdit())
62 m_q->installEventFilter(
this);
64 m_lineEdit->setReadOnly(
true);
65 m_lineEdit->setAlignment(Qt::AlignCenter);
66 m_lineEdit->setAutoFillBackground(
false);
68 m_lineEdit->installEventFilter(
this);
70 m_widgetRangeToggle =
new QWidget(m_q);
71 m_widgetRangeToggle->hide();
72 m_widgetRangeToggle->installEventFilter(
this);
74 m_sliderAnimation.setStartValue(0.0);
75 m_sliderAnimation.setEndValue(1.0);
76 m_sliderAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InOutCubic));
77 connect(&m_sliderAnimation, &QVariantAnimation::valueChanged, m_lineEdit, QOverload<>::of(&QLineEdit::update));
78 connect(&m_sliderAnimation, &QVariantAnimation::valueChanged, m_widgetRangeToggle, QOverload<>::of(&QLineEdit::update));
80 m_rangeToggleHoverAnimation.setStartValue(0.0);
81 m_rangeToggleHoverAnimation.setEndValue(1.0);
82 m_rangeToggleHoverAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InOutCubic));
83 connect(&m_rangeToggleHoverAnimation, &QVariantAnimation::valueChanged, m_widgetRangeToggle, QOverload<>::of(&QLineEdit::update));
88 if (isEditModeActive()) {
92 m_valueBeforeEditing = m_q->value();
93 m_lineEdit->setReadOnly(
false);
95 m_lineEdit->setFocus(Qt::OtherFocusReason);
101 if (!isEditModeActive()) {
104 if (updateMode == ValueUpdateMode_UseLastValidValue) {
105 setValue(m_q->value(),
false,
false,
true);
106 }
else if (updateMode == ValueUpdateMode_UseValueBeforeEditing) {
107 setValue(m_valueBeforeEditing,
false,
false,
true);
110 QPalette pal = m_lineEdit->palette();
111 pal.setBrush(QPalette::Text, m_q->palette().text());
112 m_lineEdit->setPalette(pal);
113 m_rightClickCounter = 0;
114 m_lineEdit->setReadOnly(
true);
116 m_lineEdit->update();
122 return !m_lineEdit->isReadOnly();
129 const QRectF
rect(m_lineEdit->rect());
130 const QPointF center(
132 m_lastMousePressPosition.x() + (m_useRelativeDragging ? m_relativeDraggingOffset : 0)
136 const bool useSoftRange = isSoftRangeValid() && (m_softRangeViewMode == SoftRangeViewMode_AlwaysShowSoftRange || m_isSoftRangeActive);
137 const double minimum =
static_cast<double>(useSoftRange ? m_softMinimum : m_q->minimum());
138 const double maximum =
static_cast<double>(useSoftRange ? m_softMaximum : m_q->maximum());
139 const double rangeSize = maximum - minimum;
144 const double distanceY =
147 std::abs(
static_cast<double>(
p.y()) - center.y()) - center.y() - constantDraggingMargin
151 if (modifiers & Qt::ShiftModifier) {
156 scale = (
rect.width() + 2.0 * distanceY * 10.0) /
rect.width() + 4.0;
159 scale = (
rect.width() + 2.0 * distanceY * 2.0) /
rect.width();
163 const double scaledRectLeft = (0.0 - center.x()) * scale + center.x();
164 const double scaledRectRight = (
rect.width() - center.x()) * scale + center.x();
166 const double scaledRectWidth = scaledRectRight - scaledRectLeft;
167 const double posX =
static_cast<double>(
p.x()) - scaledRectLeft;
169 const double normalizedPosX = qBound(0.0, posX / scaledRectWidth, 1.0);
171 const double normalizedValue = std::pow(normalizedPosX, m_exponentRatio);
172 double value = normalizedValue * rangeSize + minimum;
174 if (modifiers & Qt::ControlModifier) {
175 value = std::round(
value / m_fastSliderStep) * m_fastSliderStep;
178 if (std::is_same<ValueType, double>::value) {
188 if (isSoftRangeValid()) {
189 if (m_softRangeViewMode == SoftRangeViewMode_ShowBothRanges) {
190 if (m_isSoftRangeActive) {
194 min = m_q->minimum();
195 max = m_q->maximum();
202 min = m_q->minimum();
203 max = m_q->maximum();
205 return QPoint(
static_cast<int>(qRound(computeSliderWidth(min, max,
value))), 0);
210 bool blockSignals =
false,
211 bool emitSignalsEvenWhenValueNotChanged =
false,
212 bool overwriteExpression =
false)
215 m_q->blockSignals(
true);
216 m_q->BaseSpinBoxType::setValue(newValue, overwriteExpression);
217 m_q->blockSignals(
false);
220 m_q->BaseSpinBoxType::setValue(newValue, overwriteExpression);
221 if (
v == m_q->value() && emitSignalsEvenWhenValueNotChanged) {
225 if (!m_q->hasFocus()) {
226 endEditing(ValueUpdateMode_NoChange);
232 if (isSoftRangeValid() && m_softRangeViewMode == SoftRangeViewMode_ShowBothRanges) {
233 if (m_isSoftRangeActive) {
234 makeSoftRangeActive();
236 makeHardRangeActive();
238 updateWidgetRangeToggleTooltip();
239 m_widgetRangeToggle->show();
241 m_sliderAnimation.stop();
242 m_widgetRangeToggle->hide();
244 qResizeEvent(
nullptr);
247 template <typename U = SpinBoxTypeTP, typename = typename std::enable_if<std::is_same<ValueType, int>::value, U>::type>
248 void setRange(
int newMinimum,
int newMaximum,
bool computeNewFastSliderStep)
250 m_q->BaseSpinBoxType::setRange(newMinimum, newMaximum);
251 if (computeNewFastSliderStep) {
253 m_fastSliderStep = (m_q->maximum() - m_q->minimum()) / 20;
254 if (m_fastSliderStep == 0) {
255 m_fastSliderStep = 1;
258 m_softMinimum = qBound(m_q->minimum(), m_softMinimum, m_q->maximum());
259 m_softMaximum = qBound(m_q->minimum(), m_softMaximum, m_q->maximum());
264 template <typename U = SpinBoxTypeTP, typename = typename std::enable_if<std::is_same<ValueType, double>::value, U>::type>
265 void setRange(
double newMinimum,
double newMaximum,
int newNumberOfDecimals,
bool computeNewFastSliderStep)
267 m_q->setDecimals(newNumberOfDecimals);
268 m_q->BaseSpinBoxType::setRange(newMinimum, newMaximum);
269 if (computeNewFastSliderStep) {
271 const double rangeSize = m_q->maximum() - m_q->minimum();
272 if (rangeSize >= 2.0 || newNumberOfDecimals <= 0) {
273 m_fastSliderStep = 1.0;
274 }
else if (newNumberOfDecimals == 1) {
275 m_fastSliderStep = rangeSize / 10.0;
277 m_fastSliderStep = rangeSize / 20.0;
280 m_softMinimum = qBound(m_q->minimum(), m_softMinimum, m_q->maximum());
281 m_softMaximum = qBound(m_q->minimum(), m_softMaximum, m_q->maximum());
283 m_lineEdit->update();
288 m_blockUpdateSignalOnDrag = newBlockUpdateSignalOnDrag;
293 m_fastSliderStep = newFastSliderStep;
300 if ((newSoftMinimum != newSoftMaximum) &&
301 (newSoftMinimum > newSoftMaximum || newSoftMinimum < m_q->minimum() || newSoftMaximum > m_q->maximum())) {
304 m_softMinimum = newSoftMinimum;
305 m_softMaximum = newSoftMaximum;
307 m_lineEdit->update();
312 return m_softMaximum > m_softMinimum;
317 return m_fastSliderStep;
322 return m_softMinimum;
327 return m_softMaximum;
337 m_sliderAnimation.stop();
338 m_isSoftRangeActive =
true;
340 const int animationDuration =
341 static_cast<int>(std::round(m_sliderAnimation.currentValue().toReal() * fullAnimationDuration));
342 m_sliderAnimation.setStartValue(m_sliderAnimation.currentValue());
343 m_sliderAnimation.setEndValue(0.0);
344 m_sliderAnimation.setDuration(animationDuration);
345 m_sliderAnimation.start();
350 m_sliderAnimation.stop();
351 m_isSoftRangeActive =
false;
353 const int animationDuration =
354 static_cast<int>(std::round((1.0 - m_sliderAnimation.currentValue().toReal()) * fullAnimationDuration));
355 m_sliderAnimation.setStartValue(m_sliderAnimation.currentValue());
356 m_sliderAnimation.setEndValue(1.0);
357 m_sliderAnimation.setDuration(animationDuration);
358 m_sliderAnimation.start();
363 m_exponentRatio = newExponentRatio;
364 m_lineEdit->update();
369 m_widgetRangeToggle->setToolTip(
371 "@info:tooltip toggle between soft and hard range in the slider spin box",
372 "Toggle between full range and subrange.\nFull range: [%1, %2]\nSubrange: [%3, %4]",
373 QString::number(m_q->minimum()),
374 QString::number(m_q->maximum()),
375 QString::number(m_softMinimum),
376 QString::number(m_softMaximum)
383 QSize hint = m_q->BaseSpinBoxType::sizeHint();
385 (isSoftRangeValid() && m_softRangeViewMode == SoftRangeViewMode_ShowBothRanges)
386 ? QSize(hint.width() + widthOfRangeModeToggle, hint.height())
392 QSize hint = m_q->BaseSpinBoxType::minimumSizeHint();
394 (isSoftRangeValid() && m_softRangeViewMode == SoftRangeViewMode_ShowBothRanges)
395 ? QSize(hint.width() + widthOfRangeModeToggle, hint.height())
401#if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
402 Q_EMIT m_q->textChanged(m_q->text());
404 Q_EMIT m_q->valueChanged(m_q->text());
406 Q_EMIT m_q->valueChanged(m_q->value());
415 QStyleOptionSpinBox spinBoxOptions;
416 m_q->initStyleOption(&spinBoxOptions);
417 QRect
rect = m_q->style()->subControlRect(QStyle::CC_SpinBox, &spinBoxOptions, QStyle::SC_SpinBoxEditField);
421 if (style ==
"breeze") {
422 rect.adjust(-4, -4, 0, 4);
423 }
else if (style ==
"fusion") {
424 rect.adjust(-2, -1, 2, 1);
427 if (isSoftRangeValid() && m_softRangeViewMode == SoftRangeViewMode_ShowBothRanges) {
428 m_lineEdit->setGeometry(
rect.adjusted(0, 0, -widthOfRangeModeToggle, 0));
429 m_widgetRangeToggle->setGeometry(
rect.adjusted(
rect.width() - widthOfRangeModeToggle, 0, 0, 0));
431 m_lineEdit->setGeometry(
rect);
441 if (m_focusLostDueToMenu) {
442 m_focusLostDueToMenu =
false;
444 if (m_q->isLastValid()) {
466 if (!isEditModeActive()) {
467 qApp->postEvent(m_q,
new QKeyEvent(QEvent::KeyPress, Qt::Key_Up, e->modifiers()));
472 if (!isEditModeActive()) {
473 qApp->postEvent(m_q,
new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, e->modifiers()));
482 if (!e->isAutoRepeat()) {
483 if (!isEditModeActive()) {
486 if (m_q->isLastValid()) {
497 if (isEditModeActive()) {
498 endEditing(ValueUpdateMode_UseValueBeforeEditing);
507 if (!isEditModeActive() && e->key() >= Qt::Key_0 && e->key() <= Qt::Key_9) {
509 qApp->postEvent(m_q,
new QKeyEvent(QEvent::KeyPress, e->key(), e->modifiers(), e->text(), e->isAutoRepeat()));
523 if (!isEditModeActive() && m_lineEdit->rect().contains(e->pos())) {
530 if (isEditModeActive()) {
531 menu = m_lineEdit->createStandardContextMenu();
532 m_focusLostDueToMenu =
true;
540 QAction *selectAllAction =
nullptr;
541 if (isEditModeActive()) {
542 selectAllAction =
new QAction(i18nc(
"Menu action to select all text in the slider spin box",
"&Select All"), menu);
543#if QT_CONFIG(shortcut)
544 selectAllAction->setShortcut(QKeySequence::SelectAll);
546 menu->removeAction(menu->actions().last());
547 menu->addAction(selectAllAction);
548 menu->addSeparator();
551 const uint stepEnabled = m_q->stepEnabled();
552 QAction *stepUpAction = menu->addAction(i18nc(
"Menu action to step up in the slider spin box",
"&Step up"));
553 stepUpAction->setEnabled(stepEnabled & SpinBoxType::StepUpEnabled);
554 QAction *stepDown = menu->addAction(i18nc(
"Menu action to step down in the slider spin box",
"Step &down"));
555 stepDown->setEnabled(stepEnabled & SpinBoxType::StepDownEnabled);
556 menu->addSeparator();
561 (e->reason() == QContextMenuEvent::Mouse)
563 : m_q->mapToGlobal(QPoint(e->pos().x(), 0)) + QPoint(m_q->width() / 2, m_q->height() / 2);
564 const QAction *action = menu->exec(pos);
565 delete static_cast<QMenu *
>(menu);
566 if (spinbox && action) {
567 if (action == stepUpAction) {
569 }
else if (action == stepDown) {
571 }
else if (action == selectAllAction) {
583 painter.setBrush(brush);
584 painter.setPen(Qt::NoPen);
586 painter.drawRoundedRect(
rect, 1, 1);
588 painter.drawRoundedRect(
rect, 0, 0);
593 void paintSliderText(QPainter &painter,
const QString &text,
const QRectF &
rect,
const QRectF &clipRect,
const QColor &color,
const QTextOption &textOption)
595 painter.setBrush(Qt::NoBrush);
596 painter.setPen(color);
597 painter.setClipping(
true);
598 painter.setClipRect(clipRect);
599 painter.drawText(
rect, text, textOption);
600 painter.setClipping(
false);
605 QTextOption textOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter);
606 textOption.setWrapMode(QTextOption::NoWrap);
608 paintSliderText(painter, text,
rect,
rect.adjusted(sliderRect.width(), 0, 0, 0), m_lineEdit->palette().text().color(), textOption);
610 paintSliderText(painter, text,
rect, sliderRect, m_lineEdit->palette().highlightedText().color(), textOption);
613 void paintSlider(QPainter &painter,
const QString &text,
double slider01Width,
double slider02Width = -1.0)
615 const QRectF
rect = m_lineEdit->rect();
616 const QColor highlightColor = m_q->palette().highlight().color();
617 if (slider02Width < 0.0) {
618 const QRectF sliderRect =
rect.adjusted(0, 0, -(
rect.width() - slider01Width), 0);
619 paintSliderRect(painter, sliderRect, highlightColor);
620 if (!text.isNull()) {
621 paintGenericSliderText(painter, text,
rect, sliderRect);
624 static constexpr double heightOfCollapsedSliderPlusSpace = heightOfCollapsedSlider + heightOfSpaceBetweenSliders;
625 const double heightBetween =
rect.height() - 2.0 * heightOfCollapsedSlider - heightOfSpaceBetweenSliders;
626 const double animationPos = m_sliderAnimation.currentValue().toReal();
627 const double a = heightOfCollapsedSliderPlusSpace;
628 const double b = heightOfCollapsedSliderPlusSpace + heightBetween;
630 QTextOption textOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter);
631 textOption.setWrapMode(QTextOption::NoWrap);
632 paintSliderText(painter, text,
rect,
rect, m_lineEdit->palette().text().color(), textOption);
638 rect.adjusted(0, 0, -(
rect.width() - slider02Width), softSliderAdjustment),
645 rect.adjusted(0, hardSliderAdjustment, -(
rect.width() - slider01Width), 0),
651 rect.adjusted(0, 0, -(
rect.width() - slider02Width), softSliderAdjustment),
652 m_lineEdit->palette().highlightedText().color(),
657 rect.adjusted(0, hardSliderAdjustment, -(
rect.width() - slider01Width), 0),
658 m_lineEdit->palette().highlightedText().color(),
666 const double rangeSize = max - min;
667 const double localPosition =
value - min;
668 const double normalizedValue = std::pow(localPosition / rangeSize, 1.0 / m_exponentRatio);
669 const double width =
static_cast<double>(m_lineEdit->width());
670 return qBound(0.0, std::round(normalizedValue * width), width);
675 QPainter painter(m_lineEdit);
676 painter.setRenderHint(QPainter::Antialiasing,
true);
678 const double value = m_q->value();
683 const double hardSliderWidth = computeSliderWidth(
static_cast<double>(m_q->minimum()),
static_cast<double>(m_q->maximum()),
value);
684 const double softSliderWidth = computeSliderWidth(m_softMinimum, m_softMaximum,
value);
685 if (!isEditModeActive()) {
686 QString text = m_q->text();
687 if (isSoftRangeValid()) {
688 if (m_softRangeViewMode == SoftRangeViewMode_AlwaysShowSoftRange) {
689 paintSlider(painter, text, softSliderWidth);
691 paintSlider(painter, text, hardSliderWidth, softSliderWidth);
695 paintSlider(painter, text, hardSliderWidth);
699 if (isSoftRangeValid()) {
700 if (m_softRangeViewMode == SoftRangeViewMode_AlwaysShowSoftRange) {
701 paintSlider(painter, QString(), softSliderWidth);
703 paintSlider(painter, QString(), hardSliderWidth, softSliderWidth);
706 paintSlider(painter, QString(), hardSliderWidth);
709 QColor color = m_q->palette().base().color();
711 paintSliderRect(painter, m_lineEdit->rect(), color);
715 return !isEditModeActive();
720 if (!m_q->isEnabled()) {
723 if (!isEditModeActive()) {
724 if (e->button() == Qt::LeftButton) {
725 m_lastMousePressPosition = e->pos();
726 const QPoint currentValuePosition = pointForValue(m_q->value());
727 m_relativeDraggingOffset = currentValuePosition.x() - e->x();
728 m_useRelativeDragging = (e->modifiers() & Qt::ShiftModifier);
730 QTimer::singleShot(0, &m_startEditingSignalProxy, SLOT(start()));
732 lineEditMouseMoveEvent(e);
742 if (!m_q->isEnabled()) {
745 if (!isEditModeActive()) {
748 if (e->button() == Qt::RightButton) {
753 QTimer::singleShot(0, &m_startEditingSignalProxy, SLOT(start()));
757 }
else if (e->button() == Qt::LeftButton) {
758 if (m_blockUpdateSignalOnDrag) {
759 const QPoint
p(m_useRelativeDragging ? e->pos().x() + m_relativeDraggingOffset : e->pos().x(),
761 setValue(valueForPoint(
p, e->modifiers()),
false,
true);
764 setValue(valueForPoint(e->pos(), e->modifiers()),
false,
true);
768 m_isDragging =
false;
769 Q_EMIT m_q->draggingFinished();
778 if (!m_q->isEnabled()) {
781 if (!isEditModeActive()) {
782 if (e->buttons() & Qt::LeftButton) {
786 const QPoint
p(m_useRelativeDragging ? e->pos().x() + m_relativeDraggingOffset : e->pos().x(),
788 setValue(valueForPoint(
p, e->modifiers()), m_blockUpdateSignalOnDrag);
797 QPainter painter(m_widgetRangeToggle);
798 painter.setRenderHint(QPainter::Antialiasing,
true);
800 const double width =
static_cast<double>(m_widgetRangeToggle->width());
801 const double height =
static_cast<double>(m_widgetRangeToggle->height());
802 constexpr double marginX = 4.0;
803 const double toggleWidth = width - 2.0 * marginX;
804 const double centerX = width * 0.5;
805 const double centerY = height * 0.5;
806 const double bigRadius = centerX - std::floor(centerX - (toggleWidth * 0.5)) + 0.5;
807 const double smallRadius = bigRadius * 0.5;
808 const double sliderAnimationPos = m_sliderAnimation.currentValue().toReal();
809 const double radius = smallRadius + sliderAnimationPos * (bigRadius - smallRadius);
811 const double rangeToggleHoverAnimationPos = m_rangeToggleHoverAnimation.currentValue().toReal();
812 const QColor baseColor = m_q->palette().base().color();
813 const QColor textColor = m_q->palette().text().color();
816 painter.setPen(color);
817 painter.setBrush(Qt::NoBrush);
818 painter.drawEllipse(QPointF(centerX, centerY), bigRadius, bigRadius);
820 painter.setPen(Qt::NoPen);
821 painter.setBrush(color);
822 painter.drawEllipse(QPointF(centerX, centerY), radius, radius);
828 if (!m_q->isEnabled()) {
831 if (e->button() == Qt::LeftButton) {
832 if (!m_isSoftRangeActive) {
833 makeSoftRangeActive();
835 makeHardRangeActive();
844 m_rangeToggleHoverAnimation.stop();
846 const int animationDuration =
847 static_cast<int>(std::round(m_rangeToggleHoverAnimation.currentValue().toReal() * fullAnimationDuration));
848 m_rangeToggleHoverAnimation.setStartValue(m_rangeToggleHoverAnimation.currentValue());
849 m_rangeToggleHoverAnimation.setEndValue(1.0);
850 m_rangeToggleHoverAnimation.setDuration(animationDuration);
851 m_rangeToggleHoverAnimation.start();
857 m_rangeToggleHoverAnimation.stop();
859 const int animationDuration =
860 static_cast<int>(std::round(m_rangeToggleHoverAnimation.currentValue().toReal() * fullAnimationDuration));
861 m_rangeToggleHoverAnimation.setStartValue(m_rangeToggleHoverAnimation.currentValue());
862 m_rangeToggleHoverAnimation.setEndValue(0.0);
863 m_rangeToggleHoverAnimation.setDuration(animationDuration);
864 m_rangeToggleHoverAnimation.start();
875 case QEvent::Resize :
return qResizeEvent(
static_cast<QResizeEvent*
>(e));
876 case QEvent::FocusOut :
return qFocusOutEvent(
static_cast<QFocusEvent*
>(e));
877 case QEvent::MouseButtonPress :
return qMousePressEvent(
static_cast<QMouseEvent*
>(e));
878 case QEvent::KeyPress :
return qKeyPressEvent(
static_cast<QKeyEvent*
>(e));
879 case QEvent::ContextMenu :
return qContextMenuEvent(
static_cast<QContextMenuEvent*
>(e));
882 }
else if (o == m_lineEdit) {
884 case QEvent::Paint :
return lineEditPaintEvent(
static_cast<QPaintEvent*
>(e));
885 case QEvent::MouseButtonPress :
return lineEditMousePressEvent(
static_cast<QMouseEvent*
>(e),
false);
886 case QEvent::MouseButtonDblClick :
return lineEditMousePressEvent(
static_cast<QMouseEvent*
>(e),
true);
887 case QEvent::MouseButtonRelease :
return lineEditMouseReleaseEvent(
static_cast<QMouseEvent*
>(e));
888 case QEvent::MouseMove :
return lineEditMouseMoveEvent(
static_cast<QMouseEvent*
>(e));
891 }
else if (o == m_widgetRangeToggle) {
893 case QEvent::Paint :
return widgetRangeTogglePaintEvent(
static_cast<QPaintEvent*
>(e));
894 case QEvent::MouseButtonRelease:
return widgetRangeToggleMouseReleaseEvent(
static_cast<QMouseEvent*
>(e));
895 case QEvent::Enter:
return widgetRangeToggleEnterEvent(e);
896 case QEvent::Leave:
return widgetRangeToggleLeaveEvent(e);
906 static constexpr double constantDraggingMargin{32.0};
908 static constexpr double heightOfCollapsedSlider{3.0};
910 static constexpr double heightOfSpaceBetweenSliders{0.0};
912 static constexpr double widthOfRangeModeToggle{16.0};
914 static constexpr double fullAnimationDuration{200.0};
917 QLineEdit *m_lineEdit {
nullptr};
918 QWidget *m_widgetRangeToggle {
nullptr};
921 double m_exponentRatio {1.0};
922 bool m_blockUpdateSignalOnDrag {
false};
925 bool m_isDragging {
false};
926 bool m_useRelativeDragging {
false};
927 int m_relativeDraggingOffset {0};
929 int m_rightClickCounter {0};
930 bool m_focusLostDueToMenu {
false};
931 bool m_isSoftRangeActive {
true};
939 SoftRangeViewMode_ShowBothRanges
940 } m_softRangeViewMode{SoftRangeViewMode_ShowBothRanges};
float value(const T *src, size_t ch)
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
static QCursor ibeamCursor()
static QCursor splitHCursor()
void setRange(int newMinimum, int newMaximum, bool computeNewFastSliderStep)
bool lineEditMousePressEvent(QMouseEvent *e, bool edit)
void paintSliderText(QPainter &painter, const QString &text, const QRectF &rect, const QRectF &clipRect, const QColor &color, const QTextOption &textOption)
QVariantAnimation m_sliderAnimation
QSize minimumSizeHint() const
QVariantAnimation m_rangeToggleHoverAnimation
bool lineEditMouseMoveEvent(QMouseEvent *e)
void paintGenericSliderText(QPainter &painter, const QString &text, const QRectF &rect, const QRectF &sliderRect)
bool qMousePressEvent(QMouseEvent *)
ValueType fastSliderStep() const
QPoint pointForValue(ValueType value) const
bool eventFilter(QObject *o, QEvent *e) override
bool widgetRangeTogglePaintEvent(QPaintEvent *)
decltype(std::declval< SpinBoxType >().value()) ValueType
void setValue(ValueType newValue, bool blockSignals=false, bool emitSignalsEvenWhenValueNotChanged=false, bool overwriteExpression=false)
void updateWidgetRangeToggleTooltip()
bool qContextMenuEvent(QContextMenuEvent *e)
bool widgetRangeToggleMouseReleaseEvent(QMouseEvent *e)
bool widgetRangeToggleLeaveEvent(QEvent *)
BaseSpinBoxTypeTP BaseSpinBoxType
void setSoftRange(ValueType newSoftMinimum, ValueType newSoftMaximum)
ValueType valueForPoint(const QPoint &p, Qt::KeyboardModifiers modifiers) const
bool qFocusOutEvent(QFocusEvent *)
void makeSoftRangeActive()
QPoint m_lastMousePressPosition
bool lineEditMouseReleaseEvent(QMouseEvent *e)
KisSliderSpinBoxPrivate(SpinBoxType *q)
void endEditing(ValueUpdateMode updateMode=ValueUpdateMode_UseLastValidValue)
bool lineEditPaintEvent(QPaintEvent *)
void makeHardRangeActive()
void setFastSliderStep(ValueType newFastSliderStep)
SpinBoxTypeTP SpinBoxType
bool qResizeEvent(QResizeEvent *)
double computeSliderWidth(double min, double max, double value) const
void paintSlider(QPainter &painter, const QString &text, double slider01Width, double slider02Width=-1.0)
void setExponentRatio(double newExponentRatio)
void paintSliderRect(QPainter &painter, const QRectF &rect, const QBrush &brush)
@ SoftRangeViewMode_AlwaysShowSoftRange
bool isSoftRangeValid() const
bool isEditModeActive() const
bool qKeyPressEvent(QKeyEvent *e)
bool widgetRangeToggleEnterEvent(QEvent *)
@ ValueUpdateMode_NoChange
@ ValueUpdateMode_UseLastValidValue
ValueType softMaximum() const
void setRange(double newMinimum, double newMaximum, int newNumberOfDecimals, bool computeNewFastSliderStep)
SignalToFunctionProxy m_startEditingSignalProxy
void setBlockUpdateSignalOnDrag(bool newBlockUpdateSignalOnDrag)
ValueType softMinimum() const
constexpr const char * currentUnderlyingStyleNameProperty
Point lerp(const Point &pt1, const Point &pt2, qreal t)
QColor blendColors(const QColor &c1, const QColor &c2, qreal r1)