| 1 | // Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #include "action_p.h" |
| 5 | |
| 6 | #include <Qt3DInput/qaction.h> |
| 7 | #include <Qt3DInput/qabstractactioninput.h> |
| 8 | |
| 9 | #include <Qt3DInput/private/qaction_p.h> |
| 10 | |
| 11 | QT_BEGIN_NAMESPACE |
| 12 | |
| 13 | namespace Qt3DInput { |
| 14 | |
| 15 | namespace Input { |
| 16 | |
| 17 | Action::Action() |
| 18 | : BackendNode(ReadWrite) |
| 19 | , m_actionTriggered(false) |
| 20 | { |
| 21 | } |
| 22 | |
| 23 | void Action::cleanup() |
| 24 | { |
| 25 | QBackendNode::setEnabled(false); |
| 26 | m_inputs.clear(); |
| 27 | m_actionTriggered = false; |
| 28 | } |
| 29 | |
| 30 | void Action::setActionTriggered(bool actionTriggered) |
| 31 | { |
| 32 | if (isEnabled() && (actionTriggered != m_actionTriggered)) |
| 33 | m_actionTriggered = actionTriggered; |
| 34 | } |
| 35 | |
| 36 | void Action::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) |
| 37 | { |
| 38 | BackendNode::syncFromFrontEnd(frontEnd, firstTime); |
| 39 | const Qt3DInput::QAction *node = qobject_cast<const Qt3DInput::QAction *>(object: frontEnd); |
| 40 | if (!node) |
| 41 | return; |
| 42 | |
| 43 | auto ids = Qt3DCore::qIdsForNodes(nodes: node->inputs()); |
| 44 | m_inputs = ids; |
| 45 | } |
| 46 | |
| 47 | } // Input |
| 48 | |
| 49 | } // Qt3DInput |
| 50 | |
| 51 | QT_END_NAMESPACE |
| 52 | |
| 53 |
