| 96 | void 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 | |
| 118 | void 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; |
nothing calls this directly
no test coverage detected