Handle hotkeys across multiple map panes

This commit is contained in:
Dan Paulat 2024-04-12 22:59:49 -05:00
parent 60c8af46bf
commit 589eff9882
5 changed files with 77 additions and 28 deletions

View file

@ -64,34 +64,44 @@ void HotkeyManager::Impl::UpdateHotkey(types::Hotkey hotkey,
QKeySequence {QString::fromStdString(value)});
}
void HotkeyManager::HandleKeyPress(QKeyEvent* ev)
bool HotkeyManager::HandleKeyPress(QKeyEvent* ev)
{
logger_->trace("HandleKeyPress: {}, {}",
ev->keyCombination().toCombined(),
ev->isAutoRepeat());
bool hotkeyPressed = false;
for (auto& hotkey : p->hotkeys_)
{
if (hotkey.second.count() == 1 &&
hotkey.second[0] == ev->keyCombination())
{
hotkeyPressed = true;
Q_EMIT HotkeyPressed(hotkey.first, ev->isAutoRepeat());
}
}
return hotkeyPressed;
}
void HotkeyManager::HandleKeyRelease(QKeyEvent* ev)
bool HotkeyManager::HandleKeyRelease(QKeyEvent* ev)
{
logger_->trace("HandleKeyRelease: {}", ev->keyCombination().toCombined());
bool hotkeyReleased = false;
for (auto& hotkey : p->hotkeys_)
{
if (hotkey.second.count() == 1 &&
hotkey.second[0] == ev->keyCombination())
{
hotkeyReleased = true;
Q_EMIT HotkeyReleased(hotkey.first);
}
}
return hotkeyReleased;
}
std::shared_ptr<HotkeyManager> HotkeyManager::Instance()

View file

@ -24,8 +24,8 @@ public:
explicit HotkeyManager();
~HotkeyManager();
void HandleKeyPress(QKeyEvent* event);
void HandleKeyRelease(QKeyEvent* event);
bool HandleKeyPress(QKeyEvent* event);
bool HandleKeyRelease(QKeyEvent* event);
static std::shared_ptr<HotkeyManager> Instance();