1
0
mirror of synced 2024-11-12 10:10:53 +01:00

feat: Make CTRL + N automatically create a memory provider (#966)

"CTRL + N" can open a mem_file directly.
This commit is contained in:
qux-bbb 2023-03-07 23:05:03 +08:00 committed by GitHub
parent f661f4d1d6
commit cdd5d33e89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,18 +65,11 @@ namespace hex::plugin::builtin {
EventManager::subscribe<RequestOpenWindow>([](const std::string &name) {
if (name == "Create File") {
fs::openFileBrowser(fs::DialogMode::Save, {}, [](const auto &path) {
fs::File file(path, fs::File::Mode::Create);
if (!file.isValid()) {
View::showErrorPopup("hex.builtin.popup.error.create"_lang);
return;
}
file.setSize(1);
EventManager::post<RequestOpenFile>(path);
});
auto newProvider = hex::ImHexApi::Provider::createProvider("hex.builtin.provider.mem_file", true);
if (newProvider != nullptr && !newProvider->open())
hex::ImHexApi::Provider::remove(newProvider);
else
EventManager::post<EventProviderOpened>(newProvider);
} else if (name == "Open File") {
ImHexApi::Provider::createProvider("hex.builtin.provider.file");
} else if (name == "Open Project") {
@ -141,4 +134,4 @@ namespace hex::plugin::builtin {
}
}
}