Commit 746294a8 authored by Loren Burkholder's avatar Loren Burkholder
Browse files

Add reset disable; stop chrono on reset

parent 6973d67e
......@@ -23,6 +23,7 @@ void Chronometer::start()
m_updateTimer.start(m_timerInterval);
emit disableStart(true);
emit disableStopLap(false);
emit disableReset(false);
qDebug() << tr("Chronometer started");
}
......@@ -42,11 +43,13 @@ void Chronometer::stop()
void Chronometer::reset()
{
this->stop();
m_totalElapsed -= m_totalElapsed; // KLUDGE: there's no simple way to set a std::chrono::duration to zero so I just did this instead
m_beginning = std::chrono::steady_clock::now();
for (int i = m_laps.size(); i > 0; --i) // KLUDGE: the size of m_laps decreases every pop_back(), so it's not reliable
m_laps.pop_back();
updateElapsed();
emit disableReset(true);
emit newLap(0, "", ""); // zero meaning we've reset
qDebug() << tr("Chronometer reset");
}
......
......@@ -27,6 +27,7 @@ signals:
void newLap(int, QString, QString);
void disableStart(bool);
void disableStopLap(bool);
void disableReset(bool);
public slots:
virtual void start();
......
......@@ -27,6 +27,7 @@ KlockMainWindow::KlockMainWindow(QWidget *parent)
m_timerStop->setDisabled(true);
m_chronoStop->setDisabled(true);
m_chronoLap->setDisabled(true);
m_chronoReset->setDisabled(true);
// set up the timer group layout
m_timerLayout = new QGridLayout(m_timerBox);
......@@ -66,6 +67,7 @@ void KlockMainWindow::setupConnections(KlockTimer *timer, Chronometer *chrono)
QObject::connect(m_chronoStop, SIGNAL(clicked()), chrono, SLOT(stop()));
QObject::connect(chrono, SIGNAL(disableStopLap(bool)), m_chronoStop, SLOT(setDisabled(bool)));
QObject::connect(m_chronoReset, SIGNAL(clicked()), chrono, SLOT(reset()));
QObject::connect(chrono, SIGNAL(disableReset(bool)), m_chronoReset, SLOT(setDisabled(bool)));
QObject::connect(m_chronoLap, SIGNAL(clicked()), chrono, SLOT(lap()));
QObject::connect(chrono, SIGNAL(disableStopLap(bool)), m_chronoLap, SLOT(setDisabled(bool)));
QObject::connect(chrono, SIGNAL(stateChanged(QString)), m_chronoTime, SLOT(setText(QString)));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment