impr: Make close button on macOS close providers if any are open instead of closing ImHex

This commit is contained in:
WerWolv
2025-07-24 21:37:49 +02:00
parent 2e200a2ab8
commit a9ce71c481
5 changed files with 47 additions and 9 deletions

View File

@@ -95,11 +95,40 @@ namespace hex::plugin::builtin {
TaskManager::doLater([] {
for (auto &task : TaskManager::getRunningTasks())
task->interrupt();
PopupTasksWaiting::open();
PopupTasksWaiting::open([]() {
ImHexApi::System::closeImHex();
});
});
}
});
EventCloseButtonPressed::subscribe([]() {
if (ImHexApi::Provider::isValid()) {
if (ImHexApi::Provider::isDirty()) {
ui::PopupQuestion::open("hex.builtin.popup.exit_application.desc"_lang,
[] {
for (const auto &provider : ImHexApi::Provider::getProviders())
ImHexApi::Provider::remove(provider);
},
[] { }
);
} else if (TaskManager::getRunningTaskCount() > 0 || TaskManager::getRunningBackgroundTaskCount() > 0) {
TaskManager::doLater([] {
for (auto &task : TaskManager::getRunningTasks())
task->interrupt();
PopupTasksWaiting::open([]() {
EventCloseButtonPressed::post();
});
});
} else {
for (const auto &provider : ImHexApi::Provider::getProviders())
ImHexApi::Provider::remove(provider);
}
} else {
ImHexApi::System::closeImHex();
}
});
EventProviderClosing::subscribe([](const prv::Provider *provider, bool *shouldClose) {
if (provider->isDirty()) {
*shouldClose = false;