Advertisement
Guest User

Untitled

a guest
May 27th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. import QtQuick 2.0
  2. import QtGraphicalEffects 1.12
  3. import QtMultimedia 5.12
  4. import net.standby 1.0
  5.  
  6. Item {
  7. id: container
  8. height: 44
  9. width: 44
  10. property int radius: 5
  11. property int borderWidth: 2
  12. property color borderColor: "white"
  13.  
  14. visible: available
  15.  
  16. property alias iconColor: backgroundRectangle.color
  17. property alias iconSource: iconImage.source
  18. property alias text: textField.text
  19. property alias textColor: textField.color
  20.  
  21. property ButtonModel buttonModel
  22.  
  23. property bool active: buttonModel.active
  24. property bool standby: buttonModel.standby
  25. property bool available: buttonModel.available
  26. property bool delay: buttonModel.delay
  27. property bool error: buttonModel.error
  28. property bool disabled: buttonModel.disabled
  29.  
  30. DropShadow {
  31. id: shadow
  32. anchors.fill: backgroundRectangle
  33. horizontalOffset: 0
  34. verticalOffset: 0
  35. radius: 12.0
  36. samples: 20
  37. color: "#000000"
  38. source: backgroundRectangle
  39. spread: 0
  40. }
  41.  
  42. SequentialAnimation {
  43. id: animation
  44. running: delay
  45.  
  46. loops: Animation.Infinite
  47. PropertyAnimation { target: backgroundRectangle; property: "border.color"; to: "#ff0000" ; duration: 1 }
  48. PauseAnimation { duration: 499 }
  49. PropertyAnimation { target: backgroundRectangle; property: "border.color"; to: container.borderColor ; duration: 1 }
  50. PauseAnimation { duration: 499 }
  51. }
  52.  
  53. Rectangle {
  54. id: backgroundRectangle
  55. anchors.fill: parent
  56. color: "white"
  57. radius: container.radius
  58.  
  59. border.width: container.borderWidth
  60. border.color: !delay ? (active ? "#ff0000" : container.borderColor) : "white"
  61.  
  62.  
  63. }
  64.  
  65. Rectangle {
  66. id: indicator
  67. anchors.left: parent.left
  68. anchors.top: parent.top
  69. anchors.topMargin: 15
  70. anchors.leftMargin: 15
  71. height: 15
  72. width: height
  73. radius: width*0.5
  74.  
  75. color: container.standby ? "#ff0000" : "black"
  76. }
  77.  
  78.  
  79. Image {
  80. id: iconImage
  81. anchors.fill: parent
  82. }
  83.  
  84. Text {
  85. id: textField
  86. anchors.centerIn: parent
  87. anchors.fill: parent
  88. anchors.margins: 3
  89. color: "white"
  90. font.pointSize: 12
  91. wrapMode: Text.Wrap
  92. horizontalAlignment: Text.AlignHCenter
  93. verticalAlignment: Text.AlignVCenter
  94. }
  95.  
  96. Audio {
  97. id: buttonClick
  98. source: "qrc:/sounds/Click.wav"
  99. }
  100.  
  101. MouseArea {
  102. enabled: !error
  103. anchors.fill: parent
  104. onPressed: {
  105. buttonModel.pressed = true
  106. buttonClick.play()
  107. shadow.radius = 6.0
  108. }
  109. onReleased: { buttonModel.pressed = false; shadow.radius = 12.0; }
  110. }
  111.  
  112. Image {
  113. visible: error
  114. anchors.fill: parent
  115. source: "qrc:/images/error_overlay.svg"
  116. }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement