From 4fec6958d7af80c10453d4d45c2e9e90500a7549 Mon Sep 17 00:00:00 2001 From: Andrew O'Doherty Date: Thu, 21 Dec 2017 13:49:08 +0100 Subject: 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 --- examples/nfc/poster/poster.qml | 59 +++++++++++++-------------------------- examples/nfc/poster/qmlposter.cpp | 2 +- 2 files changed, 21 insertions(+), 40 deletions(-) (limited to 'examples') 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(); -- cgit v1.2.3