diff options
Diffstat (limited to 'examples/nfc/ndefeditor/nfcmanager.cpp')
-rw-r--r-- | examples/nfc/ndefeditor/nfcmanager.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/examples/nfc/ndefeditor/nfcmanager.cpp b/examples/nfc/ndefeditor/nfcmanager.cpp new file mode 100644 index 00000000..bc09b89e --- /dev/null +++ b/examples/nfc/ndefeditor/nfcmanager.cpp @@ -0,0 +1,29 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include "nfcmanager.h" + +#include <QNearFieldManager> + +#include "nfctarget.h" + +NfcManager::NfcManager(QObject *parent) : QObject(parent) +{ + m_manager = new QNearFieldManager(this); + + connect(m_manager, &QNearFieldManager::targetDetected, this, [this](QNearFieldTarget *target) { + auto jsTarget = new NfcTarget(target); + QJSEngine::setObjectOwnership(jsTarget, QJSEngine::JavaScriptOwnership); + Q_EMIT targetDetected(jsTarget); + }); +} + +void NfcManager::startTargetDetection() +{ + m_manager->startTargetDetection(QNearFieldTarget::NdefAccess); +} + +void NfcManager::stopTargetDetection() +{ + m_manager->stopTargetDetection(); +} |