kopia lustrzana https://github.com/AlexandreRouma/SDRPlusPlus
Added new dialog helpers and added Are You Sure dialogs in a few places
rodzic
b4924a8fae
commit
964fd467f8
|
@ -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);
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <gui/tuner.h>
|
||||
#include <gui/file_dialogs.h>
|
||||
#include <utils/freq_formatting.h>
|
||||
#include <gui/dialogs/dialog_box.h>
|
||||
|
||||
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<ImGui::WaterFall::FFTRedrawArgs> fftRedrawHandler;
|
||||
EventHandler<ImGui::WaterFall::InputHandlerArgs> inputHandler;
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue