diff options
-rw-r--r-- | examples/nfc/corkboard/Mode.qml | 149 | ||||
-rw-r--r-- | examples/nfc/corkboard/corkboards.qml | 20 |
2 files changed, 88 insertions, 81 deletions
diff --git a/examples/nfc/corkboard/Mode.qml b/examples/nfc/corkboard/Mode.qml index a3df4448..36b5afd7 100644 --- a/examples/nfc/corkboard/Mode.qml +++ b/examples/nfc/corkboard/Mode.qml @@ -39,110 +39,101 @@ ** ****************************************************************************/ -import QtQuick 2.1 +import QtQuick 2.4 Item { id: page width: ListView.view.width; height: ListView.view.height - Rectangle { - id: frame - anchors.fill: parent - z: 1 - color: "transparent" - border.color: "darkred" - border.width: 10 - } Image { source: "qrc:/cork.jpg" - width: listView.width - height: listView.height + anchors.centerIn: parent + width: parent.width - 20 + height: parent.height - 20 fillMode: Image.PreserveAspectCrop - } - - Text { - anchors { horizontalCenter: parent.horizontalCenter; top: parent.top; topMargin: 10} - text: name; - font.pixelSize: 30; font.bold: true; color: "white" - style: Text.Outline; styleColor: "black" - } - - Repeater { - model: notes - Item { - id: stickyPage - z: 2 - - 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 - rotation: -listView.horizontalVelocity / 200; - Behavior on rotation { - SpringAnimation { spring: 2.0; damping: 0.15 } - } + Text { + anchors { horizontalCenter: parent.horizontalCenter; top: parent.top; topMargin: 10} + text: name; + font.pixelSize: 30; font.bold: true; color: "white" + style: Text.Outline; styleColor: "black" + } + Repeater { + model: notes Item { - id: sticky - scale: mouse.pressed ? 1 : 0.7 - rotation: mouse.pressed ? 8 : 0 - Behavior on rotation{ - NumberAnimation {duration: 200 } - } - Behavior on scale{ - NumberAnimation { duration: 200 } - } + id: stickyPage - Image { - id: stickyImage - x: 8 + -width * 0.6 / 2; y: -20 - source: "qrc:/note-yellow.png" - scale: 0.6; transformOrigin: Item.TopLeft - smooth: true - } + 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 - TextEdit { - id: myText - text: noteText - x: -104; y: 36; width: 215; height: 200 - smooth: true - font.pixelSize: 24 - readOnly: false - rotation: -8 - wrapMode: TextEdit.Wrap + rotation: -listView.horizontalVelocity / 200; + Behavior on rotation { + SpringAnimation { spring: 2.0; damping: 0.15 } } Item { - id: interactionItem - x: stickyImage.x; y: -20 - width: stickyImage.width * stickyImage.scale - height: stickyImage.height * stickyImage.scale - - MouseArea { - id: mouse - anchors.fill: parent - drag.target: stickyPage - drag.axis: Drag.XandYAxis + id: sticky + scale: mouse.pressed ? 1 : 0.7 + rotation: mouse.pressed ? 8 : 0 + Behavior on rotation{ + NumberAnimation {duration: 200 } } + Behavior on scale{ + NumberAnimation { duration: 200 } + } + Image { - id: writeButton - source: "qrc:/NfcFlag.png" - rotation: -8 // Note image itself is rotated - anchors { bottom: parent.bottom; right:parent.right } - scale: flagMouse.pressed ? 1.3 : 1 + id: stickyImage + x: 8 + -width * 0.6 / 2; y: -20 + source: "qrc:/note-yellow.png" + scale: 0.6; transformOrigin: Item.TopLeft + smooth: true + } + + TextEdit { + id: myText + text: noteText + x: -104; y: 36; width: 215; height: 200 + smooth: true + font.pixelSize: 24 + readOnly: false + rotation: -8 + wrapMode: TextEdit.Wrap + } + + Item { + id: interactionItem + x: stickyImage.x; y: -20 + width: stickyImage.width * stickyImage.scale + height: stickyImage.height * stickyImage.scale + MouseArea { - id: flagMouse + id: mouse anchors.fill: parent - //onClicked: { } + drag.target: stickyPage + drag.axis: Drag.XandYAxis + } + Image { + id: writeButton + source: "qrc:/NfcFlag.png" + rotation: -8 // Note image itself is rotated + anchors { bottom: parent.bottom; right:parent.right } + scale: flagMouse.pressed ? 1.3 : 1 + MouseArea { + id: flagMouse + anchors.fill: parent + } } } } - } - Image { - x: -width / 2; y: -height * 0.5 / 2 - source: "qrc:/tack.png" - scale: 0.7; transformOrigin: Item.TopLeft + Image { + x: -width / 2; y: -height * 0.5 / 2 + source: "qrc:/tack.png" + scale: 0.7; transformOrigin: Item.TopLeft + } } } } diff --git a/examples/nfc/corkboard/corkboards.qml b/examples/nfc/corkboard/corkboards.qml index 550dc03b..22804c06 100644 --- a/examples/nfc/corkboard/corkboards.qml +++ b/examples/nfc/corkboard/corkboards.qml @@ -44,14 +44,30 @@ import QtNfc 5.2 Rectangle { width: 800; height: 480 - color: "black" + color: "darkred" NearField { property bool requiresManualPolling: false orderMatch: false onMessageRecordsChanged: { - list.get(listView.currentIndex).notes.append({"noteText":messageRecords[0].text}) + var i; + for (i = 0; i < messageRecords.length; ++i) { + var data = ""; + if (messageRecords[i].typeNameFormat === NdefRecord.NfcRtd) { + if (messageRecords[i].type === "T") { + data = messageRecords[i].text; + } else if (messageRecords[i].type === "U") { + data = messageRecords[i].uri; + } + } + if (!data) + data = "Unknown content"; + + list.get(listView.currentIndex).notes.append( { + "noteText":data + }) + } } onPollingChanged: { |