~aleteoryx/muditaos

3ff04e06c9eab6de2c9a2ded0876bed2d87eab93 — Maciej Gibowicz 1 year, 9 months ago 5d4d036
[BH-1944] Changing the rounding method for minutes in relaxation

Only at startup, when the number of seconds is less than 30, the minutes
are rounded down, otherwise they are rounded up
M module-apps/apps-common/widgets/TimeMinuteSecondWidget.cpp => module-apps/apps-common/widgets/TimeMinuteSecondWidget.cpp +19 -1
@@ 17,6 17,21 @@ namespace
        return digits;
    }

    std::uint32_t getRoundedMinutes(std::uint32_t currentSeconds, std::uint32_t totalSeconds)
    {
        constexpr auto halfMinute{utils::time::secondsInMinute / 2};
        const auto totalMin   = totalSeconds / utils::time::secondsInMinute;
        const auto totalSec   = totalSeconds % utils::time::secondsInMinute;
        const auto currentMin = currentSeconds / utils::time::secondsInMinute;

        // only at startup, when the number of seconds is less than 30, we round down
        if (totalMin > 0 && totalMin == currentMin && totalSec < halfMinute) {
            return currentMin;
        }
        // otherwise, we round up
        return currentMin + 1;
    }

    namespace digit
    {
        constexpr auto width      = 340U;


@@ 100,9 115,12 @@ namespace gui

    void TimeMinuteSecondWidget::updateTime(std::uint32_t seconds)
    {
        if (!totalSeconds.has_value()) {
            totalSeconds = seconds;
        }
        if (displayType != DisplayType::OnlySeconds &&
            (seconds >= utils::time::secondsInMinute || displayType == DisplayType::OnlyMinutes)) {
            const auto minutes = (seconds + utils::time::secondsInMinute - 1) / utils::time::secondsInMinute;
            const auto minutes = getRoundedMinutes(seconds, totalSeconds.value());
            setText(minutes);
            description->setText(utils::language::getCorrectMinutesNumeralForm(minutes));
        }

M module-apps/apps-common/widgets/TimeMinuteSecondWidget.hpp => module-apps/apps-common/widgets/TimeMinuteSecondWidget.hpp +1 -0
@@ 32,6 32,7 @@ namespace gui

      private:
        DisplayType displayType;
        std::optional<std::uint32_t> totalSeconds;

        static constexpr auto maxDigits{3U};
        VBox *mainBox{nullptr};

M products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningProgressWindow.cpp => products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningProgressWindow.cpp +1 -1
@@ 75,7 75,7 @@ namespace gui
                                           0,
                                           relStyle::timer::maxSizeX,
                                           relStyle::timer::maxSizeY,
                                           TimeMinuteSecondWidget::DisplayType::OnlyMinutes);
                                           TimeMinuteSecondWidget::DisplayType::MinutesThenSeconds);
        timer->setMinimumSize(relStyle::timer::maxSizeX, relStyle::timer::maxSizeY);
        timer->setMargins(Margins(0, relStyle::timer::marginTop, 0, 0));
        timer->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center));