- fix the strange behavior when user missed break and start of next working interval

This commit is contained in:
Dmytro Bogovych 2022-05-31 14:40:14 +03:00
parent 24b470cfc6
commit eed9e13e91
2 changed files with 8 additions and 2 deletions

View File

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

View File

@ -271,8 +271,14 @@ void MainWindow::onUpdateUI()
{
if (!mIdleStart)
{
// Idle could start before timer start
// Check and shrink the found idle interval if needed
auto proposed_idle_start = std::chrono::steady_clock::now() - std::chrono::milliseconds(idle_milliseconds);
auto timer_start = std::chrono::steady_clock::now() - (std::chrono::milliseconds(mTimer->interval() - mTimer->remainingTime()));
mIdleStart = std::max(timer_start, proposed_idle_start);
// 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