~aleteoryx/muditaos

ref: 3fd296c50def4440e2aff28214bd3c51c0bbc9ac muditaos/module-apps/application-settings-new/widgets/timeWidget.hpp -rw-r--r-- 1.3 KiB
3fd296c5 — Tomasz Langowski [EGD-5845] Fix broken harness messages tests 4 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
40
// 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>
#include <chrono>

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 */