feat: Added file handlers for .hexlyt and .hexproj files

This commit is contained in:
WerWolv 2023-06-06 21:35:13 +02:00
parent 456895a6a6
commit 99831a66a7
3 changed files with 26 additions and 0 deletions

View File

@ -28,6 +28,7 @@ add_library(${PROJECT_NAME} SHARED
source/content/global_actions.cpp
source/content/themes.cpp
source/content/recent.cpp
source/content/file_handlers.cpp
source/content/providers/file_provider.cpp
source/content/providers/gdb_provider.cpp

View File

@ -0,0 +1,23 @@
#include <hex/api/content_registry.hpp>
#include <hex/api/project_file_manager.hpp>
namespace hex::plugin::builtin {
void registerFileHandlers() {
ContentRegistry::FileHandler::add({ ".hexproj" }, [](const std::fs::path &path) {
return ProjectFile::load(path);
});
ContentRegistry::FileHandler::add({ ".hexlyt" }, [](const std::fs::path &path) {
for (const auto &folder : fs::getDefaultPaths(fs::ImHexPath::Layouts)) {
if (wolv::io::fs::copyFile(path, folder / path.filename()))
return true;
}
return false;
});
}
}

View File

@ -30,6 +30,7 @@ namespace hex::plugin::builtin {
void registerThemes();
void registerBackgroundServices();
void registerNetworkEndpoints();
void registerFileHandlers();
void addFooterItems();
void addTitleBarButtons();
@ -69,6 +70,7 @@ IMHEX_PLUGIN_SETUP("Built-in", "WerWolv", "Default ImHex functionality") {
registerThemes();
registerBackgroundServices();
registerNetworkEndpoints();
registerFileHandlers();
addFooterItems();
addTitleBarButtons();