mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-04-18 22:18:38 -04:00
40 lines
1.2 KiB
C++
40 lines
1.2 KiB
C++
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#pragma once
|
|
|
|
#include <gui/widgets/BoxLayout.hpp>
|
|
#include <gui/widgets/Image.hpp>
|
|
#include <gui/widgets/text/Label.hpp>
|
|
#include <apps-common/widgets/TextSpinnerBoxWithLabel.hpp>
|
|
|
|
#include <list>
|
|
#include <chrono>
|
|
|
|
namespace gui
|
|
{
|
|
class TimerProperty;
|
|
|
|
class IntervalBox : public HBox
|
|
{
|
|
TimerProperty *timerSetter = nullptr;
|
|
TextSpinnerBoxWithLabel *chimeSpinner = nullptr;
|
|
|
|
void build();
|
|
void updateIntervals();
|
|
[[nodiscard]] std::string intervalToString(std::chrono::minutes time);
|
|
[[nodiscard]] std::chrono::minutes stringToInterval(const std::string &description);
|
|
|
|
void rescaleIntervals();
|
|
|
|
public:
|
|
using OnChangeCallback = std::function<void(std::chrono::minutes newValue)>;
|
|
|
|
IntervalBox(Item *parent, uint32_t x, uint32_t y, uint32_t w, uint32_t h, TimerProperty *timerSetter);
|
|
|
|
[[nodiscard]] std::chrono::seconds getIntervalValue() noexcept;
|
|
bool setIntervalValue(std::chrono::minutes newValue);
|
|
void setOnChangeCallback(OnChangeCallback &callback);
|
|
};
|
|
} // namespace gui
|