mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
The magic hotkey handling alorithm developed and tested in joined effort via SLACK
* no redundant action calls * do not call release action if the action is still active by another combination ref T585
This commit is contained in:
committed by
Mat Sutcliffe
parent
42af7e4e9f
commit
375d26de32
@@ -175,27 +175,30 @@ namespace BlackCore
|
||||
return;
|
||||
}
|
||||
|
||||
for (const CHotkeyCombination &combination : makeKeysRange(as_const(m_configuredActions)))
|
||||
QSet<QString> newActiveActions;
|
||||
for (const auto pair : makePairsRange(as_const(m_configuredActions)))
|
||||
{
|
||||
QString action = m_configuredActions.value(combination);
|
||||
const CHotkeyCombination &combination = pair.first;
|
||||
const QString &action = pair.second;
|
||||
if (combination.isSubsetOf(currentCombination))
|
||||
{
|
||||
if (!m_activeActions.contains(action))
|
||||
{
|
||||
m_activeActions.insert(action);
|
||||
callFunctionsBy(action, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_activeActions.contains(action))
|
||||
{
|
||||
callFunctionsBy(action, false);
|
||||
m_activeActions.remove(action);
|
||||
}
|
||||
newActiveActions.insert(action);
|
||||
}
|
||||
}
|
||||
|
||||
const QSet<QString> pressedActions = newActiveActions - m_activeActions;
|
||||
const QSet<QString> releasedActions = m_activeActions - newActiveActions;
|
||||
m_activeActions = newActiveActions;
|
||||
for (const QString &action : pressedActions)
|
||||
{
|
||||
callFunctionsBy(action, true);
|
||||
}
|
||||
for (const QString &action : releasedActions)
|
||||
{
|
||||
callFunctionsBy(action, false);
|
||||
}
|
||||
|
||||
// combination
|
||||
m_lastCombination = currentCombination;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user