ContentPage.qml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /**
  2. * Copyright (c) 2012 Nokia Corporation.
  3. */
  4. import QtQuick 1.1
  5. import com.nokia.symbian 1.1
  6. import "../Constants.js" as Constants
  7. Page {
  8. id: page
  9. property string infoText: Constants.EMPTYCONTENT_INFOTEXT
  10. property string contentText: ""
  11. property bool fromToolBarMode: false
  12. property bool fromContentAreaMode: false
  13. state: "NORMAL"
  14. tools: {
  15. if (fromToolBarMode)
  16. return toolBarWithAddButton
  17. if (fromContentAreaMode)
  18. return sharedToolBar
  19. return toolBarBackAndInfo
  20. }
  21. ToolBar {
  22. id: sharedToolBar
  23. tools: fromContentMainToolBar
  24. platformInverted: window.platformInverted
  25. visible: fromContentAreaMode
  26. }
  27. ToolBarLayout {
  28. id: fromContentMainToolBar
  29. ToolButton {
  30. flat: true
  31. iconSource: "toolbar-back"
  32. platformInverted: window.platformInverted
  33. onClicked: window.pageStack.depth <= 1 ? Qt.quit() : window.pageStack.pop()
  34. }
  35. ToolButton {
  36. flat: true
  37. platformInverted: window.platformInverted
  38. iconSource: platformInverted ? "../Images/Icons/attach_w.svg" : "../Images/Icons/attach.svg"
  39. }
  40. ToolButton {
  41. flat: true
  42. platformInverted: window.platformInverted
  43. iconSource: platformInverted ? "../Images/Icons/favourite_w.svg" : "../Images/Icons/favourite.svg"
  44. }
  45. ToolButton {
  46. flat: true
  47. iconSource: platformInverted ? "../Images/Icons/information_userguide_w.svg" : "../Images/Icons/information_userguide.svg"
  48. platformInverted: window.platformInverted
  49. onClicked: window.pageStack.push(Qt.resolvedUrl("../InfoPage.qml"), {text: Constants.EMPTYCONTENT_INFOTEXT});
  50. }
  51. }
  52. ToolBarLayout {
  53. id: fromContentEditToolBar
  54. ToolButton {
  55. flat: true
  56. iconSource: "toolbar-back"
  57. platformInverted: window.platformInverted
  58. onClicked: window.pageStack.depth <= 1 ? Qt.quit() : window.pageStack.pop()
  59. }
  60. ToolButton {
  61. text: "Done"
  62. platformInverted: window.platformInverted
  63. onClicked:{
  64. page.state = "NORMAL"
  65. }
  66. }
  67. ToolButton {
  68. text: "Cancel"
  69. platformInverted: window.platformInverted
  70. onClicked:{
  71. page.state = "NORMAL"
  72. contentText = ""
  73. }
  74. }
  75. ToolButton {
  76. flat: true
  77. iconSource: "toolbar-add"
  78. platformInverted: window.platformInverted
  79. onClicked: {
  80. if (contentText.length < 5 * Constants.LOREM_IPSUM_TEXT.length )
  81. contentText += Constants.LOREM_IPSUM_TEXT
  82. }
  83. }
  84. }
  85. ToolBarLayout {
  86. id: toolBarWithAddButton
  87. ToolButton {
  88. flat: true
  89. iconSource: "toolbar-back"
  90. platformInverted: window.platformInverted
  91. onClicked: window.pageStack.depth <= 1 ? Qt.quit() : window.pageStack.pop()
  92. }
  93. ToolButton {
  94. flat: true
  95. iconSource: "toolbar-add"
  96. platformInverted: window.platformInverted
  97. onClicked: {
  98. if (contentText.length < 5 * Constants.LOREM_IPSUM_TEXT.length )
  99. contentText += Constants.LOREM_IPSUM_TEXT
  100. }
  101. }
  102. ToolButton {
  103. flat: true
  104. iconSource: platformInverted ? "../Images/Icons/information_userguide_w.svg" : "../Images/Icons/information_userguide.svg"
  105. platformInverted: window.platformInverted
  106. onClicked: window.pageStack.push(Qt.resolvedUrl("../InfoPage.qml"), {text: Constants.EMPTYCONTENT_INFOTEXT});
  107. }
  108. }
  109. ScrollDecorator{
  110. flickableItem: flickable
  111. }
  112. Flickable{
  113. id: flickable
  114. anchors.fill: parent
  115. contentHeight: label.implicitHeight + 2 * label.anchors.margins
  116. Label{
  117. id: label
  118. anchors.top: parent.top
  119. anchors.right: parent.right
  120. anchors.left: parent.left
  121. anchors.margins: platformStyle.paddingLarge
  122. platformInverted: window.platformInverted;
  123. wrapMode: Text.WordWrap
  124. horizontalAlignment: anchors.mirrored ? Text.AlignRight : Text.AlignLeft
  125. text: contentText
  126. }
  127. }
  128. Column{
  129. anchors.centerIn: parent
  130. width: parent.width
  131. visible: contentText == "" && page.state == "NORMAL"
  132. spacing: platformStyle.paddingLarge
  133. Label{
  134. width: parent.width
  135. platformInverted: window.platformInverted;
  136. font.pixelSize: 2 * platformStyle.fontSizeLarge
  137. wrapMode: Text.WordWrap
  138. horizontalAlignment: "AlignHCenter"
  139. text: "No example content"
  140. }
  141. Button{
  142. anchors.horizontalCenter: parent.horizontalCenter
  143. platformInverted: window.platformInverted;
  144. visible: fromContentAreaMode
  145. width: page.width/2
  146. iconSource: platformInverted ? "../Images/Icons/add_w.svg" : "../Images/Icons/add.svg"
  147. onClicked: {
  148. page.state = "CONTENT_EDIT"
  149. }
  150. }
  151. }
  152. states: [
  153. State {
  154. name: "NORMAL"
  155. },
  156. State {
  157. name: "CONTENT_EDIT"
  158. }
  159. ]
  160. onStateChanged: {
  161. console.log("State changed to: " + state);
  162. if (state == "NORMAL") {
  163. sharedToolBar.setTools(fromContentMainToolBar);
  164. }
  165. else
  166. sharedToolBar.setTools(fromContentEditToolBar);
  167. }
  168. }