mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 19:50:05 +00:00
Handle hotkeys across multiple map panes
This commit is contained in:
parent
60c8af46bf
commit
589eff9882
5 changed files with 77 additions and 28 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue