Advertisement
tasuku

Untitled

Dec 21st, 2017
2,360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 3.07 KB | None | 0 0
  1. import QtQuick 2.0
  2. import QtQuick.Controls 2.0
  3. import QtGraphicalEffects 1.0
  4.  
  5. Item {
  6.     id: main
  7.     width: 320
  8.     height: 320
  9.  
  10.     Item {
  11.         id: container
  12.         parent: loc
  13.         x: main.x
  14.         y: main.y
  15.         width: main.width
  16.         height: main.height
  17.  
  18.         Image {
  19.             id: item
  20.             anchors.top: parent.top
  21.             anchors.topMargin: 20
  22.             anchors.horizontalCenter: parent.horizontalCenter
  23.             width: 200
  24.             height: width
  25.             source: './images/HMI_AppLauncher_%1_%2.svg'.arg(model.icon).arg(loc.pressed && (loc.index === model.index || loc.currentId === model.id) ? 'Active' : 'Inactive')
  26.             antialiasing: item.state !== ''
  27.  
  28.             Label {
  29.                 id: title
  30.                 font.pixelSize: 125
  31.                 anchors.centerIn: parent
  32.                 text: model.name.substring(0,1).toUpperCase()
  33.                 visible: model.icon === 'Blank'
  34.  
  35.                 layer.enabled: true
  36.                 layer.effect: LinearGradient  {
  37.                     gradient: Gradient {
  38.                         GradientStop { position: -0.5; color: "#6BFBFF" }
  39.                         GradientStop { position: +1.5; color: "#00ADDC" }
  40.                     }
  41.                 }
  42.             }
  43.         }
  44.         Label {
  45.             id: name
  46.             anchors.top: item.bottom
  47.             anchors.left: parent.left
  48.             anchors.right: parent.right
  49.             anchors.margins: 20
  50.             font.pixelSize: 25
  51.             font.letterSpacing: 5
  52.             wrapMode: Text.WordWrap
  53.             horizontalAlignment: Text.AlignHCenter
  54.             color: "white"
  55.             text: qsTr(model.name.toUpperCase())
  56.         }
  57.  
  58.         Behavior on x { enabled: item.state !== 'active'; NumberAnimation { duration: 400; easing.type: Easing.OutCubic } }
  59.         Behavior on y { enabled: item.state !== 'active'; NumberAnimation { duration: 400; easing.type: Easing.OutCubic } }
  60.         SequentialAnimation on rotation {
  61.             NumberAnimation { to:  5; duration: 100 }
  62.             NumberAnimation { to: -5; duration: 200 }
  63.             NumberAnimation { to:  0; duration: 100 }
  64.             running: loc.currentId !== '' && item.state !== 'active'
  65.             loops: Animation.Infinite; alwaysRunToEnd: true
  66.         }
  67.         states: [
  68.             State {
  69.                 name: 'active'
  70.                 when: loc.currentId == model.id
  71.                 PropertyChanges {
  72.                     target: container
  73.                     x: loc.mouseX - width/2
  74.                     y: loc.mouseY - height/2
  75.                     scale: 1.15
  76.                     z: 10
  77.                 }
  78.             },
  79.             State {
  80.                 when: loc.currentId !== ''
  81.                 PropertyChanges {
  82.                     target: container
  83.                     scale: 0.85
  84.                     opacity: 0.75
  85.                 }
  86.             }
  87.         ]
  88.         transitions: Transition { NumberAnimation { properties: 'scale, opacity, x, y'; duration: 150; easing.type: Easing.OutCubic} }
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement