DialogLiquid.qml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import QtQuick 1.1
  2. import InvMA 1.0
  3. Rectangle {
  4. id: dlgLiquid
  5. function dlgShowHide() {
  6. if( state == "hidden" ) {
  7. state = "visible"
  8. } else {
  9. state = "hidden"
  10. }
  11. }
  12. property string hideToLeft: "toLeft"
  13. property string hideToCenter: "toCenter"
  14. property string hideToRight: "toRight"
  15. property alias inverseMouseArea: inverseMA.enabled
  16. property string hideTo: hideToCenter
  17. BorderImage {
  18. z: -1
  19. anchors.fill: parent
  20. anchors { rightMargin: -12; bottomMargin: -12 }
  21. border { left: 10; top: 10; right: 10; bottom: 10 }
  22. source: "qrc:/qml/images/shadow.png";
  23. smooth: true
  24. }
  25. InverseMouseArea {
  26. id: inverseMA
  27. anchors.fill: parent
  28. onClickedOutside: {
  29. dlgLiquid.state = "hidden"
  30. }
  31. }
  32. width: parent.width*0.9
  33. height: parent.height*0.6
  34. radius: 3
  35. color: "white"
  36. border.color: "gray"
  37. border.width: 3
  38. state: "hidden"
  39. property int howLong: 400
  40. states: [
  41. State {
  42. name: "visible"
  43. AnchorChanges { target: dlgLiquid; anchors.verticalCenter: parent.verticalCenter }
  44. AnchorChanges { target: dlgLiquid; anchors.horizontalCenter: parent.horizontalCenter }
  45. PropertyChanges { target: dlgLiquid; scale: 1 }
  46. PropertyChanges { target: dlgLiquid; z: 10 }
  47. PropertyChanges { target: dlgLiquid; opacity: 1 }
  48. },
  49. State {
  50. name: "hidden"
  51. AnchorChanges { target: dlgLiquid; anchors.top: parent.bottom }
  52. AnchorChanges {
  53. target: dlgLiquid;
  54. anchors.left: hideTo == hideToRight ? parent.right : undefined
  55. anchors.right: hideTo == hideToLeft ? parent.left : undefined
  56. }
  57. PropertyChanges { target: dlgLiquid; anchors.leftMargin: - 100 }
  58. PropertyChanges { target: dlgLiquid; scale: 0.1 }
  59. PropertyChanges { target: dlgLiquid; z: 0 }
  60. PropertyChanges { target: dlgLiquid; opacity: 0.3 }
  61. }
  62. ]
  63. transitions: [
  64. Transition {
  65. from: "hidden"; to: "visible"
  66. ParallelAnimation {
  67. NumberAnimation { duration: howLong; property: "scale"; easing.type: Easing.InOutQuad }
  68. AnchorAnimation { duration: howLong; easing.type: Easing.InOutQuad }
  69. onRunningChanged: {
  70. if( running == true ) { dlgLiquid.visible = true }
  71. }
  72. NumberAnimation { duration: howLong; property: "opacity"; }
  73. }
  74. },
  75. Transition {
  76. from: "visible"; to: "hidden"
  77. ParallelAnimation {
  78. NumberAnimation { duration: howLong; property: "scale"; easing.type: Easing.InOutQuad }
  79. AnchorAnimation { duration: howLong; easing.type: Easing.InOutQuad }
  80. onRunningChanged: {
  81. if( running == false ) { dlgLiquid.visible = false }
  82. }
  83. NumberAnimation { duration: howLong; property: "opacity"; }
  84. }
  85. }
  86. ]
  87. }