From d7c961ea4f9d4a02f6b90e605aeac8b3ddc93ee0 Mon Sep 17 00:00:00 2001 From: gullradriel <3157857+gullradriel@users.noreply.github.com> Date: Sun, 8 Oct 2023 22:21:00 +0200 Subject: [PATCH] Fixing empty output file/store button/text display (#1475) --- firmware/application/apps/ui_recon.cpp | 57 ++++++++++++-------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/firmware/application/apps/ui_recon.cpp b/firmware/application/apps/ui_recon.cpp index 37d30f21..6b87a3c0 100644 --- a/firmware/application/apps/ui_recon.cpp +++ b/firmware/application/apps/ui_recon.cpp @@ -103,7 +103,6 @@ void ReconView::reset_indexes() { void ReconView::update_description() { if (frequency_list.empty() || current_entry().description.empty()) { description = "...no description..."; - return; } else { switch (current_entry().type) { case freqman_type::Range: @@ -117,7 +116,6 @@ void ReconView::update_description() { } description += current_entry().description; } - desc_cycle.set(description); } @@ -539,7 +537,7 @@ ReconView::ReconView(NavigationView& nav) button_scanner_mode.set_style(&Styles::white); button_scanner_mode.set_text("MANUAL"); file_name.set_style(&Styles::white); - file_name.set("MANUAL RANGE RECON"); + file_name.set("MANUAL => " + output_file); desc_cycle.set_style(&Styles::white); last_entry.modulation = freqman_invalid_index; @@ -608,12 +606,12 @@ ReconView::ReconView(NavigationView& nav) scanner_mode = false; button_scanner_mode.set_style(&Styles::blue); button_scanner_mode.set_text("RECON"); - button_remove.set_text("DELETE"); + button_remove.set_text("REMOVE"); } else { scanner_mode = true; button_scanner_mode.set_style(&Styles::red); button_scanner_mode.set_text("SCAN"); - button_scanner_mode.set_text("REMOVE"); + button_remove.set_text("DELETE"); } frequency_file_load(true); if (autostart) { @@ -621,12 +619,16 @@ ReconView::ReconView(NavigationView& nav) } else { recon_pause(); } + button_add.hidden(scanner_mode); + set_dirty(); }; button_config.on_select = [this, &nav](Button&) { if (is_recording) // disabling config while recording return; + clear_freqlist_for_ui_action(); + freq_lock = 0; timer = 0; auto open_view = nav.push(input_file, output_file); @@ -733,30 +735,22 @@ void ReconView::frequency_file_load(bool) { button_scanner_mode.set_text("RECON"); } + file_name.set(file_input + "=>" + output_file); + freqman_load_options options{ .load_freqs = load_freqs, .load_ranges = load_ranges, .load_hamradios = load_hamradios}; - if (!load_freqman_file(file_input, frequency_list, options)) { + if (!load_freqman_file(file_input, frequency_list, options) || frequency_list.empty()) { file_name.set_style(&Styles::red); - desc_cycle.set(" NO " + file_input + ".TXT FILE ..."); - file_name.set("=> NO DATA"); - } else { - file_name.set(file_input + "=>" + output_file); - if (frequency_list.size() == 0) { - file_name.set_style(&Styles::red); - desc_cycle.set("/0 no entries in list"); - file_name.set("BadOrEmpty " + file_input); - } else { - if (frequency_list.size() > FREQMAN_MAX_PER_FILE) { - file_name.set_style(&Styles::yellow); - } - } + desc_cycle.set("...empty file..."); + frequency_list.clear(); + text_cycle.set_text(" "); + return; } - if (frequency_list.empty()) { - text_cycle.set_text(" "); - return; // Can't really do much. + if (frequency_list.size() > FREQMAN_MAX_PER_FILE) { + file_name.set_style(&Styles::yellow); } reset_indexes(); @@ -1214,14 +1208,6 @@ void ReconView::handle_remove_current_item() { if (current_is_valid()) { frequency_list.erase(frequency_list.begin() + current_index); } - - if (frequency_list.size() > 0) { - current_index = clip(current_index, 0u, frequency_list.size() - 1); - text_cycle.set_text(to_string_dec_uint(current_index + 1, 3)); - update_description(); - } else { - current_index = 0; - } } // In Scanner or Manual mode, remove the entry from the output file. @@ -1232,6 +1218,17 @@ void ReconView::handle_remove_current_item() { freq_db.delete_entry(entry); } + + // Clip + if (frequency_list.size() > 0) { + current_index = clip(current_index, 0u, frequency_list.size() - 1); + text_cycle.set_text(to_string_dec_uint(current_index + 1, 3)); + } else { + current_index = 0; + text_cycle.set_text(" "); + } + + update_description(); } } /* namespace ui */