~aleteoryx/muditaos

ref: c2cd94a6f2aa3f54ba0559928a5f21e4fc042584 muditaos/module-apps/application-settings/windows/EinkModeWindow.cpp -rw-r--r-- 1.9 KiB
c2cd94a6 — KacperLewandowski [EGD-4417] Fix operations in calculator 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
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <memory>
#include <functional>

#include "Common.hpp"
#include "service-eink/Common.hpp"
#include "messages/EinkModeMessage.hpp"
#include "service-appmgr/Controller.hpp"
#include "../ApplicationSettings.hpp"

#include <i18n/i18n.hpp>

#include "Label.hpp"
#include "Margins.hpp"
#include "EinkModeWindow.hpp"
#include <Style.hpp>

namespace gui
{

    EinkModeWindow::EinkModeWindow(app::Application *app) : AppWindow(app, window::name::eink)
    {
        AppWindow::buildInterface();
        bottomBar->setActive(BottomBar::Side::CENTER, true);
        bottomBar->setActive(BottomBar::Side::RIGHT, true);
        bottomBar->setText(BottomBar::Side::CENTER, utils::localize.get(style::strings::common::select));
        bottomBar->setText(BottomBar::Side::RIGHT, utils::localize.get(style::strings::common::back));
        topBar->setActive(TopBar::Elements::SIGNAL, true);
        topBar->setActive(TopBar::Elements::BATTERY, true);

        setTitle("Change eink mode");
        auto label               = new Label(this, 100, 200, 300, 50, "Change mode on click");
        label->activatedCallback = [this](Item &) -> bool {
            static auto last_mode = service::eink::EinkModeMessage::Mode::Normal;
            if (last_mode == service::eink::EinkModeMessage::Mode::Normal) {
                last_mode = service::eink::EinkModeMessage::Mode::Invert;
            }
            else {
                last_mode = service::eink::EinkModeMessage::Mode::Normal;
            }

            sys::Bus::SendUnicast(std::make_shared<service::eink::EinkModeMessage>(last_mode),
                                  service::name::eink,
                                  this->application,
                                  5000);
            return true;
        };
        setFocusItem(label);
    }

} /* namespace gui */