2023-12-05 14:32:28 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hex/ui/popup.hpp>
|
|
|
|
|
|
|
|
#include <hex/api/localization_manager.hpp>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace hex::plugin::builtin {
|
|
|
|
|
|
|
|
class PopupBlockingTask : public Popup<PopupBlockingTask> {
|
|
|
|
public:
|
|
|
|
PopupBlockingTask(TaskHolder &&task) : hex::Popup<PopupBlockingTask>("hex.builtin.popup.blocking_task.title", false), m_task(std::move(task)) { }
|
|
|
|
|
|
|
|
void drawContent() override {
|
|
|
|
ImGui::TextUnformatted("hex.builtin.popup.blocking_task.desc"_lang);
|
|
|
|
ImGui::Separator();
|
|
|
|
|
2023-12-19 13:10:25 +01:00
|
|
|
if (m_task.getProgress() == 0)
|
2023-12-05 14:32:28 +01:00
|
|
|
ImGuiExt::TextSpinner("");
|
|
|
|
else
|
2023-12-19 13:10:25 +01:00
|
|
|
ImGui::ProgressBar(m_task.getProgress() / 100.0F);
|
2023-12-05 14:32:28 +01:00
|
|
|
|
|
|
|
ImGui::NewLine();
|
2023-12-23 21:09:41 +01:00
|
|
|
if (ImGui::ButtonEx("hex.ui.common.cancel"_lang, ImVec2(ImGui::GetContentRegionAvail().x, 0)) || ImGui::IsKeyDown(ImGuiKey_Escape))
|
2023-12-19 13:10:25 +01:00
|
|
|
m_task.interrupt();
|
2023-12-05 14:32:28 +01:00
|
|
|
|
2023-12-19 13:10:25 +01:00
|
|
|
if (!m_task.isRunning()) {
|
2023-12-05 14:32:28 +01:00
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] ImGuiWindowFlags getFlags() const override {
|
|
|
|
return ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
TaskHolder m_task;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|