From a1d639e963eaad1f8d24d47cd004c22052166978 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Thu, 1 Jan 2026 14:33:14 +0100 Subject: export dropdown ui --- src/ui/imgui_extensions.cpp | 65 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'src/ui/imgui_extensions.cpp') diff --git a/src/ui/imgui_extensions.cpp b/src/ui/imgui_extensions.cpp index f8adb70..05eeb7b 100644 --- a/src/ui/imgui_extensions.cpp +++ b/src/ui/imgui_extensions.cpp @@ -1,3 +1,5 @@ +#include + #include "ui.hpp" #include "strops.hpp" #include "memops.hpp" @@ -707,4 +709,67 @@ namespace ImGui ImGui::CountryDropdown(buffer->country_code, IM_ARRAYSIZE(buffer->country_code), active_countries_only); } + + bool BeginExportDropdown(const char* title, const char* text, exporter::export_request* active_request) + { + static bool is_new_request = false; + static bool show_status_change = false; + static time_t status_changed_at = 0; + static e_err last_err; + + if (active_request && active_request->status == exporter::status::EXPORT_DONE && is_new_request) + { + is_new_request = false; + show_status_change = true; + last_err = active_request->error; + status_changed_at = time(NULL); + } + + if (active_request && active_request->status != exporter::status::EXPORT_DONE) { + is_new_request = true; + ImGui::BeginDisabled(); + ImGui::BeginCombo("##sendStatus", NULL, 1 << 20); + { + if (ImGui::BeginComboPreview()) + { + ImGui::Text("Sending"); // @Localize + ImGui::SameLine(); + ImGui::LoadingIndicatorCircleSmall(); + ImGui::EndComboPreview(); + } + } + ImGui::EndDisabled(); + } + else if (show_status_change) { + ImGui::BeginDisabled(); + ImGui::BeginCombo("##sendStatus", NULL, 1 << 20); + { + if (ImGui::BeginComboPreview()) + { + if (last_err == E_ERR_SUCCESS) { + ImGui::PushStyleColor(ImGuiCol_Text, config::colors::COLOR_SUCCESS); + ImGui::Text("√"); + ImGui::PopStyleColor(); + ImGui::Text("Success"); // @Localize + } + else { + ImGui::PushStyleColor(ImGuiCol_Text, config::colors::COLOR_ERROR); + ImGui::Text("X"); + ImGui::PopStyleColor(); + ImGui::Text("Failed"); // @Localize + } + ImGui::EndComboPreview(); + } + } + ImGui::EndDisabled(); + + if (difftime(time(NULL), status_changed_at) > 1.0f) { + show_status_change = false; + } + } + else { + return ImGui::BeginCombo(title, text); + } + return false; + } } \ No newline at end of file -- cgit v1.2.3-70-g09d2