diff options
Diffstat (limited to 'src/input/backend/inputchord.cpp')
-rw-r--r-- | src/input/backend/inputchord.cpp | 47 |
1 files changed, 8 insertions, 39 deletions
diff --git a/src/input/backend/inputchord.cpp b/src/input/backend/inputchord.cpp index 731fd91e3..5716e3344 100644 --- a/src/input/backend/inputchord.cpp +++ b/src/input/backend/inputchord.cpp @@ -62,15 +62,6 @@ InputChord::InputChord() { } -void InputChord::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) -{ - const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QInputChordData>>(change); - const QInputChordData &data = typedChange->data; - m_chords = data.chordIds; - m_timeout = milliToNano(data.timeout); - m_inputsToTrigger = m_chords; -} - void InputChord::cleanup() { setEnabled(false); @@ -102,38 +93,16 @@ void InputChord::setStartTime(qint64 time) m_startTime = time; } -void InputChord::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) +void InputChord::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) { - switch (e->type()) { - case Qt3DCore::PropertyUpdated: { - const auto change = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e); - if (change->propertyName() == QByteArrayLiteral("timeout")) - m_timeout = milliToNano(change->value().toInt()); - break; - } + AbstractActionInput::syncFromFrontEnd(frontEnd, firstTime); + const QInputChord *node = qobject_cast<const QInputChord *>(frontEnd); + if (!node) + return; - case Qt3DCore::PropertyValueAdded: { - const auto change = qSharedPointerCast<Qt3DCore::QPropertyNodeAddedChange>(e); - if (change->propertyName() == QByteArrayLiteral("chord")) { - m_chords.push_back(change->addedNodeId()); - m_inputsToTrigger.push_back(change->addedNodeId()); - } - break; - } - - case Qt3DCore::PropertyValueRemoved: { - const auto change = qSharedPointerCast<Qt3DCore::QPropertyNodeRemovedChange>(e); - if (change->propertyName() == QByteArrayLiteral("chord")) { - m_chords.removeOne(change->removedNodeId()); - m_inputsToTrigger.removeOne(change->removedNodeId()); - } - break; - } - - default: - break; - } - AbstractActionInput::sceneChangeEvent(e); + m_timeout = milliToNano(node->timeout()); + m_chords = Qt3DCore::qIdsForNodes(node->chords()); + m_inputsToTrigger = m_chords; } bool InputChord::process(InputHandler *inputHandler, qint64 currentTime) |