mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-25 20:07:51 +02:00
Added new dialog helpers and added Are You Sure dialogs in a few places
This commit is contained in:
@ -3,13 +3,15 @@
|
||||
#include <core.h>
|
||||
#include <string.h>
|
||||
#include <gui/style.h>
|
||||
#include <gui/dialogs/dialog_box.h>
|
||||
|
||||
namespace module_manager_menu {
|
||||
char modName[1024];
|
||||
std::vector<std::string> modTypes;
|
||||
std::vector<std::string> 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);
|
||||
|
Reference in New Issue
Block a user