1
0
mirror of synced 2024-11-28 17:40:51 +01:00

sys: Added a info popup when closing ImHex while tasks are still running

This commit is contained in:
WerWolv 2023-01-28 12:16:41 +01:00
parent 9b80486285
commit 6799263317
3 changed files with 33 additions and 4 deletions

View File

@ -325,7 +325,7 @@
"hex.builtin.popup.close_provider.title": "Close Provider?", "hex.builtin.popup.close_provider.title": "Close Provider?",
"hex.builtin.popup.error.create": "Failed to create new file!", "hex.builtin.popup.error.create": "Failed to create new file!",
"hex.builtin.popup.error.file_dialog.common": "An error occurred while opening the file browser!", "hex.builtin.popup.error.file_dialog.common": "An error occurred while opening the file browser!",
"hex.builtin.popup.error.file_dialog.portal": "There was an error while opening the file browser. This might be caused by your system not having a xdg-desktop-portal backend installed correctly.\n\nOn KDE, it's xdg-desktop-portal-kde.\nOn Gnome it's xdg-desktop-portal-gnome.\nOn wlroots it's xdg-desktop-portal-wlr.\nOtherwise, you can try to use xdg-desktop-portal-gtk.\n\nReboot your system after installing it.\n\nIf the file browser still doesn't work after this, submit an issue at https://github.com/WerWolv/ImHex/issues\n\nIn the meantime files can still be opened by dragging them onto the ImHex window!", "hex.builtin.popup.error.file_dialog.portal": "There was an error while opening the file browser.\nThis might be caused by your system not having a xdg-desktop-portal backend installed correctly.\n\nOn KDE, it's xdg-desktop-portal-kde.\nOn Gnome it's xdg-desktop-portal-gnome.\nOn wlroots it's xdg-desktop-portal-wlr.\nOtherwise, you can try to use xdg-desktop-portal-gtk.\n\nReboot your system after installing it.\n\nIf the file browser still doesn't work after this, submit an issue at https://github.com/WerWolv/ImHex/issues\n\nIn the meantime files can still be opened by dragging them onto the ImHex window!",
"hex.builtin.popup.error.open": "Failed to open file!", "hex.builtin.popup.error.open": "Failed to open file!",
"hex.builtin.popup.error.project.load": "Failed to load project!", "hex.builtin.popup.error.project.load": "Failed to load project!",
"hex.builtin.popup.error.project.save": "Failed to save project!", "hex.builtin.popup.error.project.save": "Failed to save project!",
@ -333,6 +333,8 @@
"hex.builtin.popup.error.task_exception": "Exception thrown in Task '{}':\n\n{}", "hex.builtin.popup.error.task_exception": "Exception thrown in Task '{}':\n\n{}",
"hex.builtin.popup.exit_application.desc": "You have unsaved changes made to your Project.\nAre you sure you want to exit?", "hex.builtin.popup.exit_application.desc": "You have unsaved changes made to your Project.\nAre you sure you want to exit?",
"hex.builtin.popup.exit_application.title": "Exit Application?", "hex.builtin.popup.exit_application.title": "Exit Application?",
"hex.builtin.popup.waiting_for_tasks.title": "Waiting for Tasks",
"hex.builtin.popup.waiting_for_tasks.desc": "There are still tasks running in the background.\nImHex will close after they are finished.",
"hex.builtin.provider.disk": "Raw Disk Provider", "hex.builtin.provider.disk": "Raw Disk Provider",
"hex.builtin.provider.disk.disk_size": "Disk Size", "hex.builtin.provider.disk.disk_size": "Disk Size",
"hex.builtin.provider.disk.reload": "Reload", "hex.builtin.provider.disk.reload": "Reload",

View File

@ -32,6 +32,13 @@ namespace hex::plugin::builtin {
if (ImHexApi::Provider::isDirty()) { if (ImHexApi::Provider::isDirty()) {
glfwSetWindowShouldClose(window, GLFW_FALSE); glfwSetWindowShouldClose(window, GLFW_FALSE);
TaskManager::doLater([] { ImGui::OpenPopup("hex.builtin.popup.exit_application.title"_lang); }); TaskManager::doLater([] { ImGui::OpenPopup("hex.builtin.popup.exit_application.title"_lang); });
} else if (TaskManager::getRunningTaskCount() > 0 || TaskManager::getRunningBackgroundTaskCount() > 0) {
glfwSetWindowShouldClose(window, GLFW_FALSE);
TaskManager::doLater([] {
for (auto &task : TaskManager::getRunningTasks())
task->interrupt();
ImGui::OpenPopup("hex.builtin.popup.waiting_for_tasks.title"_lang);
});
} }
}); });

View File

@ -31,7 +31,10 @@ namespace hex::plugin::builtin {
ImGui::NewLine(); ImGui::NewLine();
View::confirmButtons("hex.builtin.common.yes"_lang, "hex.builtin.common.no"_lang, View::confirmButtons("hex.builtin.common.yes"_lang, "hex.builtin.common.no"_lang,
[] { ImHexApi::Common::closeImHex(true); }, [] {
ImHexApi::Provider::resetDirty();
ImHexApi::Common::closeImHex();
},
[] { ImGui::CloseCurrentPopup(); } [] { ImGui::CloseCurrentPopup(); }
); );
@ -58,6 +61,23 @@ namespace hex::plugin::builtin {
ImGui::EndPopup(); ImGui::EndPopup();
} }
if (ImGui::BeginPopupModal("hex.builtin.popup.waiting_for_tasks.title"_lang, nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove)) {
ImGui::TextUnformatted("hex.builtin.popup.waiting_for_tasks.desc"_lang);
ImGui::Separator();
ImGui::NewLine();
ImGui::SetCursorPosX((ImGui::GetWindowWidth() - ImGui::CalcTextSize("[-]").x) / 2);
ImGui::TextSpinner("");
ImGui::NewLine();
if (TaskManager::getRunningTaskCount() == 0 && TaskManager::getRunningBackgroundTaskCount() == 0) {
ImGui::CloseCurrentPopup();
ImHexApi::Common::closeImHex();
}
ImGui::EndPopup();
}
auto windowSize = ImHexApi::System::getMainWindowSize(); auto windowSize = ImHexApi::System::getMainWindowSize();
// Info popup // Info popup