Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions src/Menu/SettingsTabRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ void SettingsTabRenderer::RenderThemesTab()
auto& themeSettings = globals::menu->GetSettings().Theme;

// Static variables for popup state and new theme creation
static Util::ConfirmationPopup deleteThemePopup("Delete Theme", "", "Delete", "Cancel");
static bool showCreateThemePopup = false;
static char newThemeName[128] = "";
static char newThemeDisplayName[128] = "";
Expand Down Expand Up @@ -476,7 +477,7 @@ void SettingsTabRenderer::RenderThemesTab()
ImGui::Spacing();
const auto& selectedTheme = themes[currentItem];
ImGui::Text("Selected Theme: ");
ImGui::SameLine();
ImGui::SameLine(0, 0);
ImGui::TextColored(themeSettings.StatusPalette.InfoColor, "%s", selectedTheme.displayName.c_str());
if (!selectedTheme.description.empty()) {
ImGui::TextWrapped("%s", selectedTheme.description.c_str());
Expand All @@ -485,10 +486,10 @@ void SettingsTabRenderer::RenderThemesTab()
ImGui::Spacing();

const bool isPreset = IsPresetThemeSelected();
const auto* currentThemeInfo = themeManager->GetThemeInfo(currentThemePreset);

if (!isPreset) {
if (Util::ButtonWithFlash("Save")) {
const auto* currentThemeInfo = themeManager->GetThemeInfo(currentThemePreset);
if (currentThemeInfo) {
// Get current settings
json currentThemeJson;
Expand Down Expand Up @@ -561,6 +562,22 @@ void SettingsTabRenderer::RenderThemesTab()
showValidationError = false;
}

if (!isPreset && currentThemeInfo && !currentThemeInfo->filePath.empty()) {
ImGui::SameLine();
auto _style = Util::ErrorButtonStyle();
if (Util::ButtonWithFlash("Delete")) {
deleteThemePopup.message =
"Are you sure you want to delete the theme '" +
(currentThemeInfo->displayName.empty() ? currentThemePreset : currentThemeInfo->displayName) +
"'?\n\nThis will permanently remove the theme file. This cannot be undone.";
deleteThemePopup.Request();
}
if (auto _tt = Util::HoverTooltipWrapper()) {
ImGui::Text("Delete the theme file for '%s'. This cannot be undone.",
(currentThemeInfo->displayName.empty() ? currentThemePreset : currentThemeInfo->displayName).c_str());
}
}

// Display update feedback below the buttons
if (showUpdateFeedback) {
ImGui::Spacing();
Expand Down Expand Up @@ -701,6 +718,17 @@ void SettingsTabRenderer::RenderThemesTab()
ImGui::EndPopup();
}

if (deleteThemePopup.Draw() && currentThemeInfo && !currentThemeInfo->filePath.empty()) {
auto result = Util::FileHelpers::SafeDelete(currentThemeInfo->filePath, "Theme '" + currentThemePreset + "'");
if (result.success) {
themeManager->RefreshThemes();
globals::menu->LoadThemePreset("Default");
currentThemePreset = "Default";
} else {
logger::warn("Failed to delete theme '{}': {}", currentThemePreset, result.errorMessage);
}
}

ImGui::EndTabItem();
}
}
Expand Down