Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import QtQuick 2.1
- import Sailfish.Silica 1.0
- import QtSensors 5.0
- Item {
- id: root
- width: Screen.width
- height: Screen.height
- property string chara: viewHelper.character
- property string charaPost: viewHelper.characterMsg
- onCharaChanged: {
- if (bubble.opacity != 1.0) bubble.opacity = 1.0
- }
- Connections {
- target: viewHelper
- onApplicationRemoval: {
- removalOverlay.opacity = 1.0
- }
- }
- OrientationSensor {
- id: rotationSensor
- active: true
- property bool hack: if (reading.orientation) _getOrientation(reading.orientation)
- property int sensorAngle: 0
- property int angle: sensorAngle
- function _getOrientation(value) {
- switch (value) {
- case 1:
- sensorAngle = 0
- break
- case 2:
- sensorAngle = 180
- break
- case 3:
- sensorAngle = -90
- break
- case 4:
- sensorAngle = 90
- break
- default:
- return false
- }
- return true
- }
- }
- MouseArea {
- id: touchArea
- x: viewHelper.lastXPos
- y: viewHelper.lastYPos
- width: Theme.itemSizeLarge
- height: Theme.itemSizeLarge
- drag.target: touchArea
- drag.minimumX: 0
- drag.maximumX: root.width - touchArea.width
- drag.minimumY: 0
- drag.maximumY: root.height - touchArea.height
- onDoubleClicked: {
- viewHelper.hideShowToggle();
- //Qt.quit()
- }
- onClicked: {
- if (bubble.opacity == 1.0) bubble.opacity = 0
- else bubble.opacity = 1.0
- }
- onReleased: viewHelper.setTouchRegion(Qt.rect(x, y, width, height))
- Item {
- id: iconItem
- anchors.fill: parent
- property int deltaAngle: 0
- rotation: rotationSensor.angle + deltaAngle
- Behavior on rotation {
- SmoothedAnimation { duration: 500 }
- }
- AnimatedImage {
- id: mainIcon
- anchors.centerIn: parent
- anchors.fill: parent
- source: chara
- }
- }
- }
- SpeechBubble {
- id: bubble
- property int deltaAngle: 0
- rotation: rotationSensor.angle + deltaAngle
- Behavior on rotation {
- SmoothedAnimation { duration: 500 }
- }
- Behavior on opacity {
- FadeAnimation { duration: 600 }
- }
- onOpacityChanged: {
- if (opacity == 1.0) {
- if (showTime.running) showTime.restart()
- else showTime.start()
- }
- }
- anchors.horizontalCenter: parent.horizontalCenter
- target: touchArea
- opacity: 0
- Timer {
- id: showTime
- interval: 3000;
- onTriggered: bubble.opacity = 0
- }
- post: charaPost
- Component.onCompleted: {
- opacity = 1.0
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement