diff --git a/core/src/gui/menus/module_manager.cpp b/core/src/gui/menus/module_manager.cpp index aba181d9..9e38294a 100644 --- a/core/src/gui/menus/module_manager.cpp +++ b/core/src/gui/menus/module_manager.cpp @@ -3,13 +3,15 @@ #include #include #include +#include namespace module_manager_menu { char modName[1024]; std::vector modTypes; - std::vector toBeRemoved; + std::string toBeRemoved; std::string modTypesTxt; int modTypeId; + bool confirmOpened = false; void init() { modName[0] = 0; @@ -35,8 +37,6 @@ namespace module_manager_menu { float height = ImGui::CalcTextSize("-").y; - toBeRemoved.clear(); - for (auto& [name, inst] : core::moduleManager.instances) { ImGui::TableNextRow(); @@ -50,19 +50,21 @@ namespace module_manager_menu { ImVec2 origPos = ImGui::GetCursorPos(); ImGui::SetCursorPos(ImVec2(origPos.x - 3, origPos.y)); if (ImGui::Button(("##module_mgr_"+name).c_str(), ImVec2(height,height))) { - toBeRemoved.push_back(name); - modified = true; + toBeRemoved = name; + confirmOpened = true; } ImGui::SetCursorPos(ImVec2(origPos.x + 2, origPos.y - 5)); ImGui::Text("_"); } ImGui::EndTable(); - - for (auto& rem : toBeRemoved) { - core::moduleManager.deleteInstance(rem); - } } - + + if (ImGui::GenericDialog("module_mgr_confirm_", confirmOpened, GENERIC_DIALOG_BUTTONS_YES_NO, [](){ + ImGui::Text("Deleting \"%s\". Are you sure?", toBeRemoved.c_str()); + }) == GENERIC_DIALOG_BUTTON_YES) { + core::moduleManager.deleteInstance(toBeRemoved); + modified = true; + } // Add module row with slightly different settings ImGui::BeginTable("Module Manager Add Table", 3); diff --git a/misc_modules/frequency_manager/src/main.cpp b/misc_modules/frequency_manager/src/main.cpp index ac709424..4de26024 100644 --- a/misc_modules/frequency_manager/src/main.cpp +++ b/misc_modules/frequency_manager/src/main.cpp @@ -12,6 +12,7 @@ #include #include #include +#include SDRPP_MOD_INFO { /* Name: */ "frequency_manager", @@ -391,7 +392,14 @@ private: ImGui::SameLine(); if (_this->selectedListName == "") { style::beginDisabled(); } if (ImGui::Button(("-##_freq_mgr_del_lst_" + _this->name).c_str(), ImVec2(lineHeight, 0))) { - if (_this->selectedListName == "") { style::endDisabled(); } + _this->deleteListOpen = true; + } + if (_this->selectedListName == "") { style::endDisabled(); } + + // List delete confirmation + if (ImGui::GenericDialog(("freq_manager_del_list_confirm"+_this->name).c_str(), _this->deleteListOpen, GENERIC_DIALOG_BUTTONS_YES_NO, [_this](){ + ImGui::Text("Deleting list named \"%s\". Are you sure?", _this->selectedListName.c_str()); + }) == GENERIC_DIALOG_BUTTON_YES) { config.acquire(); config.conf["lists"].erase(_this->selectedListName); _this->refreshWaterfallBookmarks(false); @@ -405,9 +413,6 @@ private: _this->selectedListName = ""; } } - else { - if (_this->selectedListName == "") { style::endDisabled(); } - } if (_this->selectedListName == "") { style::beginDisabled(); } //Draw buttons on top of the list @@ -454,8 +459,7 @@ private: ImGui::TableSetColumnIndex(1); if (selectedNames.size() == 0 && _this->selectedListName != "") { style::beginDisabled(); } if (ImGui::Button(("Remove##_freq_mgr_rem_" + _this->name).c_str(), ImVec2(ImGui::GetContentRegionAvailWidth(), 0))) { - for (auto& _name : selectedNames) { _this->bookmarks.erase(_name); } - _this->saveByName(_this->selectedListName); + _this->deleteBookmarksOpen = true; } if (selectedNames.size() == 0 && _this->selectedListName != "") { style::endDisabled(); } ImGui::TableSetColumnIndex(2); @@ -470,6 +474,15 @@ private: ImGui::EndTable(); + // Bookmark delete confirm dialog + // List delete confirmation + if (ImGui::GenericDialog(("freq_manager_del_list_confirm"+_this->name).c_str(), _this->deleteBookmarksOpen, GENERIC_DIALOG_BUTTONS_YES_NO, [_this](){ + ImGui::Text("Deleting selected bookmaks. Are you sure?"); + }) == GENERIC_DIALOG_BUTTON_YES) { + for (auto& _name : selectedNames) { _this->bookmarks.erase(_name); } + _this->saveByName(_this->selectedListName); + } + // Bookmark list if (ImGui::BeginTable(("freq_manager_bkm_table"+_this->name).c_str(), 2, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY, ImVec2(0, 200))) { ImGui::TableSetupColumn("Name"); @@ -786,6 +799,9 @@ private: bool renameListOpen = false; bool selectListsOpen = false; + bool deleteListOpen = false; + bool deleteBookmarksOpen = false; + EventHandler fftRedrawHandler; EventHandler inputHandler;