feat: Allow recents to also display other providers

This commit is contained in:
WerWolv
2022-08-14 10:07:45 +02:00
parent 440ba3823e
commit 85f0e04d0e
14 changed files with 150 additions and 78 deletions

View File

@@ -337,12 +337,12 @@ namespace hex {
void add(bool addToList = true) {
auto typeName = T().getTypeName();
(void)EventManager::subscribe<RequestCreateProvider>([expectedName = typeName](const std::string &name, hex::prv::Provider **provider) {
(void)EventManager::subscribe<RequestCreateProvider>([expectedName = typeName](const std::string &name, bool skipLoadInterface, hex::prv::Provider **provider) {
if (name != expectedName) return;
auto newProvider = new T();
prv::Provider *newProvider = new T();
hex::ImHexApi::Provider::add(newProvider);
hex::ImHexApi::Provider::add(newProvider, skipLoadInterface);
if (provider != nullptr)
*provider = newProvider;

View File

@@ -129,7 +129,7 @@ namespace hex {
EVENT_DEF(RequestOpenFile, std::fs::path);
EVENT_DEF(RequestChangeTheme, u32);
EVENT_DEF(RequestOpenPopup, std::string);
EVENT_DEF(RequestCreateProvider, std::string, hex::prv::Provider **);
EVENT_DEF(RequestCreateProvider, std::string, bool, hex::prv::Provider **);
EVENT_DEF(RequestShowInfoPopup, std::string);
EVENT_DEF(RequestShowErrorPopup, std::string);

View File

@@ -137,7 +137,7 @@ namespace hex {
void resetDirty();
bool isDirty();
void add(prv::Provider *provider);
void add(prv::Provider *provider, bool skipLoadInterface = false);
template<std::derived_from<prv::Provider> T>
void add(auto &&...args) {
@@ -146,7 +146,7 @@ namespace hex {
void remove(prv::Provider *provider, bool noQuestions = false);
prv::Provider* createProvider(const std::string &unlocalizedName);
prv::Provider* createProvider(const std::string &unlocalizedName, bool skipLoadInterface = false);
}

View File

@@ -96,7 +96,8 @@ namespace hex::fs {
Resources,
Constants,
Encodings,
Logs
Logs,
Recent
};
std::optional<std::fs::path> getExecutablePath();

View File

@@ -104,6 +104,9 @@ namespace hex::prv {
virtual std::pair<Region, bool> getRegionValidity(u64 address) const;
void skipLoadInterface() { this->m_skipLoadInterface = true; }
[[nodiscard]] bool shouldSkipLoadInterface() const { return this->m_skipLoadInterface; }
protected:
u32 m_currPage = 0;
u64 m_baseAddress = 0;
@@ -115,6 +118,7 @@ namespace hex::prv {
u32 m_id;
bool m_dirty = false;
bool m_skipLoadInterface = false;
private:
static u32 s_idCounter;