~aleteoryx/muditaos

ref: 2695cc830472190ce1401869bb67f5506a3e17e6 muditaos/module-apps/application-settings-new/widgets/timeWidget.hpp -rw-r--r-- 1.3 KiB
2695cc83 — piotrleniec-mudita [DW-31] Add commit message format checking on CI (#1201) 5 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <Label.hpp>
#include <Text.hpp>

namespace gui
{
    class TimeWidget : public VBox
    {
      public:
        TimeWidget(Item *parent,
                   const std::string &description,
                   std::function<void(const UTF8 &text)> bottomBarTemporaryMode = nullptr,
                   std::function<void()> bottomBarRestoreFromTemporaryMode      = nullptr);

        [[nodiscard]] auto getTime() const noexcept -> std::chrono::minutes;
        void setTime(std::chrono::minutes newTime);

      private:
        gui::HBox *hBox         = nullptr;
        Label *descriptionLabel = nullptr;
        Text *hourInput         = nullptr;
        Label *colonLabel       = nullptr;
        Text *minuteInput       = nullptr;
        Label *separatorLabel   = nullptr;
        Label *meridiemInput    = nullptr;

        std::function<void(const UTF8 &text)> bottomBarTemporaryMode = nullptr;
        std::function<void()> bottomBarRestoreFromTemporaryMode      = nullptr;

        void applyFocusCallbacks();
        void applyInputCallbacks();
        [[nodiscard]] auto readTimeFromInputFields() const -> bool;
    };

} /* namespace gui */