mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 13:37:42 -05:00
impr: Make close button on macOS close providers if any are open instead of closing ImHex
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user