mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-07-30 10:09:25 -04:00
First pass at custom app-settings support (#1381)
* First draft of custom app settings support. * WIP new settings * Working per-app custom settings * Revert design to use "bound settings"
This commit is contained in:
parent
a4636d7872
commit
63f99742fc
11 changed files with 269 additions and 43 deletions
|
@ -71,6 +71,8 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav)
|
|||
if (!settings_.loaded())
|
||||
field_frequency.set_value(initial_target_frequency);
|
||||
|
||||
check_log.set_value(enable_logging);
|
||||
|
||||
receiver_model.enable();
|
||||
|
||||
// TODO: app setting instead?
|
||||
|
@ -88,7 +90,6 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav)
|
|||
logger->append(LOG_ROOT_DIR "/POCSAG.TXT");
|
||||
|
||||
audio::output::start();
|
||||
|
||||
baseband::set_pocsag();
|
||||
}
|
||||
|
||||
|
@ -99,8 +100,9 @@ void POCSAGAppView::focus() {
|
|||
POCSAGAppView::~POCSAGAppView() {
|
||||
audio::output::stop();
|
||||
|
||||
// Save ignored address
|
||||
// Save settings.
|
||||
persistent_memory::set_pocsag_ignore_address(sym_ignore.value_dec_u32());
|
||||
enable_logging = check_log.value();
|
||||
|
||||
receiver_model.disable();
|
||||
baseband::shutdown();
|
||||
|
|
|
@ -65,7 +65,14 @@ class POCSAGAppView : public View {
|
|||
NavigationView& nav_;
|
||||
RxRadioState radio_state_{};
|
||||
app_settings::SettingsManager settings_{
|
||||
"rx_pocsag", app_settings::Mode::RX};
|
||||
"rx_pocsag",
|
||||
app_settings::Mode::RX};
|
||||
|
||||
// Settings
|
||||
bool enable_logging = false;
|
||||
SettingsStore settings_store_{
|
||||
"rx_pocsag_ui",
|
||||
{{"enable_logging", &enable_logging}}};
|
||||
|
||||
uint32_t last_address = 0xFFFFFFFF;
|
||||
pocsag::POCSAGState pocsag_state{};
|
||||
|
|
|
@ -360,6 +360,8 @@ TextEditorView::TextEditorView(NavigationView& nav)
|
|||
&text_size,
|
||||
});
|
||||
|
||||
viewer.set_font_zoom(enable_zoom);
|
||||
|
||||
viewer.on_select = [this]() {
|
||||
// Treat as if menu button was pressed.
|
||||
if (button_menu.on_select)
|
||||
|
@ -382,7 +384,7 @@ TextEditorView::TextEditorView(NavigationView& nav)
|
|||
};
|
||||
|
||||
menu.on_zoom() = [this]() {
|
||||
viewer.toggle_font_zoom();
|
||||
enable_zoom = viewer.toggle_font_zoom();
|
||||
refresh_ui();
|
||||
hide_menu(true);
|
||||
};
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "ui_styles.hpp"
|
||||
#include "ui_widget.hpp"
|
||||
|
||||
#include "app_settings.hpp"
|
||||
#include "file_wrapper.hpp"
|
||||
#include "optional.hpp"
|
||||
|
||||
|
@ -80,7 +81,10 @@ class TextViewer : public Widget {
|
|||
|
||||
const Style& style() { return *font_style; }
|
||||
void set_font_zoom(bool zoom);
|
||||
void toggle_font_zoom() { set_font_zoom(!font_zoom); };
|
||||
bool toggle_font_zoom() {
|
||||
set_font_zoom(!font_zoom);
|
||||
return font_zoom;
|
||||
};
|
||||
|
||||
private:
|
||||
bool font_zoom{};
|
||||
|
@ -220,6 +224,12 @@ class TextEditorView : public View {
|
|||
void on_show() override;
|
||||
|
||||
private:
|
||||
// Settings
|
||||
bool enable_zoom = false;
|
||||
SettingsStore settings_store_{
|
||||
"notepad",
|
||||
{{"enable_zoom", &enable_zoom}}};
|
||||
|
||||
static constexpr size_t max_edit_length = 1024;
|
||||
std::string edit_line_buffer_{};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue