From 955edc2f6ad8ee0c651ab8c21c73c376decae6a7 Mon Sep 17 00:00:00 2001 From: laserpants Date: Sat, 30 Apr 2016 13:54:59 +0300 Subject: [PATCH] zoom slider handle on mouse press --- components/slider.cpp | 12 +++++++----- components/slider.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/components/slider.cpp b/components/slider.cpp index 87ace7d..4d02293 100644 --- a/components/slider.cpp +++ b/components/slider.cpp @@ -8,13 +8,13 @@ Handle::Handle(Slider *slider) : QWidget(slider), _slider(slider), _animation(new QPropertyAnimation(this)), - _scaleFactor(1) + _scaleFactor(12) { _animation->setPropertyName("scaleFactor"); _animation->setTargetObject(this); - _animation->setStartValue(1); - _animation->setEndValue(2); - _animation->setDuration(200); + _animation->setStartValue(12); + _animation->setEndValue(20); + _animation->setDuration(100); } Handle::~Handle() @@ -51,7 +51,9 @@ void Handle::paintEvent(QPaintEvent *event) painter.setBrush(brush); painter.setPen(Qt::NoPen); - painter.drawEllipse(0, 0, width(), height()); + //painter.drawEllipse(0, 0, width(), height()); + //painter.drawRect(rect()); + painter.drawEllipse((width()-_scaleFactor)/2, (height()-_scaleFactor)/2, _scaleFactor, _scaleFactor); QWidget::paintEvent(event); } diff --git a/components/slider.h b/components/slider.h index 7963167..4ff0155 100644 --- a/components/slider.h +++ b/components/slider.h @@ -17,7 +17,7 @@ public: explicit Handle(Slider *slider); ~Handle(); - inline QSize sizeHint() const Q_DECL_OVERRIDE { return QSize(12, 12)*_scaleFactor; } + inline QSize sizeHint() const Q_DECL_OVERRIDE { return QSize(24, 24); } // *_scaleFactor; } inline void setRelativePosition(const QPoint &pos) { setPosition(_offset + pos); }