M module-apps/apps-common/widgets/ProgressTimerImpl.cpp => module-apps/apps-common/widgets/ProgressTimerImpl.cpp +17 -6
@@ 8,14 8,19 @@
#include <time/time_conversion.hpp>
#include <gsl/assert>
+namespace
+{
+ inline constexpr auto increasingModePrefix = "-";
+}
namespace app
{
ProgressTimerImpl::ProgressTimerImpl(app::ApplicationCommon *app,
gui::Item *parent,
std::string timerName,
- std::chrono::milliseconds baseTick)
- : app{app}, parent{parent}, name{std::move(timerName)}, baseTickInterval{baseTick}
+ std::chrono::milliseconds baseTick,
+ ProgressCountdownMode countdownMode)
+ : app{app}, parent{parent}, name{std::move(timerName)}, baseTickInterval{baseTick}, countdownMode{countdownMode}
{}
void ProgressTimerImpl::resetProgress()
@@ 35,11 40,17 @@ namespace app
void ProgressTimerImpl::updateText()
{
using utils::time::Duration;
- if (text != nullptr) {
- const auto secondsRemaining = duration - elapsed;
- const Duration remainingDuration{std::time_t{secondsRemaining.count()}};
- text->setText(remainingDuration.str(Duration::DisplayedFormat::Fixed0M0S));
+ if (text == nullptr) {
+ return;
+ }
+ const auto secondsRemaining = duration - elapsed;
+ const Duration remainingDuration{std::time_t{secondsRemaining.count()}};
+ UTF8 timerText;
+ if (countdownMode == ProgressCountdownMode::Increasing && secondsRemaining != std::chrono::seconds::zero()) {
+ timerText += increasingModePrefix;
}
+ timerText += remainingDuration.str(Duration::DisplayedFormat::Fixed0M0S);
+ text->setText(std::move(timerText));
}
void ProgressTimerImpl::updateProgress()
M module-apps/apps-common/widgets/ProgressTimerImpl.hpp => module-apps/apps-common/widgets/ProgressTimerImpl.hpp +8 -1
@@ 21,6 21,11 @@ namespace gui
namespace app
{
+ enum class ProgressCountdownMode
+ {
+ Decreasing,
+ Increasing
+ };
class ProgressTimerImpl : public ProgressTimer
{
@@ 41,6 46,7 @@ namespace app
std::function<void()> onFinishedCallback = nullptr;
std::function<void()> onIntervalCallback = nullptr;
+ ProgressCountdownMode countdownMode;
void startTimer();
void update();
@@ 55,7 61,8 @@ namespace app
ProgressTimerImpl(app::ApplicationCommon *app,
gui::Item *parent,
std::string timerName,
- std::chrono::milliseconds baseTick);
+ std::chrono::milliseconds baseTick,
+ ProgressCountdownMode countdownMode = ProgressCountdownMode::Decreasing);
void reset(std::chrono::seconds _duration,
std::chrono::seconds _interval = std::chrono::seconds::zero()) override;
void start() override;
M products/BellHybrid/apps/application-bell-powernap/presenter/PowerNapProgressPresenter.cpp => products/BellHybrid/apps/application-bell-powernap/presenter/PowerNapProgressPresenter.cpp +2 -1
@@ 32,7 32,8 @@ namespace app::powernap
void PowerNapProgressPresenter::initTimer(gui::Item *parent)
{
- timer = std::make_unique<app::ProgressTimerImpl>(app, parent, powernapTimerName, timerTick);
+ timer = std::make_unique<app::ProgressTimerImpl>(
+ app, parent, powernapTimerName, timerTick, app::ProgressCountdownMode::Increasing);
timer->registerOnFinishedCallback([this]() { onNapFinished(); });
}
void PowerNapProgressPresenter::activate()