From 5bb8a687ea66e0b536ec294fef0ddd6ba512c807 Mon Sep 17 00:00:00 2001 From: Daniel Dada Date: Wed, 17 Dec 2025 08:37:15 +0300 Subject: [PATCH] fix: added delete confirmation dialog in color_scheme_editor --- src/gui/color_scheme_editor.cpp | 28 +++++++++++++++++++++++++++- src/gui/color_scheme_editor.hpp | 1 + 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/gui/color_scheme_editor.cpp b/src/gui/color_scheme_editor.cpp index 7d8ada6..0003650 100644 --- a/src/gui/color_scheme_editor.cpp +++ b/src/gui/color_scheme_editor.cpp @@ -138,10 +138,36 @@ void color_scheme_editor::render_controls() ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.6f, 0.1f, 0.1f, 1.0f)); if (ImGui::Button("Delete")) { - m_controller.delete_current_palette(); + m_show_delete_confirmation = true; } ImGui::PopStyleColor(3); + if (m_show_delete_confirmation) + { + ImGui::OpenPopup("Delete Palette?"); + m_show_delete_confirmation = false; + } + + if (ImGui::BeginPopupModal("Delete Palette?", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) + { + ImGui::Text("Are you sure you want to delete '%s'?", current.name().c_str()); + ImGui::Text("This action cannot be undone."); + ImGui::Separator(); + + if (ImGui::Button("Delete", ImVec2(120, 0))) + { + m_controller.delete_current_palette(); + apply_themes(); + ImGui::CloseCurrentPopup(); + } + ImGui::SameLine(); + if (ImGui::Button("Cancel", ImVec2(120, 0))) + { + ImGui::CloseCurrentPopup(); + } + ImGui::EndPopup(); + } + ImGui::SameLine(); if (ImGui::Button("Apply")) { diff --git a/src/gui/color_scheme_editor.hpp b/src/gui/color_scheme_editor.hpp index 9baead8..f6bf17b 100644 --- a/src/gui/color_scheme_editor.hpp +++ b/src/gui/color_scheme_editor.hpp @@ -26,6 +26,7 @@ private: color_table_renderer m_color_table; preview_renderer m_preview; template_editor* m_template_editor{nullptr}; + bool m_show_delete_confirmation{false}; }; #endif // CLRSYNC_GUI_COLOR_SCHEME_EDITOR_HPP \ No newline at end of file