mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
fix: Handling of unchanged shortcut keys
This commit is contained in:
@@ -46,7 +46,7 @@ namespace hex {
|
||||
try {
|
||||
callback(getSetting(category, name, {}));
|
||||
} catch (const std::exception &e) {
|
||||
log::error("Failed to load setting [{}/{}]: {}", category, name, e.what());
|
||||
log::error("Failed to load setting [{} / {}]: {}", category, name, e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -216,12 +216,13 @@ namespace hex {
|
||||
entry->widget = std::move(widget);
|
||||
if (entry->widget != nullptr) {
|
||||
onChange(unlocalizedCategory, unlocalizedName, [widget = entry->widget.get(), unlocalizedCategory, unlocalizedName](const SettingsValue &) {
|
||||
auto defaultValue = widget->store();
|
||||
try {
|
||||
auto defaultValue = widget->store();
|
||||
widget->load(ContentRegistry::Settings::impl::getSetting(unlocalizedCategory, unlocalizedName, defaultValue));
|
||||
widget->onChanged();
|
||||
} catch (const std::exception &e) {
|
||||
log::error("Failed to load setting [{} / {}]: {}", unlocalizedCategory.get(), unlocalizedName.get(), e.what());
|
||||
ContentRegistry::Settings::impl::getSetting(unlocalizedCategory, unlocalizedName, defaultValue) = defaultValue;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -336,6 +336,9 @@ namespace hex::plugin::builtin {
|
||||
void load(const nlohmann::json &data) override {
|
||||
std::set<Key> keys;
|
||||
|
||||
if (data.empty())
|
||||
return;
|
||||
|
||||
for (const auto &key : data.get<std::vector<u32>>())
|
||||
keys.insert(Key(scanCodeToKey(key)));
|
||||
|
||||
|
||||
@@ -32,11 +32,13 @@ namespace hex::plugin::builtin {
|
||||
for (const auto &[unlocalizedCategory, unlocalizedDescription, subCategories] : ContentRegistry::Settings::impl::getSettings()) {
|
||||
for (const auto &[unlocalizedSubCategory, entries] : subCategories) {
|
||||
for (const auto &[unlocalizedName, widget] : entries) {
|
||||
auto defaultValue = widget->store();
|
||||
try {
|
||||
auto defaultValue = widget->store();
|
||||
widget->load(ContentRegistry::Settings::impl::getSetting(unlocalizedCategory, unlocalizedName, defaultValue));
|
||||
} catch (const std::exception &e) {
|
||||
log::error("Failed to load setting [{} / {}]: {}", unlocalizedCategory.get(), unlocalizedName.get(), e.what());
|
||||
|
||||
ContentRegistry::Settings::impl::getSetting(unlocalizedCategory, unlocalizedName, defaultValue) = defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user