diff options
Diffstat (limited to 'src/ui/imgui_extensions.cpp')
| -rw-r--r-- | src/ui/imgui_extensions.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
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 <time.h> + #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 |
