feat: Display detailed error message when loading of project fails (#1135)

In order to do this I add to make some other additions :
- Add a warning popup (TODO, maybe add some icons to differentiate
error/warning popups in a future PR ?)
- create showError() and showWarning() functions, as helpers to show a
message both to the logs and as a popup
This commit is contained in:
iTrooz
2023-06-21 20:07:36 +02:00
committed by GitHub
parent 3fe6cd057b
commit b7d8e46288
13 changed files with 363 additions and 182 deletions

View File

@@ -12,15 +12,15 @@
#include <hex/helpers/concepts.hpp>
#include <hex/helpers/tar.hpp>
/**
* @brief Project file manager
*
* The project file manager is used to load and store project files. It is used by all features of ImHex
* that want to store any data to a Project File.
*
*/
namespace hex {
/**
* @brief Project file manager
*
* The project file manager is used to load and store project files. It is used by all features of ImHex
* that want to store any data to a Project File.
*
*/
class ProjectFile {
public:
struct Handler {
@@ -39,6 +39,17 @@ namespace hex {
Function load, store; //< Functions to load and store data
};
/**
* @brief Set implementations for loading and restoring a project
*
* @param loadFun function to use to load a project in ImHex
* @param storeFun function to use to store a project to disk
*/
static void setProjectFunctions(
const std::function<bool(const std::fs::path&)> &loadFun,
const std::function<bool(std::optional<std::fs::path>)> &storeFun
);
/**
* @brief Load a project file
*
@@ -119,6 +130,9 @@ namespace hex {
private:
ProjectFile() = default;
static std::function<bool(const std::fs::path&)> s_loadProjectFunction;
static std::function<bool(std::optional<std::fs::path>)> s_storeProjectFunction;
static std::fs::path s_currProjectPath;
static std::vector<Handler> s_handlers;
static std::vector<ProviderHandler> s_providerHandlers;