~aleteoryx/muditaos

ref: 6cd0fd35e889cbdd8ebaa15622cd66ea26f423a8 muditaos/module-gui/gui/widgets/TopBar/BatteryWidgetText.cpp -rw-r--r-- 1.2 KiB
6cd0fd35 — Alek Rudnik [EGD-5777] Refactored status bar battery indicator 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
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "BatteryWidgetText.hpp"
#include "Label.hpp"
#include <Utils.hpp>
#include <Style.hpp>

namespace gui
{
    BatteryWidgetText::BatteryWidgetText(Item *parent, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
        : BatteryWidgetBase(parent, x, y, w, h)
    {
        label = new Label(this, 0, 0, 0, 0);
        label->setFilled(false);
        label->setBorderColor(gui::ColorNoColor);
        label->setFont(style::header::font::modes);
        label->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center));
        label->setMaximumSize(this->getWidth(), this->getHeight());
    }

    void BatteryWidgetText::showBatteryLevel(std::uint32_t percentage)
    {
        label->setText(utils::to_string(percentage) + " %");
    }

    void BatteryWidgetText::showBatteryCharging()
    {
        label->setText(utils::localize.get("topbar_battery_charging"));
    }

    void BatteryWidgetText::showBatteryPluggedNotCharging()
    {
        label->setText(utils::localize.get("topbar_battery_plugged"));
    }

} // namespace gui