From 58b488b8404747aaef8cbc82ef4de1ead654751d Mon Sep 17 00:00:00 2001 From: Mark Thompson <129641948+NotherNgineer@users.noreply.github.com> Date: Fri, 12 Jan 2024 06:41:13 -0600 Subject: [PATCH] Added new "App Setting" app (#1759) * New "App Settings" app for quicker settings access --- firmware/application/apps/ui_settings.cpp | 30 +++++++++++++++++++++++ firmware/application/apps/ui_settings.hpp | 17 +++++++++++++ 2 files changed, 47 insertions(+) diff --git a/firmware/application/apps/ui_settings.cpp b/firmware/application/apps/ui_settings.cpp index 5b445c7a..56c96eac 100644 --- a/firmware/application/apps/ui_settings.cpp +++ b/firmware/application/apps/ui_settings.cpp @@ -27,6 +27,7 @@ #include "ui_navigation.hpp" #include "ui_receiver.hpp" #include "ui_touch_calibration.hpp" +#include "ui_text_editor.hpp" #include "portapack_persistent_memory.hpp" #include "lpc43xx_cpp.hpp" @@ -628,6 +629,34 @@ void SetEncoderDialView::focus() { button_save.focus(); } +/* AppSettingsView ************************************/ + +AppSettingsView::AppSettingsView( + NavigationView& nav) + : nav_{nav} { + add_children({&labels, + &menu_view}); + + menu_view.set_parent_rect({0, 3 * 8, 240, 33 * 8}); + + ensure_directory(SETTINGS_DIR); + + for (const auto& entry : std::filesystem::directory_iterator(SETTINGS_DIR, u"*.ini")) { + auto path = (std::filesystem::path)SETTINGS_DIR / entry.path(); + + menu_view.add_item({path.filename().string().substr(0, 26), + ui::Color::dark_cyan(), + &bitmap_icon_file_text, + [this, path](KeyEvent) { + nav_.push(path); + }}); + } +} + +void AppSettingsView::focus() { + menu_view.focus(); +} + /* SettingsMenuView **************************************/ SettingsMenuView::SettingsMenuView(NavigationView& nav) { @@ -635,6 +664,7 @@ SettingsMenuView::SettingsMenuView(NavigationView& nav) { add_items({{"..", ui::Color::light_grey(), &bitmap_icon_previous, [&nav]() { nav.pop(); }}}); } add_items({ + {"App Settings", ui::Color::dark_cyan(), &bitmap_icon_notepad, [&nav]() { nav.push(); }}, {"Audio", ui::Color::dark_cyan(), &bitmap_icon_speaker, [&nav]() { nav.push(); }}, {"Calibration", ui::Color::dark_cyan(), &bitmap_icon_options_touch, [&nav]() { nav.push(); }}, {"Converter", ui::Color::dark_cyan(), &bitmap_icon_options_radio, [&nav]() { nav.push(); }}, diff --git a/firmware/application/apps/ui_settings.hpp b/firmware/application/apps/ui_settings.hpp index be9ce532..e3973b0c 100644 --- a/firmware/application/apps/ui_settings.hpp +++ b/firmware/application/apps/ui_settings.hpp @@ -564,6 +564,23 @@ class SetPersistentMemoryView : public View { }; }; +class AppSettingsView : public View { + public: + AppSettingsView(NavigationView& nav); + std::string title() const override { return "App Settings"; }; + void focus() override; + + private: + NavigationView& nav_; + + Labels labels{ + {{0, 4}, "Select file to edit:", Color::white()}}; + + MenuView menu_view{ + {0, 2 * 8, 240, 26 * 8}, + true}; +}; + class SettingsMenuView : public BtnGridView { public: SettingsMenuView(NavigationView& nav);