e578127f67
This PR does two things : - save opened projects as recent entries - refactor stuff about recent entries in a separate file. The reason is that I felt like welcome_screen.cpp was really big ( 685 lines before this, 500 now). What do you think ? --------- Co-authored-by: Nik <werwolv98@gmail.com>
81 lines
2.0 KiB
C++
81 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <atomic>
|
|
#include <list>
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#include <wolv/io/fs.hpp>
|
|
|
|
namespace hex::plugin::builtin::recent {
|
|
|
|
/**
|
|
* @brief Structure used to represent a recent other
|
|
*/
|
|
struct RecentEntry {
|
|
|
|
/**
|
|
* @brief Name that should be used to display the entry to the user
|
|
*/
|
|
std::string displayName;
|
|
|
|
/**
|
|
* @brief type of this entry. Might be a provider id (e.g. hex.builtin.provider.file)
|
|
* or "project" in case of a project
|
|
*/
|
|
std::string type;
|
|
|
|
/**
|
|
* @brief path of this entry file
|
|
*/
|
|
std::fs::path entryFilePath;
|
|
|
|
/**
|
|
* @brief Entire json data of the recent entry (include the fields above)
|
|
* Used for custom settings set by the providers
|
|
*/
|
|
nlohmann::json data;
|
|
|
|
bool operator==(const RecentEntry &other) const {
|
|
return HashFunction()(*this) == HashFunction()(other);
|
|
}
|
|
|
|
std::size_t getHash() const {
|
|
return HashFunction()(*this);
|
|
}
|
|
|
|
struct HashFunction {
|
|
std::size_t operator()(const RecentEntry& provider) const {
|
|
return
|
|
(std::hash<std::string>()(provider.displayName)) ^
|
|
(std::hash<std::string>()(provider.type) << 1);
|
|
}
|
|
};
|
|
|
|
};
|
|
|
|
void registerEventHandlers();
|
|
|
|
/**
|
|
* @brief Scan the files in ImHexPath::Recent to get the recent entries, and delete duplicates.
|
|
*/
|
|
void updateRecentEntries();
|
|
|
|
/**
|
|
* @brief Load a recent entry in ImHex. The entry might be a provider of a project
|
|
* @param recentEntry entry to load
|
|
*/
|
|
void loadRecentEntry(const RecentEntry &recentEntry);
|
|
|
|
/**
|
|
* @brief Draw the recent providers in the welcome screen
|
|
*/
|
|
void draw();
|
|
|
|
/**
|
|
* @brief Draw the "open recent" item in the "File" menu
|
|
*/
|
|
void drawFileMenuItem();
|
|
|
|
} |