Skip to content

Commit

Permalink
Merge pull request #556 from ArjanOnwezen/settings-cancel-button
Browse files Browse the repository at this point in the history
Added cancel button in UI settings.
  • Loading branch information
ArjanOnwezen committed Apr 8, 2022
2 parents 1f27af6 + 8c1593f commit b023290
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 23 deletions.
44 changes: 25 additions & 19 deletions firmware/application/apps/ui_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace ui {
SetDateTimeView::SetDateTimeView(
NavigationView& nav
) {
button_done.on_select = [&nav, this](Button&){
button_save.on_select = [&nav, this](Button&){
const auto model = this->form_collect();
const rtc::RTC new_datetime {
model.year, model.month, model.day,
Expand All @@ -65,7 +65,7 @@ SetDateTimeView::SetDateTimeView(
&field_hour,
&field_minute,
&field_second,
&button_done,
&button_save,
&button_cancel,
});

Expand Down Expand Up @@ -150,7 +150,7 @@ SetRadioView::SetRadioView(
&value_freq_step,
&labels_bias,
&check_bias,
&button_done,
&button_save,
&button_cancel
});

Expand Down Expand Up @@ -200,7 +200,7 @@ SetRadioView::SetRadioView(
EventDispatcher::send_message(message);
};

button_done.on_select = [this, &nav](Button&){
button_save.on_select = [this, &nav](Button&){
const auto model = this->form_collect();
portapack::persistent_memory::set_correction_ppb(model.ppm * 1000);
portapack::persistent_memory::set_clkout_freq(model.freq);
Expand All @@ -210,7 +210,7 @@ SetRadioView::SetRadioView(
}

void SetRadioView::focus() {
button_done.focus();
button_save.focus();
}

void SetRadioView::form_init(const SetFrequencyCorrectionModel& model) {
Expand All @@ -227,15 +227,15 @@ SetFrequencyCorrectionModel SetRadioView::form_collect() {

SetUIView::SetUIView(NavigationView& nav) {
add_children({
//&checkbox_login,
&checkbox_disable_touchscreen,
&checkbox_speaker,
&checkbox_bloff,
&options_bloff,
&checkbox_showsplash,
&checkbox_showclock,
&options_clockformat,
&button_ok
&button_save,
&button_cancel
});

checkbox_disable_touchscreen.set_value(persistent_memory::disable_touchscreen());
Expand All @@ -257,16 +257,14 @@ SetUIView::SetUIView(NavigationView& nav) {
options_clockformat.set_selected_index(0);
}

checkbox_speaker.on_select = [this](Checkbox&, bool v) {
if (v) audio::output::speaker_mute(); //Just mute audio if speaker is disabled

persistent_memory::set_config_speaker(v); //Store Speaker status
//checkbox_speaker.on_select = [this](Checkbox&, bool v) {
// if (v) audio::output::speaker_mute(); //Just mute audio if speaker is disabled
// persistent_memory::set_config_speaker(v); //Store Speaker status
// StatusRefreshMessage message { }; //Refresh status bar with/out speaker
// EventDispatcher::send_message(message);
//};

StatusRefreshMessage message { }; //Refresh status bar with/out speaker
EventDispatcher::send_message(message);
};

button_ok.on_select = [&nav, this](Button&) {
button_save.on_select = [&nav, this](Button&) {
if (checkbox_bloff.value())
persistent_memory::set_config_backlight_timer(options_bloff.selected_index() + 1);
else
Expand All @@ -277,17 +275,25 @@ SetUIView::SetUIView(NavigationView& nav) {
persistent_memory::set_clock_with_date(true);
else
persistent_memory::set_clock_with_date(false);
}
}

if (checkbox_speaker.value()) audio::output::speaker_mute(); //Just mute audio if speaker is disabled
persistent_memory::set_config_speaker(checkbox_speaker.value()); //Store Speaker status
StatusRefreshMessage message { }; //Refresh status bar with/out speaker
EventDispatcher::send_message(message);

persistent_memory::set_config_splash(checkbox_showsplash.value());
persistent_memory::set_clock_hidden(!checkbox_showclock.value());
persistent_memory::set_disable_touchscreen(checkbox_disable_touchscreen.value());
//persistent_memory::set_config_login(checkbox_login.value());
nav.pop();
};
button_cancel.on_select = [&nav, this](Button&) {
nav.pop();
};
}

void SetUIView::focus() {
button_ok.focus();
button_save.focus();
}

SetAudioView::SetAudioView(NavigationView& nav) {
Expand Down
13 changes: 9 additions & 4 deletions firmware/application/apps/ui_settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class SetDateTimeView : public View {
'0',
};

Button button_done {
Button button_save {
{ 2 * 8, 16 * 16, 12 * 8, 32 },
"Save"
};
Expand Down Expand Up @@ -197,7 +197,7 @@ class SetRadioView : public View {
"Turn on bias voltage"
};

Button button_done {
Button button_save {
{ 2 * 8, 16 * 16, 12 * 8, 32 },
"Save"
};
Expand Down Expand Up @@ -272,10 +272,15 @@ class SetUIView : public View {
}
};

Button button_ok {
Button button_save {
{ 2 * 8, 16 * 16, 12 * 8, 32 },
"Save"
};

Button button_cancel {
{ 16 * 8, 16 * 16, 12 * 8, 32 },
"Cancel",
};
};

class SetAudioView : public View {
Expand Down Expand Up @@ -317,7 +322,7 @@ class SetQRCodeView : public View {

void focus() override;

std::string title() const override { return "QR code settings"; };
std::string title() const override { return "QR code"; };

private:
Checkbox checkbox_bigger_qr {
Expand Down

0 comments on commit b023290

Please sign in to comment.