Skip to content

Commit

Permalink
feat: Add back Windows-specific settings
Browse files Browse the repository at this point in the history
  • Loading branch information
WerWolv committed Oct 21, 2023
1 parent 9c7bdfa commit ccb8684
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
1 change: 0 additions & 1 deletion lib/libimhex/source/api/content_registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ namespace hex {
entry->widget = std::move(widget);
entry->widget->load(getSetting(unlocalizedCategory, unlocalizedName, entry->widget->store()));


return entry->widget.get();
}

Expand Down
2 changes: 1 addition & 1 deletion main/gui/source/init/tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ namespace hex::init {
return true;
}

// run all exit taks, and print to console
// Run all exit tasks, and print to console
void runExitTasks() {
for (const auto &[name, task, async] : init::getExitTasks()) {
task();
Expand Down
33 changes: 14 additions & 19 deletions plugins/windows/source/content/settings_entries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ namespace hex::plugin::windows {

namespace {

/*constexpr auto ImHexContextMenuKey = R"(Software\Classes\*\shell\ImHex)";
constexpr auto ImHexContextMenuKey = R"(Software\Classes\*\shell\ImHex)";

void addImHexContextMenuEntry() {
// Create ImHex Root Key
HKEY imHexRootKey;
RegCreateKeyExA(HKEY_CURRENT_USER, ImHexContextMenuKey, 0x00, nullptr, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, nullptr, &imHexRootKey, nullptr);
RegSetValueA(imHexRootKey, nullptr, REG_SZ, "Open with ImHex", 0x00);

// Add Icon key to use first icon embedded in exe
// Add 'Icon' key to use first icon embedded in exe
std::array<char, MAX_PATH> imHexPath = { 0 };
GetModuleFileNameA(nullptr, imHexPath.data(), imHexPath.size());
auto iconValue = hex::format(R"("{}",0)", imHexPath.data());
RegSetKeyValueA(imHexRootKey, nullptr, "Icon", REG_SZ, iconValue.c_str(), iconValue.size() + 1);

// Add command key to pass file path as first argument to ImHex
// Add 'command' key to pass the right-clicked file path as first argument to ImHex
auto commandValue = hex::format(R"("{}" "%1")", imHexPath.data());
RegSetValueA(imHexRootKey, "command", REG_SZ, commandValue.c_str(), commandValue.size() + 1);
RegCloseKey(imHexRootKey);
Expand All @@ -43,32 +43,27 @@ namespace hex::plugin::windows {
RegCloseKey(key);

return keyExists;
}*/
}

}

void registerSettings() {

/* General */

/*ContentRegistry::Settings::add("hex.builtin.setting.general", "hex.builtin.setting.general.context_menu_entry", 0, [](auto name, nlohmann::json &setting) {
static bool enabled = hasImHexContextMenuEntry();
if (ImGui::Checkbox(name.data(), &enabled)) {
if (enabled)
addImHexContextMenuEntry();
else
removeImHexContextMenuEntry();
namespace Widgets = ContentRegistry::Settings::Widgets;

enabled = hasImHexContextMenuEntry();
setting = enabled;
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "", "hex.builtin.setting.general.context_menu_entry", false)
.setChangedCallback([](auto &widget) {
auto checked = static_cast<Widgets::Checkbox &>(widget).isChecked();

return true;
}
if (checked)
addImHexContextMenuEntry();
else
removeImHexContextMenuEntry();

return false;
});*/
widget.load(hasImHexContextMenuEntry());
});
}

}

0 comments on commit ccb8684

Please sign in to comment.