Advertisement
tasuku

Untitled

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