- version 0.1.5 - fix random notifications

This commit is contained in:
Dmytro Bogovych 2022-05-29 16:59:56 +03:00
parent ee486da79d
commit 24b470cfc6
2 changed files with 19 additions and 7 deletions

View File

@ -4,7 +4,7 @@
// App version // App version
#define QBREAK_VERSION_MAJOR 0 #define QBREAK_VERSION_MAJOR 0
#define QBREAK_VERSION_MINOR 1 #define QBREAK_VERSION_MINOR 1
#define QBREAK_VERSION_SUFFIX 4 #define QBREAK_VERSION_SUFFIX 5
// How often UI is updated - interval in seconds // How often UI is updated - interval in seconds
#define INTERVAL_UPDATE_UI (60) #define INTERVAL_UPDATE_UI (60)

View File

@ -273,10 +273,16 @@ void MainWindow::onUpdateUI()
{ {
// Start idle mode. Save idle start time // Start idle mode. Save idle start time
mIdleStart = std::chrono::steady_clock::now() - std::chrono::milliseconds(idle_milliseconds); mIdleStart = std::chrono::steady_clock::now() - std::chrono::milliseconds(idle_milliseconds);
if (mTimer->isActive())
{
// Save how much time was remaininig when idle was detected + add idle length
// Later timer will restart with this interval time
mIdleRemaining = mTimer->remainingTime() + idle_milliseconds; mIdleRemaining = mTimer->remainingTime() + idle_milliseconds;
// Stop counting // Stop counting
mTimer->stop(); mTimer->stop();
mNotifyTimer->stop();
}
} }
else else
{ {
@ -290,9 +296,8 @@ void MainWindow::onUpdateUI()
{ {
// Idle interval ended // Idle interval ended
mIdleStart.reset(); mIdleStart.reset();
mTimer->setInterval(mIdleRemaining); mTimer->start(mIdleRemaining);
mTimer->setSingleShot(true); mNotifyTimer->start(std::max(1, mIdleRemaining - 30 * 1000));
mTimer->start();
} }
else else
{ {
@ -334,7 +339,11 @@ void MainWindow::onLongBreakStart()
{ {
// qDebug() << "Long break starts for " << secondsToText(mAppConfig.longbreak_postpone_interval); // qDebug() << "Long break starts for " << secondsToText(mAppConfig.longbreak_postpone_interval);
mTimer->stop();
mNotifyTimer->stop();
// Reset idle counter // Reset idle counter
mLastIdleMilliseconds = 0; mLastIdleMilliseconds = 0;
ui->mPostponeButton->setText(tr("Postpone for ") + secondsToText(mAppConfig.longbreak_postpone_interval)); ui->mPostponeButton->setText(tr("Postpone for ") + secondsToText(mAppConfig.longbreak_postpone_interval));
@ -429,6 +438,9 @@ void MainWindow::onProgress()
void MainWindow::onNextBreak() void MainWindow::onNextBreak()
{ {
mIdleRemaining = 0;
mIdleStart.reset();
mTimer->stop(); mTimer->stop();
mNotifyTimer->stop(); mNotifyTimer->stop();