mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-04 00:45:46 +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/compare.h"
|
||||||
#include "blackmisc/dictionary.h"
|
#include "blackmisc/dictionary.h"
|
||||||
#include "blackmisc/input/actionhotkey.h"
|
#include "blackmisc/input/actionhotkey.h"
|
||||||
|
#include "blackmisc/range.h"
|
||||||
#include "blackmisc/sequence.h"
|
#include "blackmisc/sequence.h"
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
@@ -151,26 +152,43 @@ namespace BlackCore
|
|||||||
return info.m_index;
|
return info.m_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::processCombination(const CHotkeyCombination &combination)
|
void CInputManager::processCombination(const CHotkeyCombination ¤tCombination)
|
||||||
{
|
{
|
||||||
if (m_captureActive)
|
if (m_captureActive)
|
||||||
{
|
{
|
||||||
if (combination.size() < m_capturedCombination.size())
|
if (currentCombination.size() < m_capturedCombination.size())
|
||||||
{
|
{
|
||||||
emit combinationSelectionFinished(m_capturedCombination);
|
emit combinationSelectionFinished(m_capturedCombination);
|
||||||
m_captureActive = false;
|
m_captureActive = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
emit combinationSelectionChanged(combination);
|
emit combinationSelectionChanged(currentCombination);
|
||||||
m_capturedCombination = combination;
|
m_capturedCombination = currentCombination;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString previousAction = m_configuredActions.value(m_lastCombination);
|
for (const CHotkeyCombination &combination : makeKeysRange(as_const(m_configuredActions)))
|
||||||
|
{
|
||||||
QString action = m_configuredActions.value(combination);
|
QString action = m_configuredActions.value(combination);
|
||||||
m_lastCombination = combination;
|
if (combination.isSubsetOf(currentCombination))
|
||||||
callFunctionsBy(previousAction, false);
|
{
|
||||||
|
if (!m_activeActions.contains(action))
|
||||||
|
{
|
||||||
|
m_activeActions.insert(action);
|
||||||
callFunctionsBy(action, true);
|
callFunctionsBy(action, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (m_activeActions.contains(action))
|
||||||
|
{
|
||||||
|
callFunctionsBy(action, false);
|
||||||
|
m_activeActions.remove(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_lastCombination = currentCombination;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
QMap<QString, QPixmap> m_availableActions;
|
QMap<QString, QPixmap> m_availableActions;
|
||||||
QHash<BlackMisc::Input::CHotkeyCombination, QString> m_configuredActions;
|
QHash<BlackMisc::Input::CHotkeyCombination, QString> m_configuredActions;
|
||||||
|
QSet<QString> m_activeActions;
|
||||||
QVector<BindInfo> m_boundActions;
|
QVector<BindInfo> m_boundActions;
|
||||||
|
|
||||||
bool m_actionRelayingEnabled = false;
|
bool m_actionRelayingEnabled = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user