MCPcopy Create free account
hub / github.com/Liniyous/ElaWidgetTools / mouseReleaseEvent

Method mouseReleaseEvent

ElaWidgetTools/ElaToggleSwitch.cpp:98–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96void ElaToggleSwitch::mousePressEvent(QMouseEvent* event)
97{
98 if (event->button() != Qt::LeftButton)
99 {
100 QWidget::mousePressEvent(event);
101 return;
102 }
103 Q_D(ElaToggleSwitch);
104 if (d->_positionAnimation)
105 {
106 d->_positionAnimation->stop();
107 }
108 d->_adjustCircleCenterX();
109 setProperty("circleCenterX", d->_circleCenterX);
110 d->_isLeftButtonPress = true;
111 d->_isDragging = false;
112 d->_mousePressPos = event->pos();
113 d->_lastMouseX = event->pos().x();
114 d->_startRadiusAnimation(d->_circleRadius, d->_getTrackHeight() * 0.25);
115 event->accept();
116}
117
118void ElaToggleSwitch::mouseReleaseEvent(QMouseEvent* event)
119{
120 Q_D(ElaToggleSwitch);
121 if (event->button() != Qt::LeftButton || !d->_isLeftButtonPress)
122 {
123 QWidget::mouseReleaseEvent(event);
124 return;
125 }
126 d->_isLeftButtonPress = false;
127 bool isToggled = d->_isToggled;
128 if (d->_isDragging)
129 {
130 isToggled = d->_circleCenterX > width() / 2;

Callers

nothing calls this directly

Calls 2

_startPosAnimationMethod · 0.80
_startRadiusAnimationMethod · 0.45

Tested by

no test coverage detected