Handle held hotkeys on frame update (paintGL) rather than on key press

This commit is contained in:
Dan Paulat 2024-04-12 00:37:27 -05:00
parent dcaba52db7
commit 7e99b5fb00
2 changed files with 124 additions and 79 deletions

View file

@ -66,6 +66,10 @@ void HotkeyManager::Impl::UpdateHotkey(types::Hotkey hotkey,
void HotkeyManager::HandleKeyPress(QKeyEvent* ev)
{
logger_->trace("HandleKeyPress: {}, {}",
ev->keyCombination().toCombined(),
ev->isAutoRepeat());
for (auto& hotkey : p->hotkeys_)
{
if (hotkey.second.count() == 1 &&
@ -78,7 +82,16 @@ void HotkeyManager::HandleKeyPress(QKeyEvent* ev)
void HotkeyManager::HandleKeyRelease(QKeyEvent* ev)
{
Q_UNUSED(ev);
logger_->trace("HandleKeyRelease: {}", ev->keyCombination().toCombined());
for (auto& hotkey : p->hotkeys_)
{
if (hotkey.second.count() == 1 &&
hotkey.second[0] == ev->keyCombination())
{
Q_EMIT HotkeyReleased(hotkey.first);
}
}
}
std::shared_ptr<HotkeyManager> HotkeyManager::Instance()