Advertisement
Guest User

Untitled

a guest
Jul 24th, 2018
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 2.54 KB | None | 0 0
  1. import QtQuick 2.6
  2.  
  3. import wesual.Touch 1.0
  4.  
  5. Item {
  6.     id : delegate
  7.  
  8.     signal tapped()
  9.  
  10.     implicitWidth  : 185
  11.     implicitHeight : 185
  12.  
  13.     function resetFlip() {
  14.         icon.flipped = false;
  15.     }
  16.  
  17.     Flipable {
  18.         id : icon
  19.  
  20.         property bool flipped: false
  21.  
  22.         width  : 118
  23.         height : 118
  24.  
  25.         anchors {
  26.             top : parent.top
  27.             horizontalCenter : parent.horizontalCenter
  28.         }
  29.  
  30.         front : Image {
  31.             sourceSize.width  : 118
  32.             sourceSize.height : 118
  33.  
  34.             anchors.centerIn : parent
  35.  
  36.             source : "profession_icon_" + modelData.id + ".png"
  37.         }
  38.  
  39.         back : Image {
  40.             sourceSize.width  : 118
  41.             sourceSize.height : 118
  42.  
  43.             anchors.centerIn : parent
  44.  
  45.             source : "profession_back.png"
  46.         }
  47.  
  48.         transform: Rotation {
  49.             id : rotation
  50.  
  51.             origin.x : icon.width/2
  52.             origin.y : icon.height/2
  53.             axis.x : 0
  54.             axis.y : 1
  55.             axis.z : 0
  56.             angle : 0
  57.         }
  58.  
  59.         states: State {
  60.             name: "back"
  61.             PropertyChanges {
  62.                 target : rotation
  63.                 angle : 180
  64.             }
  65.  
  66.             when : icon.flipped
  67.         }
  68.  
  69.         transitions: Transition {
  70.             SequentialAnimation {
  71.                 NumberAnimation {
  72.                     target : rotation
  73.                     property : "angle"
  74.                     duration : 300
  75.                 }
  76.                 PauseAnimation {
  77.                     duration : 100
  78.                 }
  79.                 ScriptAction {
  80.                     script : delegate.tapped()
  81.                 }
  82.                 ScriptAction {
  83.                     script : delegate.resetFlip()
  84.                 }
  85.             }
  86.         }
  87.     }
  88.  
  89.  
  90.  
  91.     Text {
  92.         id : label
  93.  
  94.         text : modelData["name_" + template_.activeLanguage]
  95.  
  96.         color : "#706f6f"
  97.  
  98.         wrapMode: Text.Wrap
  99.         horizontalAlignment : Text.AlignHCenter
  100.  
  101.         anchors {
  102.             top : icon.bottom
  103.             horizontalCenter : parent.horizontalCenter
  104.             topMargin : 10
  105.         }
  106.  
  107.         width : parent.width - 20
  108.  
  109.         font.pixelSize : 16
  110.         font.family : "Lucida Sans Unicode"
  111.         font.capitalization: Font.AllUppercase
  112.     }
  113.  
  114.     TapArea {
  115.         id : tapArea
  116.  
  117.         anchors.fill : parent
  118.         mouseEnabled : true
  119.  
  120.         onTap : {
  121.             icon.flipped = !icon.flipped;
  122.         }
  123.     }
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement