mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-27 23:37:05 -05:00
impr: Add option to ShortcutManager to get a shortcut by its name
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user