18#include <swadjustabledigit.h>
20using namespace std::chrono;
22SWAdjustableDigit::SWAdjustableDigit( QWidget* parent )
28SWAdjustableDigit::~SWAdjustableDigit()
33void SWAdjustableDigit::mousePressEvent( QMouseEvent* event )
37 _timerID = startTimer( 200 );
40 _posY =
event->pos().y();
41 int middle = rect().height() / 2;
42 _delta = _posY >= middle ? -1 : +1 ;
43 qDebug() <<
"first press: " << middle <<
" : " << _posY <<
"delta: " << _delta;
44 setNumber( _number + _delta );
50void SWAdjustableDigit::mouseMoveEvent( QMouseEvent* event )
54 if( !rect().contains( event->pos() ) )
56 mouseReleaseEvent( event );
65void SWAdjustableDigit::mouseReleaseEvent( QMouseEvent* event )
69 killTimer( _timerID );
79void SWAdjustableDigit::timerEvent( QTimerEvent* event )
90 if( !_waiting && _delta )
92 setNumber( _number + _delta );
97 killTimer( _timerID );
99 _timerID = startTimer( 100 );