summaryrefslogtreecommitdiff
path: root/examples/nfc
diff options
context:
space:
mode:
Diffstat (limited to 'examples/nfc')
-rw-r--r--examples/nfc/annotatedurl/annotatedurl.cpp60
-rw-r--r--examples/nfc/annotatedurl/annotatedurl.h22
-rw-r--r--examples/nfc/annotatedurl/doc/images/annotatedurl.pngbin34705 -> 7345 bytes
-rw-r--r--examples/nfc/annotatedurl/doc/images/annotatedurl2.pngbin0 -> 7685 bytes
-rw-r--r--examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc48
-rw-r--r--examples/nfc/annotatedurl/main.cpp33
-rw-r--r--examples/nfc/annotatedurl/mainwindow.cpp20
-rw-r--r--examples/nfc/annotatedurl/mainwindow.h22
-rw-r--r--examples/nfc/corkboard/Mode.qml23
-rw-r--r--examples/nfc/corkboard/corkboards.qml21
-rw-r--r--examples/nfc/corkboard/doc/src/corkboard.qdoc101
-rw-r--r--examples/nfc/corkboard/main.cpp18
-rw-r--r--examples/nfc/ndefeditor/doc/images/ndefeditor.pngbin24397 -> 13445 bytes
-rw-r--r--examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc78
-rw-r--r--examples/nfc/ndefeditor/main.cpp16
-rw-r--r--examples/nfc/ndefeditor/mainwindow.cpp60
-rw-r--r--examples/nfc/ndefeditor/mainwindow.h31
-rw-r--r--examples/nfc/ndefeditor/mimeimagerecordeditor.cpp22
-rw-r--r--examples/nfc/ndefeditor/mimeimagerecordeditor.h24
-rw-r--r--examples/nfc/ndefeditor/ndefeditor.pro1
-rw-r--r--examples/nfc/ndefeditor/textrecordeditor.cpp18
-rw-r--r--examples/nfc/ndefeditor/textrecordeditor.h24
-rw-r--r--examples/nfc/ndefeditor/urirecordeditor.cpp16
-rw-r--r--examples/nfc/ndefeditor/urirecordeditor.h26
-rw-r--r--examples/nfc/poster/poster.qml75
-rw-r--r--examples/nfc/poster/qmlposter.cpp18
26 files changed, 569 insertions, 208 deletions
diff --git a/examples/nfc/annotatedurl/annotatedurl.cpp b/examples/nfc/annotatedurl/annotatedurl.cpp
index a07aadcc..0e6b58fa 100644
--- a/examples/nfc/annotatedurl/annotatedurl.cpp
+++ b/examples/nfc/annotatedurl/annotatedurl.cpp
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtNfc module.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -37,24 +47,22 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
#include "annotatedurl.h"
-#include <qnearfieldmanager.h>
-#include <qnearfieldtarget.h>
-#include <qndefmessage.h>
-#include <qndefrecord.h>
-#include <qndefnfctextrecord.h>
-#include <qndefnfcurirecord.h>
-
-#include <QtCore/QUrl>
+#include <QtNfc/qnearfieldmanager.h>
+#include <QtNfc/qnearfieldtarget.h>
+#include <QtNfc/qndefmessage.h>
+#include <QtNfc/qndefrecord.h>
+#include <QtNfc/qndefnfctextrecord.h>
+#include <QtNfc/qndefnfcurirecord.h>
+
+#include <QtWidgets/QGridLayout>
+#include <QtWidgets/QLabel>
+#include <QtGui/QMouseEvent>
+#include <QtGui/QDesktopServices>
+#include <QtCore/QDebug>
#include <QtCore/QLocale>
-
-#include <QGridLayout>
-#include <QLabel>
-#include <QMouseEvent>
-#include <QDesktopServices>
-#include <QDebug>
+#include <QtCore/QUrl>
AnnotatedUrl::AnnotatedUrl(QObject *parent)
: QObject(parent)
@@ -81,10 +89,10 @@ AnnotatedUrl::AnnotatedUrl(QObject *parent)
qWarning() << "Platform does not support NDEF message handler registration";
manager->startTargetDetection();
- connect(manager, SIGNAL(targetDetected(QNearFieldTarget*)),
- this, SLOT(targetDetected(QNearFieldTarget*)));
- connect(manager, SIGNAL(targetLost(QNearFieldTarget*)),
- this, SLOT(targetLost(QNearFieldTarget*)));
+ connect(manager, &QNearFieldManager::targetDetected,
+ this, &AnnotatedUrl::targetDetected);
+ connect(manager, &QNearFieldManager::targetLost,
+ this, &AnnotatedUrl::targetLost);
}
AnnotatedUrl::~AnnotatedUrl()
@@ -97,8 +105,8 @@ void AnnotatedUrl::targetDetected(QNearFieldTarget *target)
if (!target)
return;
- connect(target, SIGNAL(ndefMessageRead(QNdefMessage)),
- this, SLOT(handlePolledNdefMessage(QNdefMessage)));
+ connect(target, &QNearFieldTarget::ndefMessageRead,
+ this, &AnnotatedUrl::handlePolledNdefMessage);
target->readNdefMessages();
}
@@ -160,12 +168,12 @@ void AnnotatedUrl::handleMessage(const QNdefMessage &message, QNearFieldTarget *
QNdefNfcUriRecord uriRecord(record);
url = uriRecord.uri();
-//! [handleMessage 3]
} else if (record.typeNameFormat() == QNdefRecord::Mime &&
record.type().startsWith("image/")) {
pixmap = QPixmap::fromImage(QImage::fromData(record.payload()));
-//! [handleMessage 4]
}
+//! [handleMessage 3]
+//! [handleMessage 4]
}
emit annotatedUrl(url, title, pixmap);
diff --git a/examples/nfc/annotatedurl/annotatedurl.h b/examples/nfc/annotatedurl/annotatedurl.h
index 853bdd7f..204bed5f 100644
--- a/examples/nfc/annotatedurl/annotatedurl.h
+++ b/examples/nfc/annotatedurl/annotatedurl.h
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtNfc module.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -41,7 +51,7 @@
#ifndef ANNOTATEDURL_H
#define ANNOTATEDURL_H
-#include <QNdefMessage>
+#include <QtNfc/QNdefMessage>
#include <QtCore/QObject>
@@ -50,8 +60,7 @@ QT_FORWARD_DECLARE_CLASS(QPixmap)
QT_FORWARD_DECLARE_CLASS(QNearFieldManager)
QT_FORWARD_DECLARE_CLASS(QNearFieldTarget)
-QT_USE_NAMESPACE
-
+//! [0]
class AnnotatedUrl : public QObject
{
Q_OBJECT
@@ -71,5 +80,6 @@ public slots:
private:
QNearFieldManager *manager;
};
+//! [0]
#endif // ANNOTATEDURL_H
diff --git a/examples/nfc/annotatedurl/doc/images/annotatedurl.png b/examples/nfc/annotatedurl/doc/images/annotatedurl.png
index b6cf8637..01130ecd 100644
--- a/examples/nfc/annotatedurl/doc/images/annotatedurl.png
+++ b/examples/nfc/annotatedurl/doc/images/annotatedurl.png
Binary files differ
diff --git a/examples/nfc/annotatedurl/doc/images/annotatedurl2.png b/examples/nfc/annotatedurl/doc/images/annotatedurl2.png
new file mode 100644
index 00000000..2ea6f12f
--- /dev/null
+++ b/examples/nfc/annotatedurl/doc/images/annotatedurl2.png
Binary files differ
diff --git a/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc b/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc
index 0ea57a7c..7fda040f 100644
--- a/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc
+++ b/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc
@@ -30,13 +30,53 @@
\title Annotated URL Example
\brief An example showing reading from formatted NFC Data Exchange Format (NDEF) messages.
-The Annotated URL example displays the contents of specifically formatted NFC
-Data Exchange Format (NDEF) messages read from an NFC Tag. The NDEF message
-should contain a URI record, an optional \c image/* MIME record, and one or more
-localized Text records.
+The Annotated URL example displays the contents of specifically
+formatted NFC Data Exchange Format (NDEF) messages read from an NFC
+Tag. The NDEF message should contain a URI record, an optional \c
+image/* MIME record, and one or more localized Text records.
+This is the initial state of the example:
\image annotatedurl.png
+In this example the NFC Tag used contains a text record. The UI
+gets updated accordingly to:
+
+\image annotatedurl2.png
+
+\section1 AnnotatedUrl Class Definition
+
+The \c AnnotatedUrl class wraps the \c QNearFieldManager, the class
+providing the NFC Tag detection functionality. NDEF messages are read
+by the QNearFieldManager and forwarded to a handler contained in the
+\c AnnotatedUrl class. After parsing the NDEF message the class emits
+the signal AnnotatedUrl::annotatedUrl(const QUrl &url, const QString
+&title, const QPixmap &pixmap). The UI reacts to the signal displaying
+the contents of the NDEF message.
+
+\snippet annotatedurl/annotatedurl.h 0
+
+\section1 AnnotatedUrl Handler Implementation
+
+NFC messages read by the \c QNearFieldManager are forwarded to
+AnnotatedUrl::handleMessage. The callback signature details can be
+read in \l{QNearFieldManager::registerNdefMessageHandler}.
+
+\snippet annotatedurl/annotatedurl.cpp handleMessage 1
+
+Because NFC messages are composed of several NDEF records, looping
+through all of the records allows the extraction of the 3 parameters
+to be displayed in the UI: the Uri, the Title and the Pixmap:
+
+
+\snippet annotatedurl/annotatedurl.cpp handleMessage 2
+\snippet annotatedurl/annotatedurl.cpp handleMessage 3
+
+Finally after having extracted the parameters of the NFC message the
+corresponding signal is emitted so that the UI can handle it.
+
+\snippet annotatedurl/annotatedurl.cpp handleMessage 4
+
+
\include examples-run.qdocinc
\sa {Qt NFC}
diff --git a/examples/nfc/annotatedurl/main.cpp b/examples/nfc/annotatedurl/main.cpp
index f46d303e..9ce6c1b9 100644
--- a/examples/nfc/annotatedurl/main.cpp
+++ b/examples/nfc/annotatedurl/main.cpp
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtNfc module.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -41,26 +51,21 @@
#include "annotatedurl.h"
#include "mainwindow.h"
-#include <qnearfieldmanager.h>
-#include <qndefnfctextrecord.h>
-#include <qndefnfcurirecord.h>
-
-#include <QtCore/QLocale>
-
-#include <QApplication>
+#include <QtNfc/qnearfieldmanager.h>
+#include <QtNfc/qndefnfctextrecord.h>
+#include <QtNfc/qndefnfcurirecord.h>
+#include <QtWidgets/QApplication>
int main(int argc, char *argv[])
{
- //QLocale::setDefault(QLocale(QLocale::Japanese));
-
QApplication a(argc, argv);
MainWindow mainWindow;
AnnotatedUrl annotatedUrl;
- QObject::connect(&annotatedUrl, SIGNAL(annotatedUrl(QUrl,QString,QPixmap)),
- &mainWindow, SLOT(displayAnnotatedUrl(QUrl,QString,QPixmap)));
+ QObject::connect(&annotatedUrl, &AnnotatedUrl::annotatedUrl,
+ &mainWindow, &MainWindow::displayAnnotatedUrl);
mainWindow.show();
diff --git a/examples/nfc/annotatedurl/mainwindow.cpp b/examples/nfc/annotatedurl/mainwindow.cpp
index b0c7fc18..707c03eb 100644
--- a/examples/nfc/annotatedurl/mainwindow.cpp
+++ b/examples/nfc/annotatedurl/mainwindow.cpp
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtNfc module.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -41,9 +51,9 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
-#include <QtCore/QUrl>
-#include <QtGui/QMouseEvent>
#include <QtGui/QDesktopServices>
+#include <QtGui/QMouseEvent>
+#include <QtCore/QUrl>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
diff --git a/examples/nfc/annotatedurl/mainwindow.h b/examples/nfc/annotatedurl/mainwindow.h
index 0d367171..9cfb6e7f 100644
--- a/examples/nfc/annotatedurl/mainwindow.h
+++ b/examples/nfc/annotatedurl/mainwindow.h
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtNfc module.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -41,9 +51,13 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
-#include <QMainWindow>
+#include <QtWidgets/QMainWindow>
+QT_FORWARD_DECLARE_CLASS(QMouseEvent)
QT_FORWARD_DECLARE_CLASS(QUrl)
+QT_FORWARD_DECLARE_CLASS(QPixmap)
+QT_FORWARD_DECLARE_CLASS(QString)
+QT_FORWARD_DECLARE_CLASS(QWidget)
QT_BEGIN_NAMESPACE
namespace Ui {
diff --git a/examples/nfc/corkboard/Mode.qml b/examples/nfc/corkboard/Mode.qml
index 81c42682..0d427cf5 100644
--- a/examples/nfc/corkboard/Mode.qml
+++ b/examples/nfc/corkboard/Mode.qml
@@ -1,13 +1,23 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt.io/licensing/
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the QtNfc module.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -56,7 +66,8 @@ Item {
Text {
anchors { horizontalCenter: parent.horizontalCenter; top: parent.top; topMargin: 10}
text: name;
- font.pixelSize: 30; font.bold: true; color: "white"
+ font { pixelSize: 30; bold: true }
+ color: "white"
style: Text.Outline; styleColor: "black"
}
@@ -65,8 +76,8 @@ Item {
Item {
id: stickyPage
- x: Math.random() * (listView.width-listView.width*0.30) + listView.width*0.10
- y: Math.random() * (listView.height-listView.height*0.30) + listView.height*0.10
+ x: ListView.width * (0.7 * Math.random() + 0.1)
+ y: ListView.height * (0.7 * Math.random() + 0.1)
rotation: -listView.horizontalVelocity / 200;
Behavior on rotation {
diff --git a/examples/nfc/corkboard/corkboards.qml b/examples/nfc/corkboard/corkboards.qml
index dc96865a..92cb6616 100644
--- a/examples/nfc/corkboard/corkboards.qml
+++ b/examples/nfc/corkboard/corkboards.qml
@@ -1,13 +1,23 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt.io/licensing/
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the QtNfc module.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -100,15 +110,14 @@ Rectangle {
ListElement {
name: "Work"
notes: [
- //ListElement { noteText: "To write a tag, click the red flag of a note and then touch a tag" },
- ListElement { noteText: "https://www.qt.io" }
+ ListElement { noteText: "https://www.qt.io" },
+ ListElement { noteText: "To write a tag, click the red flag of a note and then touch a tag" }
]
}
}
ListView {
id: listView
-
anchors.fill: parent
orientation: ListView.Horizontal
snapMode: ListView.SnapOneItem
diff --git a/examples/nfc/corkboard/doc/src/corkboard.qdoc b/examples/nfc/corkboard/doc/src/corkboard.qdoc
index 29ad8eac..ac21187b 100644
--- a/examples/nfc/corkboard/doc/src/corkboard.qdoc
+++ b/examples/nfc/corkboard/doc/src/corkboard.qdoc
@@ -30,13 +30,106 @@
\title QML CorkBoard Example
\brief A QML example about displaying NFC Data Exchange Format (NDEF) messages.
-The QML CorkBoard example displays the contents of NDEF messages read from an
-NFC Tag. Each newly detected NDEF message is added to the corkboard and can be
-dragged into an arbitrary position on the board. The corkboard has a \e Personal
-and \e Work space. The workspace can be changed by sliding left or right.
+The QML corkboard example displays the contents of NDEF messages read
+from an NFC Tag. Each newly detected NDEF message is added to the
+corkboard and can be dragged into an arbitrary position on the
+board. The corkboard has a \e Personal and \e Work space. The
+workspace can be changed by sliding left or right.
+
\image corkboard.png
+\section1 Implementation details
+In the corkboard example, we use the following .qml files:
+ \list
+ \li corkboards.qml
+ \li Mode.qml
+ \endlist
+
+The main.cpp holds the application logic to load the main view stored
+in the corkboards.qml file.
+
+\snippet corkboard/main.cpp 0
+
+\section1 corkboards.qml details
+There are two basic QML components in this file:
+ \list
+ \li NearField
+ \li ListView
+ \endlist
+
+The first time the NearField QML type is instantiated, the
+Component.onCompleted handler will start the NFC polling process. The
+\l [Qml] {NearField} {onMessageRecordsChanged} handler parses NFC
+Messages that are detected by the NearField component and builds up a
+data model that is passed into the ListView. Additionally, every time the
+NearField manager stops the polling process, the onPollingChanged
+handler restarts it.
+
+\quotefromfile corkboard/corkboards.qml
+\skipto NearField
+\printuntil onMessageRecordsChanged
+\dots 8
+\skipuntil }
+\skipto onPollingChanged
+\printuntil onPollingChanged
+\dots 8
+\skipuntil }
+\skipto Component
+\printuntil Component
+\dots 8
+\skipuntil }
+\printline }
+\skipto ListModel
+\printto ListModel
+
+The ListView component takes a ListModel as parameter (built from the
+NFC records). The view of each of the items of the model is defined by
+the Mode component (its implementation details can be found in the
+file Mode.qml). The data model consists of a list of corkboards. Each
+corkboard can display multiple NFC text message records.
+
+\quotefromfile corkboard/corkboards.qml
+\skipto ListView
+\printuntil id
+\dots 8
+\skipto model
+\printuntil model
+\dots 8
+\skipto delegate
+\printuntil delegate
+\skipto }
+\printline }
+
+\section1 Mode.qml details
+
+A corkboard title is displayed for each of the items that form part
+of the data model:
+
+\quotefromfile corkboard/Mode.qml
+\skipto Text
+\printuntil }
+\printuntil }
+
+Every text record that was read from an NFC message, is represented by
+a sticky note with its own position on the display. Initially the
+position is set randomly. The text on the sticky note is set on a
+TextField.
+
+\quotefromfile corkboard/Mode.qml
+\skipto Repeater
+\printuntil y:
+\skipto Item
+\dots 16
+\printuntil sticky
+\dots 20
+\skipto TextEdit
+\printuntil noteText
+\dots 24
+\skipto }
+\printuntil }
+\dots 20
+
\include examples-run.qdocinc
\sa {Qt NFC}
diff --git a/examples/nfc/corkboard/main.cpp b/examples/nfc/corkboard/main.cpp
index 320412ff..74fad72f 100644
--- a/examples/nfc/corkboard/main.cpp
+++ b/examples/nfc/corkboard/main.cpp
@@ -1,13 +1,23 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt.io/licensing/
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the QtNfc module.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -43,6 +53,7 @@
#include <QtQml/QQmlEngine>
#include <QtQuick/QQuickView>
+//! [0]
int main(int argc, char *argv[])
{
QGuiApplication application(argc, argv);
@@ -52,3 +63,4 @@ int main(int argc, char *argv[])
view.show();
return application.exec();
}
+//! [0]
diff --git a/examples/nfc/ndefeditor/doc/images/ndefeditor.png b/examples/nfc/ndefeditor/doc/images/ndefeditor.png
index 9a5fbba7..d203e474 100644
--- a/examples/nfc/ndefeditor/doc/images/ndefeditor.png
+++ b/examples/nfc/ndefeditor/doc/images/ndefeditor.png
Binary files differ
diff --git a/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc b/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc
index ed7d2bba..eb638200 100644
--- a/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc
+++ b/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc
@@ -3,7 +3,7 @@
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the documentation of the Qt local connectivty modules.
+** This file is part of the documentation of the Qt local connectivity modules.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
@@ -30,12 +30,82 @@
\title NDEF Editor Example
\brief An example about reading and writing NFC Data Exchange Format (NDEF) messages to NFC Forum Tags.
-The NDEF Editor example reads and writes NFC Data Exchange Format (NDEF)
-messages to NFC Forum Tags. NDEF messages can be composed by adding records of
-supported types.
+The NDEF Editor example reads and writes NFC Data Exchange Format
+(NDEF) messages to NFC Forum Tags. NDEF messages can be composed by
+adding records of supported types. Additionally, NDEF messages can be
+loaded/saved from/into a file located in the file system of the
+machine where the application is running.
\image ndefeditor.png
+\section1 NFC Tag detection
+
+The MainWindow class is able to detect if a NFC Tag is in the range
+for read/write operations. It can also detect if connectivity has been
+lost. This is achieved by connecting the MainWindow class private
+handlers to the signals QNearFieldManager::targetDetected and
+QNearFieldManager::targetLost.
+
+\snippet ndefeditor/mainwindow.cpp QNearFieldManager init
+
+Through the UI a user requests when to start the detection of a NFC
+Tag by calling the method QNearFieldManager::startTargetDetection.
+
+\snippet ndefeditor/mainwindow.cpp QNearFieldManager start detection
+
+Once the target is detected the MainWindow connects the following
+signals to its internal private slots:
+QNearFieldTarget::ndefMessageRead, QNearFieldTarget::NdefReadError,
+QNearFieldTarget::ndefMessagesWritten,
+QNearFieldTarget::NdefWriteError and QNearFieldTarget::error
+
+\snippet ndefeditor/mainwindow.cpp QNearFieldTarget detected
+
+If during the process of reading or writing to a NFC Tag the
+connection is lost, the MainWindow reacts to this event by
+scheduling the target deletion (QObject::deleteLater).
+
+\snippet ndefeditor/mainwindow.cpp QNearFieldTarget lost
+
+\section1 Record creation
+
+The main window of the ndefeditor example manages the composition and
+creation of NFC records. The UI contains a QScrollArea where
+RecordEditors are added dynamically on a user requests basis. The
+following methods of the MainWindow class provide an interface towards
+each of the record editing classes managing the different types of
+records.
+
+\snippet ndefeditor/mainwindow.h 0
+
+The following sections explain each of the record editing classes.
+\section1 Record editing classes
+
+\section2 TextRecordEditor
+
+The TextRecordEditor is a QWidget that can handle editing the values
+of text record that has been requested by the user. For each text
+record, there is a new instance of this class.
+
+\snippet ndefeditor/textrecordeditor.h 0
+
+\section2 UriRecordEditor
+
+The UriRecordEditor is a QWidget that can handle editing the values of
+Uri record that has been requested by the user. For each new Uri
+record there is a new instance of this class.
+
+\snippet ndefeditor/urirecordeditor.h 0
+
+\section2 MimeImageRecordEditor
+
+The UriRecordEditor is a QWidget that can handle editing the values of
+a Mime Image record that has been requested by the user. For each Mime
+Image record there is a new instance of this class.
+
+\snippet ndefeditor/mimeimagerecordeditor.h 0
+
+
\include examples-run.qdocinc
\sa {Qt NFC}
diff --git a/examples/nfc/ndefeditor/main.cpp b/examples/nfc/ndefeditor/main.cpp
index c60517dc..6ea32a57 100644
--- a/examples/nfc/ndefeditor/main.cpp
+++ b/examples/nfc/ndefeditor/main.cpp
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
diff --git a/examples/nfc/ndefeditor/mainwindow.cpp b/examples/nfc/ndefeditor/mainwindow.cpp
index 28c2054a..38865b88 100644
--- a/examples/nfc/ndefeditor/mainwindow.cpp
+++ b/examples/nfc/ndefeditor/mainwindow.cpp
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -45,21 +55,18 @@
#include "urirecordeditor.h"
#include "mimeimagerecordeditor.h"
-#include <QtCore/QTime>
-#include <QMenu>
-#include <QVBoxLayout>
-#include <QFrame>
-#include <QLabel>
-#include <QFileDialog>
-
-#include <qnearfieldmanager.h>
-#include <qnearfieldtarget.h>
-#include <qndefrecord.h>
-#include <qndefnfctextrecord.h>
-#include <qndefnfcurirecord.h>
-#include <qndefmessage.h>
+#include <QtNfc/qndefnfcurirecord.h>
+#include <QtNfc/qndefnfctextrecord.h>
+#include <QtNfc/qndefrecord.h>
+#include <QtNfc/qndefmessage.h>
+#include <QtNfc/qnearfieldmanager.h>
+#include <QtNfc/qnearfieldtarget.h>
-#include <QtCore/QDebug>
+#include <QtWidgets/QMenu>
+#include <QtWidgets/QVBoxLayout>
+#include <QtWidgets/QFrame>
+#include <QtWidgets/QLabel>
+#include <QtWidgets/QFileDialog>
class EmptyRecordLabel : public QLabel
{
@@ -136,10 +143,10 @@ MainWindow::MainWindow(QWidget *parent)
//! [QNearFieldManager init]
m_manager = new QNearFieldManager(this);
- connect(m_manager, SIGNAL(targetDetected(QNearFieldTarget*)),
- this, SLOT(targetDetected(QNearFieldTarget*)));
- connect(m_manager, SIGNAL(targetLost(QNearFieldTarget*)),
- this, SLOT(targetLost(QNearFieldTarget*)));
+ connect(m_manager, &QNearFieldManager::targetDetected,
+ this, &MainWindow::targetDetected);
+ connect(m_manager, &QNearFieldManager::targetLost,
+ this, &MainWindow::targetLost);
//! [QNearFieldManager init]
}
@@ -229,19 +236,16 @@ void MainWindow::targetDetected(QNearFieldTarget *target)
case NoAction:
break;
case ReadNdef:
- connect(target, SIGNAL(ndefMessageRead(QNdefMessage)),
- this, SLOT(ndefMessageRead(QNdefMessage)));
- connect(target, SIGNAL(error(QNearFieldTarget::Error,QNearFieldTarget::RequestId)),
- this, SLOT(targetError(QNearFieldTarget::Error,QNearFieldTarget::RequestId)));
+ connect(target, &QNearFieldTarget::ndefMessageRead, this, &MainWindow::ndefMessageRead);
+ connect(target, &QNearFieldTarget::error, this, &MainWindow::targetError);
m_request = target->readNdefMessages();
if (!m_request.isValid()) // cannot read messages
targetError(QNearFieldTarget::NdefReadError, m_request);
break;
case WriteNdef:
- connect(target, SIGNAL(ndefMessagesWritten()), this, SLOT(ndefMessageWritten()));
- connect(target, SIGNAL(error(QNearFieldTarget::Error,QNearFieldTarget::RequestId)),
- this, SLOT(targetError(QNearFieldTarget::Error,QNearFieldTarget::RequestId)));
+ connect(target, &QNearFieldTarget::ndefMessagesWritten, this, &MainWindow::ndefMessageWritten);
+ connect(target, &QNearFieldTarget::error, this, &MainWindow::targetError);
m_request = target->writeNdefMessages(QList<QNdefMessage>() << ndefMessage());
if (!m_request.isValid()) // cannot write messages
diff --git a/examples/nfc/ndefeditor/mainwindow.h b/examples/nfc/ndefeditor/mainwindow.h
index 69eeee30..234efcd2 100644
--- a/examples/nfc/ndefeditor/mainwindow.h
+++ b/examples/nfc/ndefeditor/mainwindow.h
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -41,16 +51,12 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
-#include <QMainWindow>
+#include <QtNfc/qnearfieldtarget.h>
-#include <qnearfieldtarget.h>
+#include <QtWidgets/QMainWindow>
-QT_BEGIN_NAMESPACE
-class QNearFieldManager;
-class QNdefMessage;
-QT_END_NAMESPACE
-
-QT_USE_NAMESPACE
+QT_FORWARD_DECLARE_CLASS(QNearFieldManager)
+QT_FORWARD_DECLARE_CLASS(QNdefMessage)
QT_BEGIN_NAMESPACE
namespace Ui {
@@ -67,11 +73,12 @@ public:
~MainWindow();
private slots:
+ //! [0]
void addNfcTextRecord();
void addNfcUriRecord();
void addMimeImageRecord();
void addEmptyRecord();
-
+ //! [0]
void clearMessage();
void loadMessage();
diff --git a/examples/nfc/ndefeditor/mimeimagerecordeditor.cpp b/examples/nfc/ndefeditor/mimeimagerecordeditor.cpp
index 5ed733a4..8044e8a6 100644
--- a/examples/nfc/ndefeditor/mimeimagerecordeditor.cpp
+++ b/examples/nfc/ndefeditor/mimeimagerecordeditor.cpp
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -41,9 +51,9 @@
#include "mimeimagerecordeditor.h"
#include "ui_mimeimagerecordeditor.h"
-#include <QBuffer>
-#include <QFileDialog>
-#include <QImageReader>
+#include <QtGui/QImageReader>
+#include <QtWidgets/QFileDialog>
+#include <QtCore/QBuffer>
static QString imageFormatToMimeType(const QByteArray &format)
{
diff --git a/examples/nfc/ndefeditor/mimeimagerecordeditor.h b/examples/nfc/ndefeditor/mimeimagerecordeditor.h
index ef6506f3..44cd084b 100644
--- a/examples/nfc/ndefeditor/mimeimagerecordeditor.h
+++ b/examples/nfc/ndefeditor/mimeimagerecordeditor.h
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -42,9 +52,9 @@
#ifndef MIMEIMAGERECORDEDITOR_H
#define MIMEIMAGERECORDEDITOR_H
-#include <QWidget>
+#include <QtNfc/qndefrecord.h>
-#include <qndefrecord.h>
+#include <QtWidgets/QWidget>
QT_USE_NAMESPACE
@@ -54,7 +64,7 @@ namespace Ui {
}
QT_END_NAMESPACE
-
+//! [0]
class MimeImageRecordEditor : public QWidget
{
Q_OBJECT
@@ -73,5 +83,5 @@ private:
private slots:
void on_mimeImageOpen_clicked();
};
-
+//! [0]
#endif // MIMEIMAGERECORDEDITOR_H
diff --git a/examples/nfc/ndefeditor/ndefeditor.pro b/examples/nfc/ndefeditor/ndefeditor.pro
index 43ab47fa..4b81c17c 100644
--- a/examples/nfc/ndefeditor/ndefeditor.pro
+++ b/examples/nfc/ndefeditor/ndefeditor.pro
@@ -1,4 +1,5 @@
QT += nfc widgets
+requires(qtConfig(filedialog))
TARGET = ndefeditor
TEMPLATE = app
diff --git a/examples/nfc/ndefeditor/textrecordeditor.cpp b/examples/nfc/ndefeditor/textrecordeditor.cpp
index 77e8a085..381ff88f 100644
--- a/examples/nfc/ndefeditor/textrecordeditor.cpp
+++ b/examples/nfc/ndefeditor/textrecordeditor.cpp
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -41,8 +51,6 @@
#include "textrecordeditor.h"
#include "ui_textrecordeditor.h"
-#include <QtCore/QDebug>
-
TextRecordEditor::TextRecordEditor(QWidget *parent) :
QWidget(parent),
ui(new Ui::TextRecordEditor)
diff --git a/examples/nfc/ndefeditor/textrecordeditor.h b/examples/nfc/ndefeditor/textrecordeditor.h
index 2699cdb5..df3a872c 100644
--- a/examples/nfc/ndefeditor/textrecordeditor.h
+++ b/examples/nfc/ndefeditor/textrecordeditor.h
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -41,9 +51,9 @@
#ifndef TEXTRECORDEDITOR_H
#define TEXTRECORDEDITOR_H
-#include <QWidget>
+#include <QtNfc/qndefnfctextrecord.h>
-#include <qndefnfctextrecord.h>
+#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
namespace Ui {
@@ -51,8 +61,7 @@ namespace Ui {
}
QT_END_NAMESPACE
-QT_USE_NAMESPACE
-
+//! [0]
class TextRecordEditor : public QWidget
{
Q_OBJECT
@@ -67,5 +76,6 @@ public:
private:
Ui::TextRecordEditor *ui;
};
+//! [0]
#endif // TEXTRECORDEDITOR_H
diff --git a/examples/nfc/ndefeditor/urirecordeditor.cpp b/examples/nfc/ndefeditor/urirecordeditor.cpp
index 4ea12768..4088aece 100644
--- a/examples/nfc/ndefeditor/urirecordeditor.cpp
+++ b/examples/nfc/ndefeditor/urirecordeditor.cpp
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
diff --git a/examples/nfc/ndefeditor/urirecordeditor.h b/examples/nfc/ndefeditor/urirecordeditor.h
index 156b5147..aa3f4dfc 100644
--- a/examples/nfc/ndefeditor/urirecordeditor.h
+++ b/examples/nfc/ndefeditor/urirecordeditor.h
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -38,13 +48,12 @@
**
****************************************************************************/
-
#ifndef URIRECORDEDITOR_H
#define URIRECORDEDITOR_H
-#include <QWidget>
+#include <QtNfc/qndefnfcurirecord.h>
-#include <qndefnfcurirecord.h>
+#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
namespace Ui {
@@ -52,8 +61,7 @@ namespace Ui {
}
QT_END_NAMESPACE
-QT_USE_NAMESPACE
-
+//! [0]
class UriRecordEditor : public QWidget
{
Q_OBJECT
@@ -68,5 +76,5 @@ public:
private:
Ui::UriRecordEditor *ui;
};
-
+//! [0]
#endif // URIRECORDEDITOR_H
diff --git a/examples/nfc/poster/poster.qml b/examples/nfc/poster/poster.qml
index d57ed5d9..3e2a1eda 100644
--- a/examples/nfc/poster/poster.qml
+++ b/examples/nfc/poster/poster.qml
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -118,11 +128,9 @@ Rectangle {
Text {
id: touchText
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.verticalCenter: parent.verticalCenter
+ anchors { horizontalCenter: parent.horizontalCenter; horizontalCenterOffset: parent.verticalCenter }
text: "Touch an NFC tag with at least one Text and one URI record."
- font.bold: true
- font.pointSize: 18
+ font { italic: true; pointSize: 18 }
wrapMode: Text.WordWrap
width: root.width*0.75
horizontalAlignment: Text.AlignHCenter
@@ -140,27 +148,22 @@ Rectangle {
Text {
id: posterText
- anchors.horizontalCenter: parent.right
- anchors.horizontalCenterOffset: - parent.width / 4
y: -height
- font.bold: true
- font.pointSize: 18
+ anchors { horizontalCenter: parent.right; horizontalCenterOffset: - parent.width / 4 }
+ font { italic: true; pointSize: 18 }
}
Text {
id: posterUrl
- anchors.horizontalCenter: parent.right
- anchors.horizontalCenterOffset: - parent.width / 4
y: parent.height
- font.italic: true
- font.pointSize: 14
+ anchors { horizontalCenter: parent.right; horizontalCenterOffset: - parent.width / 4 }
+ font { italic: true; pointSize: 14 }
}
MouseArea {
id: openMouseArea
anchors.fill: parent
enabled: root.state == "show"
-
onClicked: Qt.openUrlExternally(posterUrl.text)
Rectangle {
@@ -169,14 +172,10 @@ Rectangle {
height: 50
color: "lightsteelblue"
opacity: 0.3
- anchors.top: parent.top
- anchors.right: close.left
- anchors.rightMargin: 10
-
+ anchors { top: parent.top; right: close.left; rightMargin: 10 }
MouseArea {
id: touchMouseArea
anchors.fill: parent
-
onClicked: {
if (root.state == "") {
root.state = "show";
@@ -194,34 +193,26 @@ Rectangle {
color: "black"
radius: 0
opacity: 0.3
- anchors.top: parent.top
- anchors.topMargin: 0
- anchors.right: parent.right
- anchors.rightMargin: 0
-
+ anchors { top: parent.top; topMargin: 0; right: parent.right; rightMargin: 0 }
MouseArea {
id: closeMouseArea
anchors.fill: parent
-
onClicked: Qt.quit();
}
}
}
- states: [
- State {
- name: "show"
- PropertyChanges { target: posterText; y: root.height / 3 }
- PropertyChanges { target: posterUrl; y: 2 * root.height / 3 }
- PropertyChanges { target: posterImage; x: root.width / 20 }
- PropertyChanges { target: touchText; opacity: 0 }
- }
- ]
+ states: State {
+ name: "show"
+ PropertyChanges { target: posterText; y: root.height / 3 }
+ PropertyChanges { target: posterUrl; y: 2 * root.height / 3 }
+ PropertyChanges { target: posterImage; x: root.width / 20 }
+ PropertyChanges { target: touchText; opacity: 0 }
+ }
- transitions: [
- Transition {
- PropertyAnimation { easing.type: Easing.OutQuad; properties: "x,y" }
- PropertyAnimation { property: "opacity"; duration: 125 }
- }
- ]
+
+ transitions: Transition {
+ PropertyAnimation { easing.type: Easing.OutQuad; properties: "x,y" }
+ PropertyAnimation { property: "opacity"; duration: 125 }
+ }
}
diff --git a/examples/nfc/poster/qmlposter.cpp b/examples/nfc/poster/qmlposter.cpp
index eb96e1c2..a4f98de3 100644
--- a/examples/nfc/poster/qmlposter.cpp
+++ b/examples/nfc/poster/qmlposter.cpp
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -51,7 +61,7 @@ int main(int argc, char *argv[])
view.setResizeMode(QQuickView::SizeRootObjectToView);
// Qt.quit() called in embedded .qml by default only emits
// quit() signal, so do this (optionally use Qt.exit()).
- QObject::connect(view.engine(), SIGNAL(quit()), qApp, SLOT(quit()));
+ QObject::connect(view.engine(), &QQmlEngine::quit, qApp, &QGuiApplication::quit);
view.setGeometry(QRect(100, 100, 640, 360));
view.show();
return application.exec();