Learning.qml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. import QtQuick 1.1
  2. import com.nokia.meego 1.0
  3. import "Logic.js" as Logic
  4. Page {
  5. id: pageLearning
  6. onVisibleChanged: {
  7. if(visible) {
  8. //console.log("onVisibleChanged")
  9. }
  10. }
  11. tools: ToolBarLayout {
  12. id: tool_only_back
  13. opacity: userTheme.opacityToolbar
  14. ToolIcon {
  15. id: toolIconBack
  16. //iconId: "toolbar-back"
  17. iconSource: "images/toolbar/back.png"
  18. onClicked: {
  19. pageStack.pop();
  20. }
  21. }
  22. } //ToolBarLayout
  23. QNMTitle {
  24. id: titlePage
  25. text: qsTr("Learn words")
  26. image: "images/learn.png"
  27. busy: false
  28. }
  29. BackgroundPage { }
  30. /****************************************************************/
  31. function nextWord() {
  32. var objRes = Logic.getWord( appWindow.bufWords )
  33. if( objRes !== undefined) {
  34. appWindow.learnWord = ""
  35. appWindow.learnTranslation = ""
  36. appWindow.porgressLearn = appWindow.porgressLearn + 1
  37. var pg = Qt.resolvedUrl("Learning.qml")
  38. appWindow.bufWords = objRes.buf
  39. pageStack.replace( pg )
  40. timerShowWords.w1 = objRes.obj.word
  41. timerShowWords.w2 = objRes.obj.translation
  42. appWindow.curShowTrue = objRes.obj.strue
  43. appWindow.curShowFalse = objRes.obj.sfalse
  44. appWindow.curWordId = objRes.obj.id
  45. timerShowWords.restart()
  46. } else {
  47. var pg1 = Qt.resolvedUrl( "LearnStop.qml" )
  48. pageStack.replace( pg1 )
  49. }
  50. }
  51. /****************************************************************/
  52. Timer {
  53. id: timerShowWords
  54. property string w1: ""
  55. property string w2: ""
  56. interval: 500
  57. running: false
  58. repeat: false
  59. onTriggered: {
  60. appWindow.learnWord = w1
  61. appWindow.learnTranslation = w2
  62. }
  63. }
  64. /****************************************************************/
  65. Item {
  66. id: wrapperWordCard
  67. anchors.top: titlePage.bottom
  68. anchors.left: parent.left
  69. anchors.leftMargin: screen.orientationString == "Landscape" || screen.orientationString == "LandscapeInverted" ? 16 : 0
  70. width: screen.orientationString == "Landscape" || screen.orientationString == "LandscapeInverted" ? parent.width/2 : parent.width
  71. height: screen.orientationString == "Landscape" || screen.orientationString == "LandscapeInverted" ? parent.height - titlePage.height : (parent.height - titlePage.height)/2
  72. Item {
  73. id: pbLearn
  74. anchors.top: parent.top
  75. anchors.topMargin: 20
  76. anchors.horizontalCenter: parent.horizontalCenter
  77. width: 0.9*parent.width
  78. height: 21
  79. Text {
  80. id: txtProgress
  81. anchors.verticalCenter: parent.verticalCenter
  82. width: 0.2*parent.width
  83. font.pixelSize: 22
  84. text: appWindow.porgressLearn + "/" + appWindow.siz_bufWords
  85. }
  86. MyProgressBar {
  87. width: 0.8*parent.width
  88. anchors.left: txtProgress.right
  89. anchors.verticalCenter: parent.verticalCenter
  90. height: parent.height
  91. color: "#405fff"
  92. timeAnim: 0
  93. minValue: 0
  94. maxValue: appWindow.siz_bufWords
  95. value: appWindow.porgressLearn
  96. }
  97. }
  98. Flipable {
  99. id: flipWrapper
  100. anchors.centerIn: parent
  101. property bool flipped: false
  102. front: Image {
  103. id: cardFace
  104. anchors.centerIn: parent
  105. width: screen.orientationString == "Landscape" || screen.orientationString == "LandscapeInverted" ? 420 : 450
  106. height: screen.orientationString == "Landscape" || screen.orientationString == "LandscapeInverted" ? 180 : 200
  107. source: "images/wordItem.png"
  108. smooth: true
  109. TextEdit {
  110. id: wordText
  111. anchors.centerIn: parent
  112. wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
  113. text: appWindow.learnWord
  114. font.pixelSize: 40
  115. font.bold: true
  116. clip: true
  117. focus: true
  118. readOnly: true
  119. height: parent.height-16
  120. width: parent.width-18
  121. horizontalAlignment: TextEdit.AlignHCenter
  122. verticalAlignment: TextEdit.AlignVCenter
  123. onTextChanged: {
  124. Logic.strItem( wordText, 390 )
  125. }
  126. }
  127. }
  128. onStateChanged: {
  129. if(state == "forward")
  130. Logic.strItem( wordText, 390 )
  131. else
  132. Logic.strItem( translateText, 390 )
  133. }
  134. back: Image {
  135. id: cardBack
  136. anchors.centerIn: parent
  137. width: screen.orientationString == "Landscape" || screen.orientationString == "LandscapeInverted" ? 420 : 450
  138. height: screen.orientationString == "Landscape" || screen.orientationString == "LandscapeInverted" ? 180 : 200
  139. source: "images/wordItem.png"
  140. smooth: true
  141. TextEdit {
  142. id: translateText
  143. anchors.centerIn: parent
  144. wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
  145. text: appWindow.learnTranslation
  146. font.pixelSize: 40
  147. font.bold: true
  148. clip: true
  149. focus: true
  150. readOnly: true
  151. height: parent.height-16
  152. width: parent.width-18
  153. horizontalAlignment: TextEdit.AlignHCenter
  154. verticalAlignment: TextEdit.AlignVCenter
  155. color: "blue"
  156. onTextChanged: {
  157. Logic.strItem( translateText, 390 )
  158. }
  159. }
  160. }
  161. transform: Rotation {
  162. id: rotation
  163. origin.x: flipWrapper.width/2
  164. origin.y: flipWrapper.height/2
  165. axis.x: 1; axis.y: 0; axis.z: 0 // set axis.y to 1 to rotate around y-axis
  166. angle: 0 // the default angle
  167. }
  168. state: "forward"
  169. states: [
  170. State {
  171. name: "back"
  172. PropertyChanges { target: rotation; angle: 180 }
  173. //PropertyChanges { target: wordText; visible: false }
  174. //PropertyChanges { target: translateText; visible: true }
  175. when: flipWrapper.flipped
  176. },
  177. State {
  178. name: "forward"
  179. //PropertyChanges { target: wordText; visible: true }
  180. //PropertyChanges { target: translateText; visible: false }
  181. when: ! flipWrapper.flipped
  182. }
  183. ]
  184. transitions: Transition {
  185. ParallelAnimation {
  186. NumberAnimation { target: rotation; property: "angle"; duration: 400 }
  187. /*onCompleted: {
  188. console.log("ParallelAnimation::onCompleted")
  189. }
  190. onStarted: {
  191. console.log("ParallelAnimation::onStarted")
  192. }*/
  193. }
  194. }
  195. } //Flipable
  196. MouseArea {
  197. id: ma
  198. anchors.fill: parent
  199. onClicked: {
  200. flipWrapper.flipped = !flipWrapper.flipped
  201. }
  202. }
  203. }
  204. /****************************************************************/
  205. Item {
  206. id: wrapperButton
  207. anchors.top: screen.orientationString == "Landscape" || screen.orientationString == "LandscapeInverted" ? titlePage.bottom : wrapperWordCard.bottom
  208. anchors.left: screen.orientationString == "Landscape" || screen.orientationString == "LandscapeInverted" ? wrapperWordCard.right : parent.left
  209. width: screen.orientationString == "Landscape" || screen.orientationString == "LandscapeInverted" ? parent.width/2 : parent.width
  210. height: screen.orientationString == "Landscape" || screen.orientationString == "LandscapeInverted" ? parent.height - titlePage.height : (parent.height - titlePage.height)/2
  211. MyButton {
  212. id: buttonTrue
  213. text: qsTr("I knew")
  214. height: 120
  215. width: 360
  216. anchors.top: wrapperButton.top
  217. anchors.topMargin: screen.orientationString == "Landscape" || screen.orientationString == "LandscapeInverted" ? 30 : 10
  218. anchors.horizontalCenter: parent.horizontalCenter
  219. iconSource: "images/ok.png"
  220. fontSize: 32
  221. color: "green"
  222. isGlow: false
  223. onClicked: {
  224. appWindow.curShowTrue += 1
  225. Logic.wordTrue( appWindow.curWordId, appWindow.curShowTrue )
  226. pageLearning.nextWord()
  227. appWindow.answTrue += 1
  228. }
  229. }
  230. MyButton {
  231. id: buttonFalse
  232. text: qsTr("I didn't know")
  233. height: 120
  234. width: 360
  235. anchors.top: buttonTrue.bottom
  236. anchors.topMargin: 50
  237. anchors.horizontalCenter: parent.horizontalCenter
  238. iconSource: "images/cancel.png"
  239. fontSize: 32
  240. color: "red"
  241. isGlow: false
  242. onClicked: {
  243. appWindow.curShowFalse += 1
  244. Logic.wordFalse( appWindow.curWordId, appWindow.curShowFalse )
  245. appWindow.answFalse += 1
  246. var _show = appWindow.curShowFalse + appWindow.curShowTrue
  247. var obj_we = new Object()
  248. obj_we.model_word = appWindow.learnWord
  249. obj_we.model_translation = appWindow.learnTranslation
  250. obj_we.word_show = _show
  251. obj_we.show_error = appWindow.curShowFalse
  252. var listWE = appWindow.bufWordsErrorTest
  253. listWE.push( obj_we )
  254. appWindow.bufWordsErrorTest = listWE
  255. pageLearning.nextWord()
  256. }
  257. }
  258. }
  259. /****************************************************************/
  260. }