impr: Add option to ShortcutManager to get a shortcut by its name

This commit is contained in:
WerWolv 2025-11-30 16:40:23 +01:00
parent a75947e611
commit 989f7f7678
2 changed files with 20 additions and 0 deletions

View File

@ -151,6 +151,8 @@ EXPORT_MODULE namespace hex {
*/
static void clearShortcuts();
static Shortcut getShortcutByName(const std::vector<UnlocalizedString> &unlocalizedName, const View *view = nullptr);
static void resumeShortcuts();
static void pauseShortcuts();

View File

@ -387,6 +387,24 @@ namespace hex {
s_globalShortcuts->clear();
}
Shortcut ShortcutManager::getShortcutByName(const std::vector<UnlocalizedString> &unlocalizedName, const View *view) {
if (view != nullptr) {
for (const auto &[shortcut, entry] : view->m_shortcuts) {
if (entry.unlocalizedName == unlocalizedName) {
return entry.shortcut;
}
}
} else {
for (const auto &[shortcut, entry] : *s_globalShortcuts) {
if (entry.unlocalizedName == unlocalizedName) {
return entry.shortcut;
}
}
}
return Shortcut::None;
}
void ShortcutManager::resumeShortcuts() {
s_paused = false;
}