mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-01 21:17:44 -05:00
impr: Make unsaved changes popup behave more like in other applications
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
|
||||
#include <content/global_actions.hpp>
|
||||
#include <hex/ui/view.hpp>
|
||||
#include <hex/api/project_file_manager.hpp>
|
||||
#include <hex/helpers/logger.hpp>
|
||||
@@ -18,18 +19,25 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
}
|
||||
|
||||
void saveProject() {
|
||||
if (ImHexApi::Provider::isValid() && ProjectFile::hasPath()) {
|
||||
bool saveProject() {
|
||||
if (!ImHexApi::Provider::isValid())
|
||||
return false;
|
||||
|
||||
if (ProjectFile::hasPath()) {
|
||||
if (!ProjectFile::store()) {
|
||||
ui::ToastError::open("hex.builtin.popup.error.project.save"_lang);
|
||||
return false;
|
||||
} else {
|
||||
log::debug("Project saved");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return saveProjectAs();
|
||||
}
|
||||
}
|
||||
|
||||
void saveProjectAs() {
|
||||
fs::openFileBrowser(fs::DialogMode::Save, { {"Project File", "hexproj"} },
|
||||
bool saveProjectAs() {
|
||||
return fs::openFileBrowser(fs::DialogMode::Save, { {"Project File", "hexproj"} },
|
||||
[](std::fs::path path) {
|
||||
if (path.extension() != ".hexproj") {
|
||||
path.replace_extension(".hexproj");
|
||||
|
||||
Reference in New Issue
Block a user