mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-07-21 05:24:22 -04:00
Due to vfs deprecation there is need to remove all vfs calls from code. This PR covers module gui. There are some modifications in other modules included which are necessary because of build system issues.
98 lines
2.9 KiB
C++
98 lines
2.9 KiB
C++
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#include "LockedInfoWindow.hpp"
|
|
|
|
#include "service-appmgr/Controller.hpp"
|
|
#include "gui/widgets/BottomBar.hpp"
|
|
#include "gui/widgets/TopBar.hpp"
|
|
#include "RichTextParser.hpp"
|
|
#include "FontManager.hpp"
|
|
|
|
#include "application-desktop/data/AppDesktopStyle.hpp"
|
|
#include "Names.hpp"
|
|
|
|
#include <application-phonebook/ApplicationPhonebook.hpp>
|
|
#include <i18n/i18n.hpp>
|
|
|
|
using namespace gui;
|
|
|
|
LockedInfoWindow::LockedInfoWindow(app::Application *app) : AppWindow(app, app::window::name::desktop_locked)
|
|
{
|
|
buildInterface();
|
|
}
|
|
|
|
void LockedInfoWindow::onBeforeShow(ShowMode mode, SwitchData *data)
|
|
{
|
|
setVisibleState();
|
|
}
|
|
|
|
void LockedInfoWindow::setVisibleState()
|
|
{
|
|
lockImage->setVisible(true);
|
|
|
|
bottomBar->setActive(BottomBar::Side::LEFT, true);
|
|
bottomBar->setActive(BottomBar::Side::CENTER, false);
|
|
bottomBar->setActive(BottomBar::Side::RIGHT, true);
|
|
|
|
topBar->setActive(TopBar::Elements::LOCK, true);
|
|
topBar->setActive(TopBar::Elements::BATTERY, true);
|
|
topBar->setActive(TopBar::Elements::SIGNAL, true);
|
|
}
|
|
|
|
bool LockedInfoWindow::onInput(const InputEvent &inputEvent)
|
|
{
|
|
if (inputEvent.isShortPress()) {
|
|
if (inputEvent.keyCode == KeyCode::KEY_LF && bottomBar->isActive(BottomBar::Side::LEFT)) {
|
|
app::manager::Controller::sendAction(application, app::manager::actions::ShowEmergencyContacts);
|
|
return true;
|
|
}
|
|
else if (inputEvent.keyCode == KeyCode::KEY_RF && bottomBar->isActive(BottomBar::Side::RIGHT)) {
|
|
application->switchWindow(gui::name::window::main_window);
|
|
return true;
|
|
}
|
|
}
|
|
return AppWindow::onInput(inputEvent);
|
|
}
|
|
|
|
void LockedInfoWindow::rebuild()
|
|
{
|
|
destroyInterface();
|
|
buildInterface();
|
|
}
|
|
|
|
void LockedInfoWindow::buildInterface()
|
|
{
|
|
namespace lock_style = style::window::pin_lock;
|
|
AppWindow::buildInterface();
|
|
|
|
bottomBar->setText(BottomBar::Side::LEFT, utils::localize.get("app_desktop_emergency"));
|
|
bottomBar->setText(BottomBar::Side::RIGHT, utils::localize.get("common_back"));
|
|
|
|
lockImage = new gui::Image(this, lock_style::image::x, lock_style::image::y, 0, 0, "pin_lock");
|
|
infoText = new Text(this,
|
|
lock_style::primary_text::x,
|
|
lock_style::primary_text::y,
|
|
lock_style::primary_text::w,
|
|
lock_style::primary_text::h);
|
|
|
|
TextFormat format(FontManager::getInstance().getFont(style::window::font::medium));
|
|
text::RichTextParser rtParser;
|
|
auto parsedText = rtParser.parse(utils::localize.get("app_desktop_press_to_unlock"), &format);
|
|
|
|
infoText->setText(std::move(parsedText));
|
|
infoText->setAlignment(Alignment::Horizontal::Center);
|
|
}
|
|
|
|
void LockedInfoWindow::destroyInterface()
|
|
{
|
|
erase();
|
|
invalidate();
|
|
}
|
|
|
|
void LockedInfoWindow::invalidate() noexcept
|
|
{
|
|
lockImage = nullptr;
|
|
infoText = nullptr;
|
|
}
|