diff options
author | Andrew O'Doherty <andrew.odoherty@qt.io> | 2017-12-21 13:49:08 +0100 |
---|---|---|
committer | Andrew O'Doherty <andrew.odoherty@qt.io> | 2018-02-01 11:55:48 +0000 |
commit | 4fec6958d7af80c10453d4d45c2e9e90500a7549 (patch) | |
tree | 8d744d7a5d3626f4dc85c4f0bdae580496e13ba2 | |
parent | 1d6687a0c3f3ac8033eaec43c8b77eef8ee5c833 (diff) | |
download | qtconnectivity-4fec6958d7af80c10453d4d45c2e9e90500a7549.tar.gz |
Revamp Qt NFC examples: poster example
Align QtNfc Module examples to QML and c++ coding conventions. This
commit is focused on the poster example.
Task-number: QTBUG-60644
Change-Id: Icd0990c24d2d0e79a67a1354d82a9f6c1bf59244
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
-rw-r--r-- | examples/nfc/poster/poster.qml | 59 | ||||
-rw-r--r-- | examples/nfc/poster/qmlposter.cpp | 2 |
2 files changed, 21 insertions, 40 deletions
diff --git a/examples/nfc/poster/poster.qml b/examples/nfc/poster/poster.qml index 3127d44e..3e2a1eda 100644 --- a/examples/nfc/poster/poster.qml +++ b/examples/nfc/poster/poster.qml @@ -128,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 @@ -150,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 { @@ -179,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"; @@ -204,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 5bf5f352..a4f98de3 100644 --- a/examples/nfc/poster/qmlposter.cpp +++ b/examples/nfc/poster/qmlposter.cpp @@ -61,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(); |