- many fixes + version increase to 0.1.9
This commit is contained in:
parent
6c495b6c7f
commit
21046d9c35
@ -4,7 +4,7 @@
|
||||
// App version
|
||||
#define QBREAK_VERSION_MAJOR 0
|
||||
#define QBREAK_VERSION_MINOR 1
|
||||
#define QBREAK_VERSION_SUFFIX 8
|
||||
#define QBREAK_VERSION_SUFFIX 9
|
||||
|
||||
// How often UI is updated - interval in seconds
|
||||
#define INTERVAL_UPDATE_UI (60)
|
||||
@ -12,7 +12,7 @@
|
||||
// How often progress bar is updated - interval in milliseconds
|
||||
#define INTERVAL_UPDATE_PROGRESS (1000)
|
||||
|
||||
// How long notification is shown - in milliseconds
|
||||
#define INTERVAL_NOTIFICATION (30000)
|
||||
// How long notification is shown - in seconds
|
||||
#define INTERVAL_NOTIFICATION (30)
|
||||
|
||||
#endif // CONFIG_H
|
||||
|
||||
@ -384,6 +384,7 @@ void MainWindow::onLongBreakStart()
|
||||
{
|
||||
mBreakStartTimer->stop();
|
||||
mBreakNotifyTimer->stop();
|
||||
qDebug() << "Stop main and notify timers.";
|
||||
|
||||
// Reset idle counter
|
||||
mIdleStart.reset();
|
||||
@ -418,9 +419,15 @@ void MainWindow::onLongBreakEnd()
|
||||
|
||||
// Start new timer
|
||||
if (!mBreakStartTimer->isActive())
|
||||
{
|
||||
mBreakStartTimer->start(std::chrono::seconds(mAppConfig.longbreak_interval));
|
||||
qDebug() << "Start main timer for " << mAppConfig.longbreak_interval << " seconds.";
|
||||
}
|
||||
if (!mBreakNotifyTimer->isActive())
|
||||
{
|
||||
mBreakNotifyTimer->start(std::chrono::seconds(mAppConfig.longbreak_interval - 30));
|
||||
qDebug() << "Start notify timer for " << mAppConfig.longbreak_interval - 30 << " seconds.";
|
||||
}
|
||||
|
||||
// Play selected audio. When break is postponed - audio is not played
|
||||
if (!mPostponeCount)
|
||||
@ -491,11 +498,12 @@ void MainWindow::onIdleStart()
|
||||
mIdleStart = std::chrono::steady_clock::now();
|
||||
|
||||
// How much working time remains
|
||||
mWorkInterval = mBreakStartTimer->remainingTime();
|
||||
mRemainingWorkInterval = mBreakStartTimer->remainingTime() / 1000;
|
||||
|
||||
// Stop main & notify timers
|
||||
mBreakStartTimer->stop();
|
||||
mBreakNotifyTimer->stop();
|
||||
qDebug() << "Stop main and notify timers.";
|
||||
}
|
||||
|
||||
void MainWindow::onIdleEnd()
|
||||
@ -506,14 +514,24 @@ void MainWindow::onIdleEnd()
|
||||
mIdleStart.reset();
|
||||
|
||||
// Update timer(s) duration
|
||||
if (mWorkInterval >= 0)
|
||||
if (mRemainingWorkInterval)
|
||||
{
|
||||
mBreakStartTimer->setInterval(mWorkInterval);
|
||||
if (mWorkInterval > INTERVAL_NOTIFICATION)
|
||||
mBreakNotifyTimer->setInterval(mWorkInterval - INTERVAL_NOTIFICATION);
|
||||
mBreakStartTimer->setInterval(std::chrono::seconds(*mRemainingWorkInterval));
|
||||
if (mRemainingWorkInterval > INTERVAL_NOTIFICATION)
|
||||
mBreakNotifyTimer->setInterval(std::chrono::seconds(*mRemainingWorkInterval - INTERVAL_NOTIFICATION));
|
||||
mRemainingWorkInterval.reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
mBreakStartTimer->setInterval(std::chrono::seconds(mAppConfig.longbreak_interval));
|
||||
if (mRemainingWorkInterval > INTERVAL_NOTIFICATION)
|
||||
mBreakNotifyTimer->setInterval(std::chrono::seconds(mAppConfig.longbreak_interval - INTERVAL_NOTIFICATION));
|
||||
}
|
||||
|
||||
mWorkInterval = mAppConfig.longbreak_interval * 1000;
|
||||
if (!mBreakStartTimer->isActive())
|
||||
mBreakStartTimer->start();
|
||||
if (!mBreakNotifyTimer->isActive())
|
||||
mBreakNotifyTimer->start();
|
||||
}
|
||||
|
||||
void MainWindow::onSettings()
|
||||
|
||||
@ -50,7 +50,7 @@ private:
|
||||
std::chrono::steady_clock::time_point mBreakStartTime;
|
||||
|
||||
// How much milliseconds remains for main break
|
||||
int mWorkInterval = -1;
|
||||
std::optional<int> mRemainingWorkInterval;
|
||||
|
||||
app_settings::config mAppConfig;
|
||||
int mPostponeCount;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user