DialogEdit.qml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. import QtQuick 1.1
  2. Rectangle {
  3. id: dlgEdit
  4. signal clickedOk
  5. signal clickedCancel
  6. property string title: ""
  7. property int fontTitleSize: 24
  8. property string text: ""
  9. property int fontTextSize: 22
  10. property alias textEdit: textEditWidget.text
  11. function show() {
  12. dlgEdit.state = "visible"
  13. }
  14. function hide() {
  15. dlgText.state = "hidden"
  16. }
  17. width: parent.width*0.9
  18. height: headerDlg.height +
  19. dlgText.height +
  20. rowButtons.height +
  21. dlgText.anchors.topMargin +
  22. textEditWidget.height + textEditWidget.anchors.topMargin +
  23. rowButtons.anchors.topMargin + 20
  24. state: "hidden"
  25. //radius: 10
  26. color: "white"
  27. border.color: "gray"
  28. border.width: 3
  29. smooth: true
  30. BorderImage {
  31. z: -1
  32. anchors.fill: parent
  33. anchors { /*leftMargin: -8; topMargin: -8;*/ rightMargin: -12; bottomMargin: -12 }
  34. border { left: 10; top: 10; right: 10; bottom: 10 }
  35. source: "qrc:/qml/images/shadow.png";
  36. smooth: true
  37. }
  38. Rectangle {
  39. id: headerDlg
  40. anchors.top: parent.top
  41. anchors.left: parent.left
  42. width: parent.width
  43. height: 70
  44. gradient: Gradient {
  45. GradientStop { position: 0; color: "#919191" }
  46. GradientStop { position: 1; color: "#666666" }
  47. }
  48. Text {
  49. anchors.centerIn: parent
  50. font.pixelSize: dlgEdit.fontTitleSize
  51. color: "white"
  52. text: dlgEdit.title
  53. }
  54. }
  55. Text {
  56. id: dlgText
  57. anchors.top: headerDlg.bottom; anchors.topMargin: 20
  58. anchors.left: parent.left; anchors.leftMargin: 10
  59. font.pixelSize: dlgEdit.fontTextSize
  60. width: parent.width - 10
  61. text: dlgEdit.text
  62. clip: true
  63. HorizontalGradient {
  64. anchors.left: parent.left
  65. anchors.top: parent.top
  66. height: parent.height
  67. width: parent.width
  68. gradient: Gradient {
  69. GradientStop { color: "transparent"; position: 0 }
  70. GradientStop { color: "transparent"; position: 0.8 }
  71. GradientStop { color: "white"; position: 0.95 }
  72. GradientStop { color: "white"; position: 1 }
  73. }
  74. }
  75. }
  76. MyTextInput {
  77. id: textEditWidget
  78. anchors.top: dlgText.bottom
  79. anchors.topMargin: 10
  80. anchors.left: parent.left; anchors.leftMargin: 10
  81. anchors.right: parent.right; anchors.rightMargin: 10
  82. height: 50
  83. }
  84. /****************************************************/
  85. Row {
  86. id: rowButtons
  87. anchors.top: textEditWidget.bottom; anchors.topMargin: 20
  88. anchors.left: parent.left; anchors.leftMargin: 10
  89. spacing: 20
  90. Button {
  91. id: buttonOk
  92. height: 70
  93. text: qsTr("Ok")
  94. width: dlgEdit.width/2 - 20
  95. onClicked: {
  96. dlgEdit.clickedOk()
  97. dlgEdit.state = "hidden"
  98. }
  99. }
  100. Button {
  101. id: buttonCancel
  102. height: 70
  103. text: qsTr( "Cancel" )
  104. width: dlgEdit.width/2 - 20
  105. onClicked: {
  106. dlgEdit.clickedCancel()
  107. dlgEdit.state = "hidden"
  108. }
  109. }
  110. }
  111. /****************************************************/
  112. property int howLong: 400
  113. states: [
  114. State {
  115. name: "visible"
  116. AnchorChanges { target: dlgEdit; anchors.verticalCenter: parent.verticalCenter }
  117. AnchorChanges { target: dlgEdit; anchors.horizontalCenter: parent.horizontalCenter }
  118. PropertyChanges { target: dlgEdit; scale: 1 }
  119. PropertyChanges { target: dlgEdit; z: 10 }
  120. },
  121. State {
  122. name: "hidden"
  123. AnchorChanges { target: dlgEdit; anchors.top: parent.bottom }
  124. AnchorChanges { target: dlgEdit; anchors.horizontalCenter: parent.horizontalCenter; }
  125. PropertyChanges { target: dlgEdit; anchors.leftMargin: -100 }
  126. PropertyChanges { target: dlgEdit; scale: 0.1 }
  127. PropertyChanges { target: dlgEdit; z: 0 }
  128. }
  129. ]
  130. transitions: [
  131. Transition {
  132. from: "hidden"; to: "visible"
  133. ParallelAnimation {
  134. NumberAnimation { duration: howLong; property: "scale"; easing.type: Easing.InOutQuad }
  135. AnchorAnimation { duration: howLong; easing.type: Easing.InOutQuad }
  136. onRunningChanged: {
  137. if( running == true ) { dlgAccountOptions.visible = true }
  138. }
  139. }
  140. },
  141. Transition {
  142. from: "visible"; to: "hidden"
  143. ParallelAnimation {
  144. NumberAnimation { duration: howLong; property: "scale"; easing.type: Easing.InOutQuad }
  145. AnchorAnimation { duration: howLong; easing.type: Easing.InOutQuad }
  146. onRunningChanged: {
  147. if( running == false ) { dlgAccountOptions.visible = false }
  148. }
  149. }
  150. }
  151. ]
  152. }