- fixes
This commit is contained in:
parent
4e51dc85e8
commit
6c495b6c7f
@ -86,7 +86,7 @@ void MainWindow::init()
|
|||||||
mBreakStartTimer = new QTimer(this);
|
mBreakStartTimer = new QTimer(this);
|
||||||
mBreakStartTimer->setTimerType(Qt::TimerType::CoarseTimer);
|
mBreakStartTimer->setTimerType(Qt::TimerType::CoarseTimer);
|
||||||
mBreakStartTimer->setSingleShot(true);
|
mBreakStartTimer->setSingleShot(true);
|
||||||
connect(mBreakStartTimer, SIGNAL(timeout()), this, SLOT(onLongBreakStart()));
|
connect(mBreakStartTimer, &QTimer::timeout, this, [this](){shiftTo(AppState::Break);});
|
||||||
|
|
||||||
// Timer to run notification about upcoming break
|
// Timer to run notification about upcoming break
|
||||||
mBreakNotifyTimer = new QTimer(this);
|
mBreakNotifyTimer = new QTimer(this);
|
||||||
@ -109,7 +109,7 @@ void MainWindow::init()
|
|||||||
connect(mProgressTimer, SIGNAL(timeout()), this, SLOT(onProgress()));
|
connect(mProgressTimer, SIGNAL(timeout()), this, SLOT(onProgress()));
|
||||||
|
|
||||||
connect(ui->mPostponeButton, SIGNAL(clicked()), this, SLOT(onLongBreakPostpone()));
|
connect(ui->mPostponeButton, SIGNAL(clicked()), this, SLOT(onLongBreakPostpone()));
|
||||||
connect(ui->mSkipButton, SIGNAL(clicked()), this, SLOT(onLongBreakEnd()));
|
connect(ui->mSkipButton, &QPushButton::clicked, this, [this](){shiftTo(AppState::Counting);});
|
||||||
|
|
||||||
// Use the latest config
|
// Use the latest config
|
||||||
applyConfig();
|
applyConfig();
|
||||||
@ -264,10 +264,29 @@ static int msec2min(int msec)
|
|||||||
return (int)(min_f + 0.5f);
|
return (int)(min_f + 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString state2str(AppState state)
|
||||||
|
{
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case AppState::None:
|
||||||
|
return "None";
|
||||||
|
case AppState::Break:
|
||||||
|
return "Break";
|
||||||
|
case AppState::Idle:
|
||||||
|
return "Idle";
|
||||||
|
case AppState::Counting:
|
||||||
|
return "Counting";
|
||||||
|
}
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::shiftTo(AppState newState)
|
void MainWindow::shiftTo(AppState newState)
|
||||||
{
|
{
|
||||||
if (newState == mState)
|
if (newState == mState)
|
||||||
return;
|
return;
|
||||||
|
#if defined(DEBUG)
|
||||||
|
qDebug() << state2str(mState) << " -> " << state2str(newState);
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (newState)
|
switch (newState)
|
||||||
{
|
{
|
||||||
@ -380,9 +399,6 @@ void MainWindow::onLongBreakStart()
|
|||||||
|
|
||||||
// Start progress bar
|
// Start progress bar
|
||||||
mProgressTimer->start();
|
mProgressTimer->start();
|
||||||
|
|
||||||
// Refresh UI
|
|
||||||
onUpdateUI();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onLongBreakEnd()
|
void MainWindow::onLongBreakEnd()
|
||||||
@ -401,16 +417,14 @@ void MainWindow::onLongBreakEnd()
|
|||||||
mProgressTimer->stop();
|
mProgressTimer->stop();
|
||||||
|
|
||||||
// Start new timer
|
// Start new timer
|
||||||
mBreakStartTimer->stop();
|
if (!mBreakStartTimer->isActive())
|
||||||
mBreakStartTimer->start(std::chrono::seconds(mAppConfig.longbreak_interval));
|
mBreakStartTimer->start(std::chrono::seconds(mAppConfig.longbreak_interval));
|
||||||
mBreakNotifyTimer->stop();
|
if (!mBreakNotifyTimer->isActive())
|
||||||
mBreakNotifyTimer->start(std::chrono::seconds(mAppConfig.longbreak_interval - 30));
|
mBreakNotifyTimer->start(std::chrono::seconds(mAppConfig.longbreak_interval - 30));
|
||||||
|
|
||||||
// Refresh UI
|
// Play selected audio. When break is postponed - audio is not played
|
||||||
onUpdateUI();
|
if (!mPostponeCount)
|
||||||
|
play_audio(mAppConfig.play_audio);
|
||||||
// Play selecged audio
|
|
||||||
play_audio(mAppConfig.play_audio);
|
|
||||||
|
|
||||||
// Run script
|
// Run script
|
||||||
if (!mAppConfig.script_on_break_finish.isEmpty())
|
if (!mAppConfig.script_on_break_finish.isEmpty())
|
||||||
@ -437,8 +451,7 @@ void MainWindow::onLongBreakPostpone()
|
|||||||
mBreakNotifyTimer->stop();
|
mBreakNotifyTimer->stop();
|
||||||
mBreakNotifyTimer->start(std::chrono::seconds(mAppConfig.longbreak_postpone_interval - 30));
|
mBreakNotifyTimer->start(std::chrono::seconds(mAppConfig.longbreak_postpone_interval - 30));
|
||||||
|
|
||||||
// Refresh UI
|
shiftTo(AppState::Counting);
|
||||||
onUpdateUI();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onProgress()
|
void MainWindow::onProgress()
|
||||||
@ -501,7 +514,6 @@ void MainWindow::onIdleEnd()
|
|||||||
}
|
}
|
||||||
|
|
||||||
mWorkInterval = mAppConfig.longbreak_interval * 1000;
|
mWorkInterval = mAppConfig.longbreak_interval * 1000;
|
||||||
shiftTo(AppState::Counting);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onSettings()
|
void MainWindow::onSettings()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user