void SpeedDial::slotDialChanged(int value) { Q_ASSERT(m_focus != NULL); int newValue = dialDiff(value, m_previousDialValue, m_dial->singleStep()) + m_focus->value(); if (newValue > m_focus->maximum()) { // Incremented value is above m_focus->maximum(). Spill the overflow to the // bigger number (unless already incrementing hours). if (m_focus == m_ms) m_value += (m_ms->singleStep() * MS_DIV); else if (m_focus == m_sec) m_value += MS_PER_SECOND; else if (m_focus == m_min) m_value += MS_PER_MINUTE; m_value = CLAMP(m_value, 0, INT_MAX); setSpinValues(m_value); } else if (newValue < m_focus->minimum()) { newValue = m_value; // Decremented value is below m_focus->minimum(). Spill the underflow to the // smaller number (unless already decrementing milliseconds). if (m_focus == m_ms) newValue -= (m_ms->singleStep() * MS_DIV); else if (m_focus == m_sec) newValue -= MS_PER_SECOND; else if (m_focus == m_min) newValue -= MS_PER_MINUTE; if (newValue >= 0) { m_value = newValue; m_value = CLAMP(m_value, 0, INT_MAX); setSpinValues(m_value); } } else { // Normal value increment/decrement. m_value = newValue; m_value = CLAMP(m_value, 0, INT_MAX); m_focus->setValue(m_value); } // stop tap button blinking if it was stopTimers(); // Store the current value so it can be compared on the next pass to determine the // dial's direction of rotation. m_previousDialValue = value; }
void SpeedDial::slotTapClicked() { if (m_tapTime == NULL) { m_tapTime = new QTime(QTime::currentTime()); if (m_tapTickTimer == NULL) { m_tapTickTimer = new QTimer(); connect(m_tapTickTimer, SIGNAL(timeout()), this, SLOT(slotTapTimeout())); } m_tapTime->start(); return; } // Round the elapsed time to the nearest full 10th ms. int remainder = m_tapTime->elapsed() % MS_DIV; m_value = m_tapTime->elapsed() - remainder; if (remainder >= (MS_DIV / 2)) m_value += MS_DIV; setSpinValues(m_value); m_tapTime->restart(); if (m_tapTickTimer) { m_tapTickTimer->setInterval(m_value); m_tapTickTimer->start(); } emit tapped(); }
void SpeedDial::setValue(int ms, bool emitValue) { if (emitValue == false) m_preventSignals = true; m_value = ms; setSpinValues(ms); if (ms == (int) Function::infiniteSpeed()) m_infiniteCheck->setChecked(true); else m_infiniteCheck->setChecked(false); m_preventSignals = false; }
void SpeedDial::setValue(int ms, bool emitValue) { if (emitValue == false) m_preventSignals = true; m_value = ms; setSpinValues(ms); if (ms == (int) Function::infiniteSpeed()) m_infiniteCheck->setChecked(true); else m_infiniteCheck->setChecked(false); // time has changed - update tap button blinking updateTapTimer(); m_preventSignals = false; }
void SpeedDial::slotTapClicked() { if (m_tapTime == NULL) { m_tapTime = new QTime(QTime::currentTime()); m_tapTime->start(); return; } // Round the elapsed time to the nearest full 10th ms. m_value = m_tapTime->elapsed(); setSpinValues(m_value); m_tapTime->restart(); // time has changed - update tap button blinking updateTapTimer(); emit tapped(); }