Added new dialog helpers and added Are You Sure dialogs in a few places

This commit is contained in:
AlexandreRouma
2021-12-13 03:01:06 +01:00
parent b4924a8fae
commit 964fd467f8
2 changed files with 34 additions and 16 deletions

View File

@ -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;