Advertisement
Guest User

Untitled

a guest
Apr 20th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 3.17 KB | None | 0 0
  1. import QtQuick 2.1
  2. import Sailfish.Silica 1.0
  3. import QtSensors 5.0
  4.  
  5. Item {
  6.     id: root
  7.  
  8.     width: Screen.width
  9.     height: Screen.height
  10.  
  11.     property string chara: viewHelper.character
  12.     property string charaPost: viewHelper.characterMsg
  13.  
  14.     onCharaChanged: {
  15.         if (bubble.opacity != 1.0) bubble.opacity = 1.0
  16.     }
  17.  
  18.     Connections {
  19.         target: viewHelper
  20.         onApplicationRemoval: {
  21.             removalOverlay.opacity = 1.0
  22.         }
  23.     }
  24.  
  25.     OrientationSensor {
  26.         id: rotationSensor
  27.         active: true
  28.         property bool hack: if (reading.orientation) _getOrientation(reading.orientation)
  29.         property int sensorAngle: 0
  30.         property int angle: sensorAngle
  31.         function _getOrientation(value) {
  32.             switch (value) {
  33.             case 1:
  34.                 sensorAngle = 0
  35.                 break
  36.             case 2:
  37.                 sensorAngle = 180
  38.                 break
  39.             case 3:
  40.                 sensorAngle = -90
  41.                 break
  42.             case 4:
  43.                 sensorAngle = 90
  44.                 break
  45.             default:
  46.                 return false
  47.             }
  48.             return true
  49.         }
  50.     }
  51.  
  52.     MouseArea {
  53.         id: touchArea
  54.  
  55.         x: viewHelper.lastXPos
  56.         y: viewHelper.lastYPos
  57.  
  58.         width: Theme.itemSizeLarge
  59.         height: Theme.itemSizeLarge
  60.  
  61.         drag.target: touchArea
  62.         drag.minimumX: 0
  63.         drag.maximumX: root.width - touchArea.width
  64.         drag.minimumY: 0
  65.         drag.maximumY: root.height - touchArea.height
  66.  
  67.         onDoubleClicked: {
  68.             viewHelper.hideShowToggle();
  69.             //Qt.quit()
  70.         }
  71.         onClicked: {
  72.             if (bubble.opacity == 1.0) bubble.opacity = 0
  73.             else bubble.opacity = 1.0
  74.         }
  75.         onReleased: viewHelper.setTouchRegion(Qt.rect(x, y, width, height))
  76.  
  77.         Item {
  78.             id: iconItem
  79.             anchors.fill: parent
  80.             property int deltaAngle: 0
  81.             rotation: rotationSensor.angle + deltaAngle
  82.             Behavior on rotation {
  83.                 SmoothedAnimation { duration: 500 }
  84.             }
  85.             AnimatedImage {
  86.                 id: mainIcon
  87.                 anchors.centerIn: parent
  88.                 anchors.fill: parent
  89.                 source: chara
  90.             }
  91.         }
  92.     }
  93.     SpeechBubble {
  94.         id: bubble
  95.         property int deltaAngle: 0
  96.         rotation: rotationSensor.angle + deltaAngle
  97.         Behavior on rotation {
  98.             SmoothedAnimation { duration: 500 }
  99.         }
  100.         Behavior on opacity {
  101.             FadeAnimation { duration: 600 }
  102.         }
  103.         onOpacityChanged: {
  104.             if (opacity == 1.0) {
  105.                 if (showTime.running) showTime.restart()
  106.                 else showTime.start()
  107.             }
  108.         }
  109.         anchors.horizontalCenter: parent.horizontalCenter
  110.         target: touchArea
  111.         opacity: 0
  112.  
  113.         Timer {
  114.             id: showTime
  115.             interval: 3000;
  116.             onTriggered: bubble.opacity = 0
  117.         }
  118.  
  119.         post: charaPost
  120.         Component.onCompleted: {
  121.             opacity = 1.0
  122.         }
  123.     }
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement