mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 05:26:45 +08:00
Change InputManager trigger behavior to subset triggering
Previously, InputManager triggered an action only for exact matching. If 'CTRL' was configured, the action would be released as soon as 'CTRL + R' was pressed. The behavior is changed now that the action stays active as long as its configured combination is keeping pressed (ignoring any extra keys/buttons). ref T595
This commit is contained in:
committed by
Mat Sutcliffe
parent
6f1fb20b1c
commit
59c69e379a
@@ -10,6 +10,7 @@
|
||||
#include "blackmisc/compare.h"
|
||||
#include "blackmisc/dictionary.h"
|
||||
#include "blackmisc/input/actionhotkey.h"
|
||||
#include "blackmisc/range.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
|
||||
#include <limits.h>
|
||||
@@ -151,26 +152,43 @@ namespace BlackCore
|
||||
return info.m_index;
|
||||
}
|
||||
|
||||
void CInputManager::processCombination(const CHotkeyCombination &combination)
|
||||
void CInputManager::processCombination(const CHotkeyCombination ¤tCombination)
|
||||
{
|
||||
if (m_captureActive)
|
||||
{
|
||||
if (combination.size() < m_capturedCombination.size())
|
||||
if (currentCombination.size() < m_capturedCombination.size())
|
||||
{
|
||||
emit combinationSelectionFinished(m_capturedCombination);
|
||||
m_captureActive = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
emit combinationSelectionChanged(combination);
|
||||
m_capturedCombination = combination;
|
||||
emit combinationSelectionChanged(currentCombination);
|
||||
m_capturedCombination = currentCombination;
|
||||
}
|
||||
}
|
||||
|
||||
QString previousAction = m_configuredActions.value(m_lastCombination);
|
||||
QString action = m_configuredActions.value(combination);
|
||||
m_lastCombination = combination;
|
||||
callFunctionsBy(previousAction, false);
|
||||
callFunctionsBy(action, true);
|
||||
for (const CHotkeyCombination &combination : makeKeysRange(as_const(m_configuredActions)))
|
||||
{
|
||||
QString action = m_configuredActions.value(combination);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_lastCombination = currentCombination;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user