1
0
mirror of synced 2024-11-15 11:33:23 +01:00
ImHex/plugins/builtin/source/content/global_actions.cpp
André Blome 4aa314b3ab
feat: Added quick "save project" action (#826)
* add quick -save project- action

* translation for -save project as- added

* removed machine translations; header file name extension fixed

* moved openProject() for consistency
2022-11-25 10:47:11 +01:00

36 lines
1.2 KiB
C++

#include <hex/ui/view.hpp>
#include <hex/api/project_file_manager.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 (!ProjectFile::store()) {
View::showErrorPopup("hex.builtin.popup.error.project.save"_lang);
}
}
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);
}
});
}
}