11#ifndef KISSLIDERSPINBOXPRIVATE_H
12#define KISSLIDERSPINBOXPRIVATE_H
16#include <QStyleOptionSpinBox>
19#include <QInputMethodQueryEvent>
20#include <QApplication>
25#include <QVariantAnimation>
32#include <ksharedconfig.h>
33#include <kconfiggroup.h>
36#include <klocalizedstring.h>
43template <
typename SpinBoxTypeTP,
typename BaseSpinBoxTypeTP>
49 using ValueType =
decltype(std::declval<SpinBoxType>().value());
55 ValueUpdateMode_UseValueBeforeEditing
60 , m_lineEdit(m_q->lineEdit())
63 m_q->installEventFilter(
this);
65 m_lineEdit->setReadOnly(
true);
66 m_lineEdit->setAlignment(Qt::AlignCenter);
67 m_lineEdit->setAutoFillBackground(
false);
69 m_lineEdit->installEventFilter(
this);
71 m_widgetRangeToggle =
new QWidget(m_q);
72 m_widgetRangeToggle->hide();
73 m_widgetRangeToggle->installEventFilter(
this);
75 m_sliderAnimation.setStartValue(0.0);
76 m_sliderAnimation.setEndValue(1.0);
77 m_sliderAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InOutCubic));
78 connect(&m_sliderAnimation, &QVariantAnimation::valueChanged, m_lineEdit, QOverload<>::of(&QLineEdit::update));
79 connect(&m_sliderAnimation, &QVariantAnimation::valueChanged, m_widgetRangeToggle, QOverload<>::of(&QLineEdit::update));
81 m_rangeToggleHoverAnimation.setStartValue(0.0);
82 m_rangeToggleHoverAnimation.setEndValue(1.0);
83 m_rangeToggleHoverAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InOutCubic));
84 connect(&m_rangeToggleHoverAnimation, &QVariantAnimation::valueChanged, m_widgetRangeToggle, QOverload<>::of(&QLineEdit::update));
89 if (isEditModeActive()) {
93 m_valueBeforeEditing = m_q->value();
94 m_lineEdit->setReadOnly(
false);
96 m_lineEdit->setFocus(Qt::OtherFocusReason);
102 if (!isEditModeActive()) {
105 if (updateMode == ValueUpdateMode_UseLastValidValue) {
106 setValue(m_q->value(),
false,
false,
true);
107 }
else if (updateMode == ValueUpdateMode_UseValueBeforeEditing) {
108 setValue(m_valueBeforeEditing,
false,
false,
true);
111 QPalette pal = m_lineEdit->palette();
112 pal.setBrush(QPalette::Text, m_q->palette().text());
113 m_lineEdit->setPalette(pal);
114 m_rightClickCounter = 0;
115 m_lineEdit->setReadOnly(
true);
117 m_lineEdit->update();
123 return !m_lineEdit->isReadOnly();
130 const QRectF
rect(m_lineEdit->rect());
131 const QPointF center(
133 m_lastMousePressPosition.x() + (m_useRelativeDragging ? m_relativeDraggingOffset : 0)
137 const bool useSoftRange = isSoftRangeValid() && (m_softRangeViewMode == SoftRangeViewMode_AlwaysShowSoftRange || m_isSoftRangeActive);
138 const double minimum =
static_cast<double>(useSoftRange ? m_softMinimum : m_q->minimum());
139 const double maximum =
static_cast<double>(useSoftRange ? m_softMaximum : m_q->maximum());
140 const double rangeSize = maximum - minimum;
145 const double distanceY =
148 std::abs(
static_cast<double>(
p.y()) - center.y()) - center.y() - constantDraggingMargin
152 if (modifiers & Qt::ShiftModifier) {
157 scale = (
rect.width() + 2.0 * distanceY * 10.0) /
rect.width() + 4.0;
160 scale = (
rect.width() + 2.0 * distanceY * 2.0) /
rect.width();
164 const double scaledRectLeft = (0.0 - center.x()) * scale + center.x();
165 const double scaledRectRight = (
rect.width() - center.x()) * scale + center.x();
167 const double scaledRectWidth = scaledRectRight - scaledRectLeft;
168 const double posX =
static_cast<double>(
p.x()) - scaledRectLeft;
170 const double normalizedPosX = qBound(0.0, posX / scaledRectWidth, 1.0);
172 const double normalizedValue = std::pow(normalizedPosX, m_exponentRatio);
173 double value = normalizedValue * rangeSize + minimum;
175 if (modifiers & Qt::ControlModifier) {
176 value = std::round(
value / m_fastSliderStep) * m_fastSliderStep;
179 if (std::is_same<ValueType, double>::value) {
189 if (isSoftRangeValid()) {
190 if (m_softRangeViewMode == SoftRangeViewMode_ShowBothRanges) {
191 if (m_isSoftRangeActive) {
195 min = m_q->minimum();
196 max = m_q->maximum();
203 min = m_q->minimum();
204 max = m_q->maximum();
206 return QPoint(
static_cast<int>(qRound(computeSliderWidth(min, max,
value))), 0);
211 bool blockSignals =
false,
212 bool emitSignalsEvenWhenValueNotChanged =
false,
213 bool overwriteExpression =
false)
216 m_q->blockSignals(
true);
217 m_q->BaseSpinBoxType::setValue(newValue, overwriteExpression);
218 m_q->blockSignals(
false);
221 m_q->BaseSpinBoxType::setValue(newValue, overwriteExpression);
222 if (
v == m_q->value() && emitSignalsEvenWhenValueNotChanged) {
226 if (!m_q->hasFocus()) {
227 endEditing(ValueUpdateMode_NoChange);
233 if (isSoftRangeValid() && m_softRangeViewMode == SoftRangeViewMode_ShowBothRanges) {
234 if (m_isSoftRangeActive) {
235 makeSoftRangeActive();
237 makeHardRangeActive();
239 updateWidgetRangeToggleTooltip();
240 m_widgetRangeToggle->show();
242 m_sliderAnimation.stop();
243 m_widgetRangeToggle->hide();
245 qResizeEvent(
nullptr);
248 template <typename U = SpinBoxTypeTP, typename = typename std::enable_if<std::is_same<ValueType, int>::value, U>::type>
249 void setRange(
int newMinimum,
int newMaximum,
bool computeNewFastSliderStep)
251 m_q->BaseSpinBoxType::setRange(newMinimum, newMaximum);
252 if (computeNewFastSliderStep) {
254 m_fastSliderStep = (m_q->maximum() - m_q->minimum()) / 20;
255 if (m_fastSliderStep == 0) {
256 m_fastSliderStep = 1;
259 m_softMinimum = qBound(m_q->minimum(), m_softMinimum, m_q->maximum());
260 m_softMaximum = qBound(m_q->minimum(), m_softMaximum, m_q->maximum());
265 template <typename U = SpinBoxTypeTP, typename = typename std::enable_if<std::is_same<ValueType, double>::value, U>::type>
266 void setRange(
double newMinimum,
double newMaximum,
int newNumberOfDecimals,
bool computeNewFastSliderStep)
268 m_q->setDecimals(newNumberOfDecimals);
269 m_q->BaseSpinBoxType::setRange(newMinimum, newMaximum);
270 if (computeNewFastSliderStep) {
272 const double rangeSize = m_q->maximum() - m_q->minimum();
273 if (rangeSize >= 2.0 || newNumberOfDecimals <= 0) {
274 m_fastSliderStep = 1.0;
275 }
else if (newNumberOfDecimals == 1) {
276 m_fastSliderStep = rangeSize / 10.0;
278 m_fastSliderStep = rangeSize / 20.0;
281 m_softMinimum = qBound(m_q->minimum(), m_softMinimum, m_q->maximum());
282 m_softMaximum = qBound(m_q->minimum(), m_softMaximum, m_q->maximum());
284 m_lineEdit->update();
289 m_blockUpdateSignalOnDrag = newBlockUpdateSignalOnDrag;
294 m_fastSliderStep = newFastSliderStep;
301 if ((newSoftMinimum != newSoftMaximum) &&
302 (newSoftMinimum > newSoftMaximum || newSoftMinimum < m_q->minimum() || newSoftMaximum > m_q->maximum())) {
305 m_softMinimum = newSoftMinimum;
306 m_softMaximum = newSoftMaximum;
308 m_lineEdit->update();
313 return m_softMaximum > m_softMinimum;
318 return m_fastSliderStep;
323 return m_softMinimum;
328 return m_softMaximum;
338 m_sliderAnimation.stop();
339 m_isSoftRangeActive =
true;
341 const int animationDuration =
342 static_cast<int>(std::round(m_sliderAnimation.currentValue().toReal() * fullAnimationDuration));
343 m_sliderAnimation.setStartValue(m_sliderAnimation.currentValue());
344 m_sliderAnimation.setEndValue(0.0);
345 m_sliderAnimation.setDuration(animationDuration);
346 m_sliderAnimation.start();
351 m_sliderAnimation.stop();
352 m_isSoftRangeActive =
false;
354 const int animationDuration =
355 static_cast<int>(std::round((1.0 - m_sliderAnimation.currentValue().toReal()) * fullAnimationDuration));
356 m_sliderAnimation.setStartValue(m_sliderAnimation.currentValue());
357 m_sliderAnimation.setEndValue(1.0);
358 m_sliderAnimation.setDuration(animationDuration);
359 m_sliderAnimation.start();
364 m_exponentRatio = newExponentRatio;
365 m_lineEdit->update();
370 m_widgetRangeToggle->setToolTip(
372 "@info:tooltip toggle between soft and hard range in the slider spin box",
373 "Toggle between full range and subrange.\nFull range: [%1, %2]\nSubrange: [%3, %4]",
374 QString::number(m_q->minimum()),
375 QString::number(m_q->maximum()),
376 QString::number(m_softMinimum),
377 QString::number(m_softMaximum)
384 QSize hint = m_q->BaseSpinBoxType::sizeHint();
386 (isSoftRangeValid() && m_softRangeViewMode == SoftRangeViewMode_ShowBothRanges)
387 ? QSize(hint.width() + widthOfRangeModeToggle, hint.height())
393 QSize hint = m_q->BaseSpinBoxType::minimumSizeHint();
395 (isSoftRangeValid() && m_softRangeViewMode == SoftRangeViewMode_ShowBothRanges)
396 ? QSize(hint.width() + widthOfRangeModeToggle, hint.height())
402#if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
403 Q_EMIT m_q->textChanged(m_q->text());
405 Q_EMIT m_q->valueChanged(m_q->text());
407 Q_EMIT m_q->valueChanged(m_q->value());
416 QStyleOptionSpinBox spinBoxOptions;
417 m_q->initStyleOption(&spinBoxOptions);
418 QRect
rect = m_q->style()->subControlRect(QStyle::CC_SpinBox, &spinBoxOptions, QStyle::SC_SpinBoxEditField);
422 if (style ==
"breeze") {
423 rect.adjust(-4, -4, 0, 4);
424 }
else if (style ==
"fusion") {
425 rect.adjust(-2, -1, 2, 1);
428 if (isSoftRangeValid() && m_softRangeViewMode == SoftRangeViewMode_ShowBothRanges) {
429 m_lineEdit->setGeometry(
rect.adjusted(0, 0, -widthOfRangeModeToggle, 0));
430 m_widgetRangeToggle->setGeometry(
rect.adjusted(
rect.width() - widthOfRangeModeToggle, 0, 0, 0));
432 m_lineEdit->setGeometry(
rect);
442 if (m_focusLostDueToMenu) {
443 m_focusLostDueToMenu =
false;
445 if (m_q->isLastValid()) {
467 if (!isEditModeActive()) {
468 qApp->postEvent(m_q,
new QKeyEvent(QEvent::KeyPress, Qt::Key_Up, e->modifiers()));
473 if (!isEditModeActive()) {
474 qApp->postEvent(m_q,
new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, e->modifiers()));
483 if (!e->isAutoRepeat()) {
484 if (!isEditModeActive()) {
487 if (m_q->isLastValid()) {
498 if (isEditModeActive()) {
499 endEditing(ValueUpdateMode_UseValueBeforeEditing);
508 if (!isEditModeActive() && e->key() >= Qt::Key_0 && e->key() <= Qt::Key_9) {
510 qApp->postEvent(m_q,
new QKeyEvent(QEvent::KeyPress, e->key(), e->modifiers(), e->text(), e->isAutoRepeat()));
524 if (!isEditModeActive() && m_lineEdit->rect().contains(e->pos())) {
531 if (isEditModeActive()) {
532 menu = m_lineEdit->createStandardContextMenu();
533 m_focusLostDueToMenu =
true;
541 QAction *selectAllAction =
nullptr;
542 if (isEditModeActive()) {
543 selectAllAction =
new QAction(i18nc(
"Menu action to select all text in the slider spin box",
"&Select All"), menu);
544#if QT_CONFIG(shortcut)
545 selectAllAction->setShortcut(QKeySequence::SelectAll);
547 menu->removeAction(menu->actions().last());
548 menu->addAction(selectAllAction);
549 menu->addSeparator();
552 const uint stepEnabled = m_q->stepEnabled();
553 QAction *stepUpAction = menu->addAction(i18nc(
"Menu action to step up in the slider spin box",
"&Step up"));
554 stepUpAction->setEnabled(stepEnabled & SpinBoxType::StepUpEnabled);
555 QAction *stepDown = menu->addAction(i18nc(
"Menu action to step down in the slider spin box",
"Step &down"));
556 stepDown->setEnabled(stepEnabled & SpinBoxType::StepDownEnabled);
557 menu->addSeparator();
562 (e->reason() == QContextMenuEvent::Mouse)
564 : m_q->mapToGlobal(QPoint(e->pos().x(), 0)) + QPoint(m_q->width() / 2, m_q->height() / 2);
565 const QAction *action = menu->exec(pos);
566 delete static_cast<QMenu *
>(menu);
567 if (spinbox && action) {
568 if (action == stepUpAction) {
570 }
else if (action == stepDown) {
572 }
else if (action == selectAllAction) {
585 if (e->queries().testFlag(Qt::ImEnabled) && !isEditModeActive()) {
586 e->setValue(Qt::ImEnabled,
false);
598 painter.setBrush(brush);
599 painter.setPen(Qt::NoPen);
601 painter.drawRoundedRect(
rect, 1, 1);
603 painter.drawRoundedRect(
rect, 0, 0);
608 void paintSliderText(QPainter &painter,
const QString &text,
const QRectF &
rect,
const QRectF &clipRect,
const QColor &color,
const QTextOption &textOption)
610 painter.setBrush(Qt::NoBrush);
611 painter.setPen(color);
612 painter.setClipping(
true);
613 painter.setClipRect(clipRect);
614 painter.drawText(
rect, text, textOption);
615 painter.setClipping(
false);
620 QTextOption textOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter);
621 textOption.setWrapMode(QTextOption::NoWrap);
623 paintSliderText(painter, text,
rect,
rect.adjusted(sliderRect.width(), 0, 0, 0), m_lineEdit->palette().text().color(), textOption);
625 paintSliderText(painter, text,
rect, sliderRect, m_lineEdit->palette().highlightedText().color(), textOption);
628 void paintSlider(QPainter &painter,
const QString &text,
double slider01Width,
double slider02Width = -1.0)
630 const QRectF
rect = m_lineEdit->rect();
631 const QColor highlightColor = m_q->palette().highlight().color();
632 if (slider02Width < 0.0) {
633 const QRectF sliderRect =
rect.adjusted(0, 0, -(
rect.width() - slider01Width), 0);
634 paintSliderRect(painter, sliderRect, highlightColor);
635 if (!text.isNull()) {
636 paintGenericSliderText(painter, text,
rect, sliderRect);
639 static constexpr double heightOfCollapsedSliderPlusSpace = heightOfCollapsedSlider + heightOfSpaceBetweenSliders;
640 const double heightBetween =
rect.height() - 2.0 * heightOfCollapsedSlider - heightOfSpaceBetweenSliders;
641 const double animationPos = m_sliderAnimation.currentValue().toReal();
642 const double a = heightOfCollapsedSliderPlusSpace;
643 const double b = heightOfCollapsedSliderPlusSpace + heightBetween;
645 QTextOption textOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter);
646 textOption.setWrapMode(QTextOption::NoWrap);
647 paintSliderText(painter, text,
rect,
rect, m_lineEdit->palette().text().color(), textOption);
653 rect.adjusted(0, 0, -(
rect.width() - slider02Width), softSliderAdjustment),
660 rect.adjusted(0, hardSliderAdjustment, -(
rect.width() - slider01Width), 0),
666 rect.adjusted(0, 0, -(
rect.width() - slider02Width), softSliderAdjustment),
667 m_lineEdit->palette().highlightedText().color(),
672 rect.adjusted(0, hardSliderAdjustment, -(
rect.width() - slider01Width), 0),
673 m_lineEdit->palette().highlightedText().color(),
681 const double rangeSize = max - min;
682 const double localPosition =
value - min;
683 const double normalizedValue = std::pow(localPosition / rangeSize, 1.0 / m_exponentRatio);
684 const double width =
static_cast<double>(m_lineEdit->width());
685 return qBound(0.0, std::round(normalizedValue * width), width);
690 QPainter painter(m_lineEdit);
691 painter.setRenderHint(QPainter::Antialiasing,
true);
693 const double value = m_q->value();
698 const double hardSliderWidth = computeSliderWidth(
static_cast<double>(m_q->minimum()),
static_cast<double>(m_q->maximum()),
value);
699 const double softSliderWidth = computeSliderWidth(m_softMinimum, m_softMaximum,
value);
700 if (!isEditModeActive()) {
701 QString text = m_q->text();
702 if (isSoftRangeValid()) {
703 if (m_softRangeViewMode == SoftRangeViewMode_AlwaysShowSoftRange) {
704 paintSlider(painter, text, softSliderWidth);
706 paintSlider(painter, text, hardSliderWidth, softSliderWidth);
710 paintSlider(painter, text, hardSliderWidth);
714 if (isSoftRangeValid()) {
715 if (m_softRangeViewMode == SoftRangeViewMode_AlwaysShowSoftRange) {
716 paintSlider(painter, QString(), softSliderWidth);
718 paintSlider(painter, QString(), hardSliderWidth, softSliderWidth);
721 paintSlider(painter, QString(), hardSliderWidth);
724 QColor color = m_q->palette().base().color();
726 paintSliderRect(painter, m_lineEdit->rect(), color);
730 return !isEditModeActive();
735 if (!m_q->isEnabled()) {
738 if (!isEditModeActive()) {
739 if (e->button() == Qt::LeftButton) {
740 m_lastMousePressPosition = e->pos();
741 const QPoint currentValuePosition = pointForValue(m_q->value());
742 m_relativeDraggingOffset = currentValuePosition.x() - e->x();
743 m_useRelativeDragging = (e->modifiers() & Qt::ShiftModifier);
745 QTimer::singleShot(0, &m_startEditingSignalProxy, SLOT(start()));
747 lineEditMouseMoveEvent(e);
757 if (!m_q->isEnabled()) {
760 if (!isEditModeActive()) {
763 if (e->button() == Qt::RightButton) {
768 QTimer::singleShot(0, &m_startEditingSignalProxy, SLOT(start()));
772 }
else if (e->button() == Qt::LeftButton) {
773 if (m_blockUpdateSignalOnDrag) {
774 const QPoint
p(m_useRelativeDragging ? e->pos().x() + m_relativeDraggingOffset : e->pos().x(),
776 setValue(valueForPoint(
p, e->modifiers()),
false,
true);
779 setValue(valueForPoint(e->pos(), e->modifiers()),
false,
true);
783 m_isDragging =
false;
784 Q_EMIT m_q->draggingFinished();
793 if (!m_q->isEnabled()) {
796 if (!isEditModeActive()) {
797 if (e->buttons() & Qt::LeftButton) {
801 const QPoint
p(m_useRelativeDragging ? e->pos().x() + m_relativeDraggingOffset : e->pos().x(),
803 setValue(valueForPoint(
p, e->modifiers()), m_blockUpdateSignalOnDrag);
812 QPainter painter(m_widgetRangeToggle);
813 painter.setRenderHint(QPainter::Antialiasing,
true);
815 const double width =
static_cast<double>(m_widgetRangeToggle->width());
816 const double height =
static_cast<double>(m_widgetRangeToggle->height());
817 constexpr double marginX = 4.0;
818 const double toggleWidth = width - 2.0 * marginX;
819 const double centerX = width * 0.5;
820 const double centerY = height * 0.5;
821 const double bigRadius = centerX - std::floor(centerX - (toggleWidth * 0.5)) + 0.5;
822 const double smallRadius = bigRadius * 0.5;
823 const double sliderAnimationPos = m_sliderAnimation.currentValue().toReal();
824 const double radius = smallRadius + sliderAnimationPos * (bigRadius - smallRadius);
826 const double rangeToggleHoverAnimationPos = m_rangeToggleHoverAnimation.currentValue().toReal();
827 const QColor baseColor = m_q->palette().base().color();
828 const QColor textColor = m_q->palette().text().color();
831 painter.setPen(color);
832 painter.setBrush(Qt::NoBrush);
833 painter.drawEllipse(QPointF(centerX, centerY), bigRadius, bigRadius);
835 painter.setPen(Qt::NoPen);
836 painter.setBrush(color);
837 painter.drawEllipse(QPointF(centerX, centerY), radius, radius);
843 if (!m_q->isEnabled()) {
846 if (e->button() == Qt::LeftButton) {
847 if (!m_isSoftRangeActive) {
848 makeSoftRangeActive();
850 makeHardRangeActive();
859 m_rangeToggleHoverAnimation.stop();
861 const int animationDuration =
862 static_cast<int>(std::round(m_rangeToggleHoverAnimation.currentValue().toReal() * fullAnimationDuration));
863 m_rangeToggleHoverAnimation.setStartValue(m_rangeToggleHoverAnimation.currentValue());
864 m_rangeToggleHoverAnimation.setEndValue(1.0);
865 m_rangeToggleHoverAnimation.setDuration(animationDuration);
866 m_rangeToggleHoverAnimation.start();
872 m_rangeToggleHoverAnimation.stop();
874 const int animationDuration =
875 static_cast<int>(std::round(m_rangeToggleHoverAnimation.currentValue().toReal() * fullAnimationDuration));
876 m_rangeToggleHoverAnimation.setStartValue(m_rangeToggleHoverAnimation.currentValue());
877 m_rangeToggleHoverAnimation.setEndValue(0.0);
878 m_rangeToggleHoverAnimation.setDuration(animationDuration);
879 m_rangeToggleHoverAnimation.start();
890 case QEvent::Resize :
return qResizeEvent(
static_cast<QResizeEvent*
>(e));
891 case QEvent::FocusOut :
return qFocusOutEvent(
static_cast<QFocusEvent*
>(e));
892 case QEvent::MouseButtonPress :
return qMousePressEvent(
static_cast<QMouseEvent*
>(e));
893 case QEvent::KeyPress :
return qKeyPressEvent(
static_cast<QKeyEvent*
>(e));
894 case QEvent::ContextMenu :
return qContextMenuEvent(
static_cast<QContextMenuEvent*
>(e));
895 case QEvent::InputMethodQuery:
return blockInputMethodQuery(
static_cast<QInputMethodQueryEvent *
>(e));
898 }
else if (o == m_lineEdit) {
900 case QEvent::Paint :
return lineEditPaintEvent(
static_cast<QPaintEvent*
>(e));
901 case QEvent::MouseButtonPress :
return lineEditMousePressEvent(
static_cast<QMouseEvent*
>(e),
false);
902 case QEvent::MouseButtonDblClick :
return lineEditMousePressEvent(
static_cast<QMouseEvent*
>(e),
true);
903 case QEvent::MouseButtonRelease :
return lineEditMouseReleaseEvent(
static_cast<QMouseEvent*
>(e));
904 case QEvent::MouseMove :
return lineEditMouseMoveEvent(
static_cast<QMouseEvent*
>(e));
907 }
else if (o == m_widgetRangeToggle) {
909 case QEvent::Paint :
return widgetRangeTogglePaintEvent(
static_cast<QPaintEvent*
>(e));
910 case QEvent::MouseButtonRelease:
return widgetRangeToggleMouseReleaseEvent(
static_cast<QMouseEvent*
>(e));
911 case QEvent::Enter:
return widgetRangeToggleEnterEvent(e);
912 case QEvent::Leave:
return widgetRangeToggleLeaveEvent(e);
913 case QEvent::InputMethodQuery:
return blockInputMethodQuery(
static_cast<QInputMethodQueryEvent *
>(e));
923 static constexpr double constantDraggingMargin{32.0};
925 static constexpr double heightOfCollapsedSlider{3.0};
927 static constexpr double heightOfSpaceBetweenSliders{0.0};
929 static constexpr double widthOfRangeModeToggle{16.0};
931 static constexpr double fullAnimationDuration{200.0};
934 QLineEdit *m_lineEdit {
nullptr};
935 QWidget *m_widgetRangeToggle {
nullptr};
938 double m_exponentRatio {1.0};
939 bool m_blockUpdateSignalOnDrag {
false};
942 bool m_isDragging {
false};
943 bool m_useRelativeDragging {
false};
944 int m_relativeDraggingOffset {0};
946 int m_rightClickCounter {0};
947 bool m_focusLostDueToMenu {
false};
948 bool m_isSoftRangeActive {
true};
956 SoftRangeViewMode_ShowBothRanges
957 } m_softRangeViewMode{SoftRangeViewMode_ShowBothRanges};
float value(const T *src, size_t ch)
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)
bool blockInputMethodQuery(QInputMethodQueryEvent *e)
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)