M image/user/db/settings_v2_002-devel.sql => image/user/db/settings_v2_002-devel.sql +1 -0
@@ 39,6 39,7 @@ INSERT OR IGNORE INTO settings_tab (path, value) VALUES
('\EventManager\\br_auto_mode', '0'),
('\EventManager\\br_level', '50.0f'),
('keypad_light_state', '0'),
+ ('wallpaper_option', '0'),
('gs_current_timezone_name', ''),
('gs_current_timezone_rules', ''),
('\ServiceTime\\gs_automatic_date_and_time_is_on', '1'),
M image/user/db/settings_v2_002.sql => image/user/db/settings_v2_002.sql +1 -0
@@ 40,6 40,7 @@ INSERT OR IGNORE INTO settings_tab (path, value) VALUES
('\EventManager\\br_auto_mode', '0'),
('\EventManager\\br_level', '50.0f'),
('keypad_light_state', '0'),
+ ('wallpaper_option', '0'),
('gs_current_timezone_name', ''),
('gs_current_timezone_rules', ''),
('\ServiceTime\\gs_automatic_date_and_time_is_on', '1'),
M module-apps/application-settings/ApplicationSettings.cpp => module-apps/application-settings/ApplicationSettings.cpp +13 -1
@@ 441,7 441,7 @@ namespace app
return std::make_unique<gui::FontSizeWindow>(app);
});
windowsFactory.attach(gui::window::name::wallpaper, [](ApplicationCommon *app, const std::string &name) {
- return std::make_unique<gui::WallpaperWindow>(app);
+ return std::make_unique<gui::WallpaperWindow>(app, static_cast<ApplicationSettings *>(app));
});
windowsFactory.attach(gui::window::name::quotes, [](ApplicationCommon *app, const std::string &name) {
return std::make_unique<gui::QuotesMainWindow>(app);
@@ 692,6 692,18 @@ namespace app
::settings::SettingsScope::Global);
}
+ auto ApplicationSettings::getWallpaperOption() -> gui::WallpaperOption
+ {
+ return static_cast<gui::WallpaperOption>(utils::getNumericValue<int>(
+ settings->getValue(::settings::Wallpaper::option, ::settings::SettingsScope::Global)));
+ }
+
+ void ApplicationSettings::setWallpaperOption(gui::WallpaperOption option)
+ {
+ settings->setValue(
+ ::settings::Wallpaper::option, std::to_string(static_cast<int>(option)), ::settings::SettingsScope::Global);
+ }
+
auto ApplicationSettings::getNotificationsWhenLocked() const noexcept -> bool
{
return notificationsWhenLocked;
M module-apps/application-settings/CMakeLists.txt => module-apps/application-settings/CMakeLists.txt +1 -0
@@ 17,6 17,7 @@ target_sources(application-settings
models/display-keypad/CategoriesModel.cpp
models/display-keypad/QuotesModel.cpp
models/display-keypad/DisplayModeModel.cpp
+ models/display-keypad/WallpaperOptionModel.cpp
models/network/ApnSettingsModel.cpp
models/network/NewApnModel.cpp
models/network/SimContactsImportModel.cpp
A module-apps/application-settings/data/WallpaperOption.hpp => module-apps/application-settings/data/WallpaperOption.hpp +14 -0
@@ 0,0 1,14 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+namespace gui
+{
+ enum class WallpaperOption
+ {
+ Clock = 0,
+ Quote,
+ Logo
+ };
+} // namespace gui
M module-apps/application-settings/include/application-settings/ApplicationSettings.hpp => module-apps/application-settings/include/application-settings/ApplicationSettings.hpp +13 -0
@@ 12,6 12,7 @@
#include <service-evtmgr/screen-light-control/ScreenLightControl.hpp>
#include <EventStore.hpp>
#include <application-settings/models/bluetooth/BluetoothSettingsModel.hpp>
+#include <application-settings/data/WallpaperOption.hpp>
class AudioStopNotification; // Forward declaration
@@ 64,6 65,14 @@ namespace app
virtual void setKeypadBacklightState(bsp::keypad_backlight::State state) = 0;
};
+ class WallpaperSettings
+ {
+ public:
+ virtual ~WallpaperSettings() = default;
+ virtual auto getWallpaperOption() -> gui::WallpaperOption = 0;
+ virtual void setWallpaperOption(gui::WallpaperOption option) = 0;
+ };
+
class DndSettings
{
public:
@@ 111,6 120,7 @@ namespace app
public settingsInterface::OperatorsSettings,
public settingsInterface::ScreenLightSettings,
public settingsInterface::KeypdBacklightSettings,
+ public settingsInterface::WallpaperSettings,
public settingsInterface::DndSettings,
public settingsInterface::OfflineSettings,
public settingsInterface::ConnectionSettings,
@@ 155,6 165,9 @@ namespace app
auto getKeypadBacklightState() -> bsp::keypad_backlight::State override;
void setKeypadBacklightState(bsp::keypad_backlight::State keypadLightState) override;
+ auto getWallpaperOption() -> gui::WallpaperOption override;
+ void setWallpaperOption(gui::WallpaperOption option) override;
+
auto getNotificationsWhenLocked() const noexcept -> bool override;
void setNotificationsWhenLocked(bool on) noexcept override;
auto getCallsFromFavourite() const noexcept -> bool override;
A module-apps/application-settings/models/display-keypad/WallpaperOptionModel.cpp => module-apps/application-settings/models/display-keypad/WallpaperOptionModel.cpp +31 -0
@@ 0,0 1,31 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "WallpaperOptionModel.hpp"
+
+namespace gui
+{
+ WallpaperOptionModel::WallpaperOptionModel(app::settingsInterface::WallpaperSettings *settings) : settings(settings)
+ {}
+
+ void WallpaperOptionModel::update()
+ {
+ wallpaperOption = settings->getWallpaperOption();
+ }
+
+ void WallpaperOptionModel::saveValue(WallpaperOption option)
+ {
+ settings->setWallpaperOption(option);
+ wallpaperOption = option;
+ }
+
+ auto WallpaperOptionModel::isCurrentOption(WallpaperOption option) -> bool
+ {
+ return wallpaperOption == option;
+ }
+
+ auto WallpaperOptionModel::isQuoteOptionSelected() -> bool
+ {
+ return wallpaperOption == WallpaperOption::Quote;
+ }
+} // namespace gui
A module-apps/application-settings/models/display-keypad/WallpaperOptionModel.hpp => module-apps/application-settings/models/display-keypad/WallpaperOptionModel.hpp +23 -0
@@ 0,0 1,23 @@
+// 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 <application-settings/ApplicationSettings.hpp>
+
+namespace gui
+{
+ class WallpaperOptionModel
+ {
+ public:
+ explicit WallpaperOptionModel(app::settingsInterface::WallpaperSettings *settings);
+ void update();
+ void saveValue(WallpaperOption option);
+ auto isCurrentOption(WallpaperOption option) -> bool;
+ auto isQuoteOptionSelected() -> bool;
+
+ private:
+ app::settingsInterface::WallpaperSettings *settings = nullptr;
+ WallpaperOption wallpaperOption = WallpaperOption::Clock;
+ };
+} // namespace gui
M module-apps/application-settings/windows/display-keypad/DisplayAndKeypadWindow.cpp => module-apps/application-settings/windows/display-keypad/DisplayAndKeypadWindow.cpp +1 -1
@@ 59,8 59,8 @@ namespace gui
addMenu(utils::translate("app_settings_display_display_light"), gui::window::name::display_light);
#if DISABLED_SETTINGS_OPTIONS == 1
addMenu(utils::translate("app_settings_display_font_size"), gui::window::name::font_size);
- addMenu(utils::translate("app_settings_display_wallpaper"), gui::window::name::wallpaper);
#endif // DISABLED_SETTINGS_OPTIONS
+ addMenu(utils::translate("app_settings_display_wallpaper"), gui::window::name::wallpaper);
addMenu(utils::translate("app_settings_display_keypad_light"), gui::window::name::keypad_light);
addMenu(utils::translate("app_settings_display_input_language"), gui::window::name::input_language);
addOnOffOption(utils::translate("app_settings_display_dark_mode"), [this](gui::Item & /*item*/) {
M module-apps/application-settings/windows/display-keypad/WallpaperWindow.cpp => module-apps/application-settings/windows/display-keypad/WallpaperWindow.cpp +22 -18
@@ 9,7 9,18 @@
namespace gui
{
- WallpaperWindow::WallpaperWindow(app::ApplicationCommon *app) : BaseSettingsWindow(app, window::name::wallpaper)
+
+ namespace
+ {
+ const std::vector<std::pair<std::string, WallpaperOption>> wallpaperOptions = {
+ {"app_settings_display_wallpaper_logo", WallpaperOption::Logo},
+ {"app_settings_display_wallpaper_clock", WallpaperOption::Clock},
+ {"app_settings_display_wallpaper_quotes", WallpaperOption::Quote}};
+ } // namespace
+
+ WallpaperWindow::WallpaperWindow(app::ApplicationCommon *app, app::settingsInterface::WallpaperSettings *settings)
+ : BaseSettingsWindow(app, window::name::wallpaper), optionModel{
+ std::make_unique<WallpaperOptionModel>(settings)}
{
setTitle(utils::translate("app_settings_display_wallpaper"));
}
@@ 18,11 29,12 @@ namespace gui
{
std::list<gui::Option> optionsList;
- auto addCheckOption = [&](UTF8 text, bool &Switch) {
+ for (const auto &[text, option] : wallpaperOptions) {
optionsList.emplace_back(std::make_unique<gui::option::OptionSettings>(
- text,
+ utils::translate(text),
[&](gui::Item &item) mutable {
- switchHandler(Switch);
+ optionModel->saveValue(option);
+ refreshOptionsList();
return true;
},
[=](gui::Item &item) {
@@ 32,14 44,11 @@ namespace gui
return true;
},
this,
- Switch ? gui::option::SettingRightItem::Checked : gui::option::SettingRightItem::Disabled));
- };
-
- addCheckOption(utils::translate("app_settings_display_wallpaper_logo"), isWallpaperLogoSwitchOn);
- addCheckOption(utils::translate("app_settings_display_wallpaper_clock"), isWallpaperClockSwitchOn);
- addCheckOption(utils::translate("app_settings_display_wallpaper_quotes"), isWallpaperQuotesSwitchOn);
+ optionModel->isCurrentOption(option) ? gui::option::SettingRightItem::Checked
+ : gui::option::SettingRightItem::Disabled));
+ }
- if (isWallpaperQuotesSwitchOn) {
+ if (optionModel->isQuoteOptionSelected()) {
optionsList.emplace_back(std::make_unique<gui::option::OptionSettings>(
utils::translate("app_settings_display_wallpaper_edit_quotes"),
[=](gui::Item &item) {
@@ 59,14 68,9 @@ namespace gui
return optionsList;
}
- void WallpaperWindow::switchHandler(bool &optionSwitch)
+ void WallpaperWindow::onBeforeShow(ShowMode mode, SwitchData *data)
{
- isWallpaperQuotesSwitchOn = false;
- isWallpaperClockSwitchOn = false;
- isWallpaperLogoSwitchOn = false;
-
- optionSwitch = !optionSwitch;
+ optionModel->update();
refreshOptionsList();
}
-
} // namespace gui
M module-apps/application-settings/windows/display-keypad/WallpaperWindow.hpp => module-apps/application-settings/windows/display-keypad/WallpaperWindow.hpp +4 -6
@@ 4,6 4,7 @@
#pragma once
#include <application-settings/windows/BaseSettingsWindow.hpp>
+#include <application-settings/models/display-keypad/WallpaperOptionModel.hpp>
namespace gui
{
@@ 12,16 13,13 @@ namespace gui
class WallpaperWindow : public BaseSettingsWindow
{
public:
- explicit WallpaperWindow(app::ApplicationCommon *app);
+ explicit WallpaperWindow(app::ApplicationCommon *app, app::settingsInterface::WallpaperSettings *settings);
private:
- void switchHandler(bool &onOffSwitch);
auto buildOptionsList() -> std::list<Option> override;
+ void onBeforeShow(ShowMode mode, SwitchData *data) override;
- bool isWallpaperLogoSwitchOn = false;
- bool isWallpaperClockSwitchOn = false;
- bool isWallpaperQuotesSwitchOn = false;
-
+ std::unique_ptr<WallpaperOptionModel> optionModel;
Item *quotes;
};
} // namespace gui
M module-services/service-db/agents/settings/SystemSettings.hpp => module-services/service-db/agents/settings/SystemSettings.hpp +5 -0
@@ 68,6 68,11 @@ namespace settings
constexpr inline auto state = "keypad_light_state";
} // namespace KeypadLight
+ namespace Wallpaper
+ {
+ constexpr inline auto option = "wallpaper_option";
+ } // namespace Wallpaper
+
namespace Display
{
constexpr inline auto invertedMode = "display_inverted_mode";