M image/assets/lang/English.json => image/assets/lang/English.json +2 -0
@@ 581,6 581,8 @@
"app_bell_settings_advanced": "Advanced",
"app_bell_settings_advanced_time_units": "Time & units",
"app_bell_settings_advanced_temp_scale": "Temperature scale",
+ "app_bell_settings_advanced_language": "Language",
+ "app_bell_settings_advanced_language_set": "Language is set",
"app_bell_settings_advanced_about": "About",
"app_bell_settings_advanced_about_product": "Mudita Harmony",
"app_bell_settings_advanced_about_version": "<text>OS version: <token>$VERSION</token></text>",
M module-apps/apps-common/widgets/BellBaseLayout.cpp => module-apps/apps-common/widgets/BellBaseLayout.cpp +6 -0
@@ 117,4 117,10 @@ namespace gui
item->setVisible(isVisible);
}
}
+
+ void BellBaseLayout::setMinMaxArrowsVisibility(bool minCondition, bool maxCondition)
+ {
+ setArrowVisible(BellBaseLayout::Arrow::Left, !minCondition);
+ setArrowVisible(BellBaseLayout::Arrow::Right, !maxCondition);
+ }
} // namespace gui
M module-apps/apps-common/widgets/BellBaseLayout.hpp => module-apps/apps-common/widgets/BellBaseLayout.hpp +1 -0
@@ 48,6 48,7 @@ namespace gui
void resize();
void setArrowVisible(Arrow arrow, bool isVisible);
+ void setMinMaxArrowsVisibility(bool minCondition, bool maxCondition);
private:
HThreeBox<HBox, HBox, HBox> *centerThreeBox{nullptr};
M products/BellHybrid/apps/application-bell-settings/ApplicationBellSettings.cpp => products/BellHybrid/apps/application-bell-settings/ApplicationBellSettings.cpp +22 -0
@@ 18,6 18,7 @@
#include "windows/advanced/AboutYourBellWindow.hpp"
#include "windows/advanced/BellSettingsAdvancedWindow.hpp"
#include "windows/advanced/BellSettingsTimeUnitsWindow.hpp"
+#include "windows/advanced/BellSettingsLanguageWindow.hpp"
#include "windows/alarm_settings/BellSettingsAlarmSettingsMenuWindow.hpp"
#include "windows/alarm_settings/BellSettingsAlarmSettingsSnoozeWindow.hpp"
#include "windows/alarm_settings/BellSettingsAlarmSettingsWindow.hpp"
@@ 33,6 34,7 @@
#include <service-evtmgr/Constants.hpp>
#include <service-evtmgr/EventManagerServiceAPI.hpp>
#include <service-evtmgr/ScreenLightControlMessage.hpp>
+#include <service-appmgr/messages/GetCurrentDisplayLanguageResponse.hpp>
namespace app
{
@@ 51,6 53,20 @@ namespace app
}
createUserInterface();
+ connect(typeid(manager::GetCurrentDisplayLanguageResponse), [&](sys::Message *msg) {
+ if (gui::window::name::bellSettingsLanguage == getCurrentWindow()->getName()) {
+
+ switchWindow(gui::BellFinishedWindow::defaultName,
+ gui::BellFinishedWindowData::Factory::create(
+ "big_check_W_G",
+ utils::translate("app_bell_settings_advanced_language_set"),
+ gui::window::name::bellSettingsAdvanced));
+
+ return sys::msgHandled();
+ }
+ return sys::msgNotHandled();
+ });
+
return sys::ReturnCodes::Success;
}
@@ 76,6 92,12 @@ namespace app
});
windowsFactory.attach(
+ gui::window::name::bellSettingsLanguage, [&](ApplicationCommon *app, const std::string &name) {
+ auto presenter = std::make_unique<bell_settings::LanguageWindowPresenter>(this);
+ return std::make_unique<gui::BellSettingsLanguageWindow>(app, std::move(presenter), name);
+ });
+
+ windowsFactory.attach(
gui::window::name::bellSettingsFrontlight, [](ApplicationCommon *app, const std::string &name) {
auto model =
std::make_shared<bell_settings::FrontlightModel>(app, static_cast<ApplicationBellSettings *>(app));
M products/BellHybrid/apps/application-bell-settings/CMakeLists.txt => products/BellHybrid/apps/application-bell-settings/CMakeLists.txt +4 -0
@@ 38,6 38,7 @@ target_sources(application-bell-settings
presenter/FrontlightPresenter.cpp
presenter/TimeUnitsPresenter.cpp
presenter/advanced/AboutYourBellWindowPresenter.cpp
+ presenter/advanced/LanguageWindowPresenter.cpp
presenter/alarm_settings/AlarmSettingsPresenter.cpp
presenter/alarm_settings/PrewakeUpPresenter.cpp
presenter/alarm_settings/SnoozePresenter.cpp
@@ 55,6 56,7 @@ target_sources(application-bell-settings
windows/BellSettingsWindow.cpp
windows/advanced/AboutYourBellWindow.cpp
windows/advanced/BellSettingsAdvancedWindow.cpp
+ windows/advanced/BellSettingsLanguageWindow.cpp
windows/advanced/BellSettingsTimeUnitsWindow.cpp
windows/alarm_settings/BellSettingsAlarmSettingsSnoozeWindow.cpp
windows/alarm_settings/BellSettingsAlarmSettingsMenuWindow.cpp
@@ 76,6 78,7 @@ target_sources(application-bell-settings
presenter/FrontlightPresenter.hpp
presenter/advanced/AboutYourBellWindowPresenter.hpp
+ presenter/advanced/LanguageWindowPresenter.hpp
presenter/alarm_settings/AlarmSettingsPresenter.hpp
presenter/alarm_settings/PrewakeUpPresenter.hpp
presenter/alarm_settings/SnoozePresenter.hpp
@@ 95,6 98,7 @@ target_sources(application-bell-settings
windows/BellSettingsTurnOffWindow.hpp
windows/BellSettingsWindow.hpp
windows/advanced/AboutYourBellWindow.hpp
+ windows/advanced/BellSettingsLanguageWindow.hpp
windows/advanced/BellSettingsAdvancedWindow.hpp
windows/alarm_settings/BellSettingsAlarmSettingsSnoozeWindow.hpp
windows/alarm_settings/BellSettingsAlarmSettingsMenuWindow.hpp
M products/BellHybrid/apps/application-bell-settings/include/application-bell-settings/ApplicationBellSettings.hpp => products/BellHybrid/apps/application-bell-settings/include/application-bell-settings/ApplicationBellSettings.hpp +10 -9
@@ 8,15 8,16 @@
namespace gui::window::name
{
- inline constexpr auto bellSettings = "BellSettings";
- inline constexpr auto bellSettingsAdvanced = "BellSettingsAdvanced";
- inline constexpr auto bellSettingsTimeUnits = "BellSettingsTimeUnits";
- inline constexpr auto bellSettingsDialog = "BellSettingsDialog";
- inline constexpr auto bellSettingsFinished = "BellSettingsFinished";
- inline constexpr auto bellSettingsFrontlight = "BellSettingsFrontlight";
- inline constexpr auto bellSettingsHomeView = "BellSettingsHomeView";
- inline constexpr auto bellSettingsBedtimeTone = "BellSettingsBedtimeTone";
- inline constexpr auto bellSettingsTurnOff = "BellSettingsTurnOff";
+ inline constexpr auto bellSettings = "BellSettings";
+ inline constexpr auto bellSettingsAdvanced = "BellSettingsAdvanced";
+ inline constexpr auto bellSettingsTimeUnits = "BellSettingsTimeUnits";
+ inline constexpr auto bellSettingsDialog = "BellSettingsDialog";
+ inline constexpr auto bellSettingsFinished = "BellSettingsFinished";
+ inline constexpr auto bellSettingsFrontlight = "BellSettingsFrontlight";
+ inline constexpr auto bellSettingsHomeView = "BellSettingsHomeView";
+ inline constexpr auto bellSettingsLanguage = "BellSettingsLanguage";
+ inline constexpr auto bellSettingsBedtimeTone = "BellSettingsBedtimeTone";
+ inline constexpr auto bellSettingsTurnOff = "BellSettingsTurnOff";
} // namespace gui::window::name
namespace app
A products/BellHybrid/apps/application-bell-settings/presenter/advanced/LanguageWindowPresenter.cpp => products/BellHybrid/apps/application-bell-settings/presenter/advanced/LanguageWindowPresenter.cpp +26 -0
@@ 0,0 1,26 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "LanguageWindowPresenter.hpp"
+#include <service-appmgr/Controller.hpp>
+
+namespace app::bell_settings
+{
+ LanguageWindowPresenter::LanguageWindowPresenter(app::ApplicationCommon *app) : app(app)
+ {}
+
+ std::vector<std::string> LanguageWindowPresenter::getLanguages() const
+ {
+ return loader.getAvailableDisplayLanguages();
+ }
+
+ std::string LanguageWindowPresenter::getSelectedLanguage() const
+ {
+ return utils::getDisplayLanguage();
+ }
+
+ void LanguageWindowPresenter::setLanguage(const std::string &selectedLanguage)
+ {
+ app::manager::Controller::changeDisplayLanguage(app, selectedLanguage);
+ }
+} // namespace app::bell_settings
A products/BellHybrid/apps/application-bell-settings/presenter/advanced/LanguageWindowPresenter.hpp => products/BellHybrid/apps/application-bell-settings/presenter/advanced/LanguageWindowPresenter.hpp +46 -0
@@ 0,0 1,46 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <apps-common/BasePresenter.hpp>
+#include <apps-common/ApplicationCommon.hpp>
+#include <i18n/i18n.hpp>
+
+#include <vector>
+#include <string>
+
+namespace app::bell_settings
+{
+ class LanguageWindowContract
+ {
+ public:
+ class View
+ {
+ public:
+ virtual ~View() = default;
+ };
+
+ class Presenter : public BasePresenter<LanguageWindowContract::View>
+ {
+ public:
+ virtual std::vector<std::string> getLanguages() const = 0;
+ virtual std::string getSelectedLanguage() const = 0;
+ virtual void setLanguage(const std::string &selectedLanguage) = 0;
+ };
+ };
+
+ class LanguageWindowPresenter : public LanguageWindowContract::Presenter
+ {
+ private:
+ utils::LangLoader loader;
+ app::ApplicationCommon *app{};
+
+ public:
+ explicit LanguageWindowPresenter(app::ApplicationCommon *app);
+
+ std::vector<std::string> getLanguages() const override;
+ std::string getSelectedLanguage() const override;
+ void setLanguage(const std::string &selectedLanguage) override;
+ };
+} // namespace app::bell_settings
M products/BellHybrid/apps/application-bell-settings/windows/advanced/BellSettingsAdvancedWindow.cpp => products/BellHybrid/apps/application-bell-settings/windows/advanced/BellSettingsAdvancedWindow.cpp +2 -0
@@ 45,6 45,8 @@ namespace gui
addWinSettings(utils::translate("app_bell_settings_advanced_time_units"),
gui::window::name::bellSettingsTimeUnits);
+ addWinSettings(utils::translate("app_bell_settings_advanced_language"),
+ gui::window::name::bellSettingsLanguage);
addWinSettings(utils::translate("app_bell_settings_advanced_frontlight"),
gui::window::name::bellSettingsFrontlight);
addWinSettings(utils::translate("app_bell_settings_advanced_about"), gui::AboutYourBellWindow::name);
A products/BellHybrid/apps/application-bell-settings/windows/advanced/BellSettingsLanguageWindow.cpp => products/BellHybrid/apps/application-bell-settings/windows/advanced/BellSettingsLanguageWindow.cpp +67 -0
@@ 0,0 1,67 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "BellSettingsLanguageWindow.hpp"
+#include <common/options/OptionBellMenu.hpp>
+
+namespace gui
+{
+ BellSettingsLanguageWindow::BellSettingsLanguageWindow(
+ app::ApplicationCommon *app,
+ std::unique_ptr<app::bell_settings::LanguageWindowPresenter::Presenter> &&presenter,
+ const std::string &name)
+ : AppWindow(app, name), presenter{std::move(presenter)}
+ {
+ this->presenter->attach(this);
+ buildInterface();
+ }
+
+ void BellSettingsLanguageWindow::buildInterface()
+ {
+ AppWindow::buildInterface();
+
+ statusBar->setVisible(false);
+ header->setTitleVisibility(false);
+ bottomBar->setVisible(false);
+
+ body = new BellBaseLayout(this, 0, 0, style::window_width, style::window_height, true);
+
+ auto topMessage = new TextFixedSize(body->firstBox);
+ topMessage->setMaximumSize(style::bell_base_layout::w, style::bell_base_layout::outer_layouts_h);
+ topMessage->setFont(style::window::font::largelight);
+ topMessage->setEdges(gui::RectangleEdge::None);
+ topMessage->activeItem = false;
+ topMessage->setAlignment(Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
+ topMessage->setText(utils::translate("app_bell_settings_advanced_language"));
+ topMessage->drawUnderline(false);
+
+ auto data = presenter->getLanguages();
+ spinner = new UTF8Spinner({data.begin(), data.end()}, Boundaries::Fixed);
+ spinner->setMaximumSize(style::bell_base_layout::w, style::bell_base_layout::center_layout_h);
+ spinner->setFont(style::window::font::large);
+ spinner->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center));
+ spinner->setFocusEdges(RectangleEdge::None);
+ spinner->setCurrentValue(presenter->getSelectedLanguage());
+ body->getCenterBox()->addWidget(spinner);
+
+ setFocusItem(spinner);
+ body->resize();
+ }
+
+ bool BellSettingsLanguageWindow::onInput(const InputEvent &inputEvent)
+ {
+ if (spinner->onInput(inputEvent)) {
+ auto selectedLanguage = spinner->getCurrentValue();
+
+ body->setMinMaxArrowsVisibility(selectedLanguage == presenter->getLanguages().back(),
+ selectedLanguage == presenter->getLanguages().front());
+ return true;
+ }
+ else if (inputEvent.isShortRelease(KeyCode::KEY_ENTER)) {
+ presenter->setLanguage(spinner->getCurrentValue());
+ return true;
+ }
+ return AppWindow::onInput(inputEvent);
+ }
+
+} // namespace gui
A products/BellHybrid/apps/application-bell-settings/windows/advanced/BellSettingsLanguageWindow.hpp => products/BellHybrid/apps/application-bell-settings/windows/advanced/BellSettingsLanguageWindow.hpp +32 -0
@@ 0,0 1,32 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <presenter/advanced/LanguageWindowPresenter.hpp>
+#include <ApplicationBellSettings.hpp>
+
+#include <apps-common/widgets/spinners/Spinners.hpp>
+#include <widgets/BellBaseLayout.hpp>
+
+#include <AppWindow.hpp>
+
+namespace gui
+{
+ class BellSettingsLanguageWindow : public AppWindow, public app::bell_settings::LanguageWindowContract::View
+ {
+ public:
+ BellSettingsLanguageWindow(app::ApplicationCommon *app,
+ std::unique_ptr<app::bell_settings::LanguageWindowPresenter::Presenter> &&presenter,
+ const std::string &name = gui::window::name::bellSettingsLanguage);
+
+ void buildInterface() override;
+ bool onInput(const gui::InputEvent &inputEvent) override;
+
+ private:
+ std::unique_ptr<app::bell_settings::LanguageWindowPresenter::Presenter> presenter;
+
+ BellBaseLayout *body{};
+ UTF8Spinner *spinner = nullptr;
+ };
+} // namespace gui