1
0
mirror of synced 2024-11-16 03:53:22 +01:00
ImHex/plugins/builtin/source/content/global_actions.cpp
Thomas ed831c6fc9
fix: Do not check for writable provider to save project, disable shortcut when unavailable (#859)
* do not check for writable provider to save project

* disable save project shortcut when we can't save it

* log when project is saved
2023-01-07 17:16:43 +01:00

41 lines
1.4 KiB
C++

#include <hex/ui/view.hpp>
#include <hex/api/project_file_manager.hpp>
#include <hex/helpers/logger.hpp>
namespace hex::plugin::builtin {
void openProject() {
fs::openFileBrowser(fs::DialogMode::Open, { {"Project File", "hexproj"} },
[](const auto &path) {
if (!ProjectFile::load(path)) {
View::showErrorPopup("hex.builtin.popup.error.project.load"_lang);
}
});
}
void saveProject() {
if (ImHexApi::Provider::isValid() && ProjectFile::hasPath()) {
if (!ProjectFile::store()) {
View::showErrorPopup("hex.builtin.popup.error.project.save"_lang);
} else {
log::debug("Project saved");
}
}
}
void saveProjectAs() {
fs::openFileBrowser(fs::DialogMode::Save, { {"Project File", "hexproj"} },
[](std::fs::path path) {
if (path.extension() != ".hexproj") {
path.replace_extension(".hexproj");
}
if (!ProjectFile::store(path)) {
View::showErrorPopup("hex.builtin.popup.error.project.save"_lang);
}
});
}
}