~aleteoryx/muditaos

ref: e1400aee902f44fb81c5a1efb32d9db561a88df2 muditaos/module-apps/application-settings/windows/DateTimeWindow.hpp -rw-r--r-- 1.8 KiB
e1400aee — Radoslaw Wicik [EGD-5685] Add version field in DeviceInfo EP 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

/*
 * DateTimeWindow.hpp
 *
 *  Created on: 28 sty 2020
 *      Author: kuba
 */

#pragma once

#include <functional>
#include <string>

#include "AppWindow.hpp"
#include "gui/widgets/BottomBar.hpp"
#include "gui/widgets/Image.hpp"
#include "gui/widgets/Label.hpp"
#include "gui/widgets/TopBar.hpp"
#include "gui/widgets/Window.hpp"
#include <widgets/BoxLayout.hpp>

namespace gui
{

    class DateTimeWindow : public AppWindow
    {
      protected:
        enum class DateTimeItems
        {
            Day,
            Month,
            Year,
            Hour,
            Minute,
        };

        std::map<DateTimeItems, gui::Item *> dateItems;
        std::map<DateTimeItems, gui::Item *> timeItems;

        gui::HBox *dateBody = nullptr;
        gui::HBox *timeBody = nullptr;

        bool dayPeriod      = false; // day period indicator false am, true pm

        gui::Label *addDateTimeItem(Item *parent, const UTF8 &itemTitle, const UTF8 &value);
        gui::Label *addSpacer(const UTF8 &text);
        bool onInput(const InputEvent &inputEvent) override;
        std::string getDateTimeItemValue(DateTimeItems itemType);
        bool setDate(int32_t value);
        bool setTime(int32_t value);
        void setRTC(void);
        bool isEuroTime = false;

      public:
        DateTimeWindow(app::Application *app, bool isEuroTime);

        void onBeforeShow(ShowMode mode, SwitchData *data) override;
        void rebuild() override;
        void buildInterface() override;
        void destroyInterface() override;
        void setEuroTime(bool euroTime);

      private:
        void invalidate() noexcept;
    };
} /* namespace gui */