1
0
mirror of synced 2025-01-11 05:42:15 +01:00

fix: Added migration routine to fix shortcuts

This commit is contained in:
WerWolv 2024-12-26 14:01:35 +01:00
parent 43c88a2fab
commit 58d66e3e97

View File

@ -285,9 +285,7 @@ namespace hex::plugin::builtin {
ImGui::BeginDisabled(m_drawShortcut.matches(m_defaultShortcut));
if (ImGuiExt::IconButton(ICON_VS_X, ImGui::GetStyleColorVec4(ImGuiCol_Text))) {
m_hasDuplicate = !ShortcutManager::updateShortcut(m_shortcut, m_defaultShortcut, m_view);
m_drawShortcut = m_defaultShortcut;
this->reset();
if (!m_hasDuplicate) {
m_shortcut = m_defaultShortcut;
settingChanged = true;
@ -356,6 +354,12 @@ namespace hex::plugin::builtin {
return keys;
}
void reset() {
m_hasDuplicate = !ShortcutManager::updateShortcut(m_shortcut, m_defaultShortcut, m_view);
m_drawShortcut = m_defaultShortcut;
}
private:
bool detectShortcut() {
if (const auto &shortcut = ShortcutManager::getPreviousShortcut(); shortcut.has_value()) {
@ -971,6 +975,21 @@ namespace hex::plugin::builtin {
ContentRegistry::Settings::add<ToolbarIconsWidget>("hex.builtin.setting.toolbar", "", "hex.builtin.setting.toolbar.icons");
}
ImHexApi::System::addMigrationRoutine("v1.36.1", [] {
log::warn("Resetting shortcut key settings for them to work with this version of ImHex");
for (const auto &category : ContentRegistry::Settings::impl::getSettings()) {
for (const auto &subcategory : category.subCategories) {
for (const auto &entry : subcategory.entries) {
if (auto keybindingWidget = dynamic_cast<KeybindingWidget*>(entry.widget.get())) {
keybindingWidget->reset();
}
}
}
}
ContentRegistry::Settings::impl::store();
});
}
static void loadLayoutSettings() {