main.qml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. import QtQuick 1.0
  2. import com.nokia.symbian 1.1
  3. ApplicationWindow {
  4. id: theAPP
  5. Component.onCompleted:{
  6. pageStack.push(mainPage);
  7. //deferred initialization for performance reason
  8. catalogModel.readDRMCatalog();
  9. }
  10. Page{
  11. id: mainPage
  12. tools: ToolBarLayout {
  13. ToolButton {
  14. iconSource: "toolbar-back"
  15. onClicked: Qt.quit()
  16. }
  17. ToolButton {
  18. id: buttonRestore
  19. iconSource: "toolbar-refresh"
  20. enabled: !catalogModel.isApplicationBusy
  21. ToolTip {
  22. id: toolTipRestore
  23. text: "Restore purchase sessions"
  24. target: buttonRestore
  25. visible: false
  26. }
  27. onPlatformPressAndHold: toolTipRestore.visible = true
  28. onPlatformReleased: toolTipRestore.visible = false
  29. }
  30. ToolButton {
  31. id: buttonDelete
  32. iconSource: "toolbar-delete"
  33. enabled: !catalogModel.isApplicationBusy
  34. ToolTip {
  35. id: toolTipDelete
  36. text: "Reset purchase sessions"
  37. target: buttonDelete
  38. visible: false
  39. }
  40. onPlatformPressAndHold: toolTipDelete.visible = true
  41. onPlatformReleased: toolTipDelete.visible = false
  42. onClicked: {
  43. catalogModel.resetPurchases();
  44. }
  45. }
  46. ToolButton {
  47. iconSource: "gfx/icon_info.png"
  48. onClicked: theAPP.pageStack.push(infoPage)
  49. }
  50. }
  51. Flickable {
  52. anchors.fill: parent
  53. contentWidth: parent.width
  54. contentHeight: content.height
  55. Column{
  56. id: content
  57. spacing: 10
  58. ListView {
  59. interactive: false
  60. model: itemsToBuyModel
  61. delegate: listToBuyDelegate
  62. header: ListHeading {
  63. ListItemText {
  64. anchors.centerIn: parent
  65. role: "SelectionSubTitle"
  66. text: "Items to buy"
  67. }
  68. }
  69. width: mainPage.width
  70. // NOTE: incrementing items count is for accounting header
  71. height: (mainPage.tools.implicitHeight + spacing) * (count + 1)
  72. z:count // to overlap "Items you have" header if the list is empty
  73. }
  74. ListView {
  75. interactive: false
  76. model: itemsBoughtModel
  77. delegate: listYouHaveDelegate
  78. header: ListHeading {
  79. ListItemText {
  80. anchors.centerIn: parent
  81. role: "SelectionSubTitle"
  82. text: "Items you have"
  83. }
  84. }
  85. width: mainPage.width
  86. height: (mainPage.tools.implicitHeight + spacing) * (count + 1)
  87. }
  88. }
  89. }
  90. BusyIndicator {
  91. anchors.centerIn: parent
  92. visible: catalogModel.isApplicationBusy
  93. running: true
  94. width: 60
  95. height: 60
  96. }
  97. Component {
  98. id: listToBuyDelegate
  99. ListItem {
  100. subItemIndicator: true
  101. Column {
  102. anchors.fill: parent.paddingItem
  103. ListItemText {
  104. role: "Title"
  105. text: iap_productid // Title text from model
  106. width: parent.width
  107. color: iap_isBusy ? "darkred" : "darkgreen"
  108. }
  109. }
  110. onClicked:{
  111. catalogModel.buy(index);
  112. }
  113. }
  114. }
  115. Component {
  116. id: listYouHaveDelegate
  117. ListItem {
  118. Column {
  119. anchors.fill: parent.paddingItem
  120. ListItemText {
  121. role: "Title"
  122. text: iap_productid // Title text from model
  123. width: parent.width
  124. }
  125. }
  126. }
  127. }
  128. Page{
  129. id: infoPage
  130. TextArea{
  131. id: info
  132. anchors.margins: 30
  133. anchors.fill: parent
  134. readOnly: true
  135. property string link: "http://projects.developer.nokia.com/iap_sample_drm_case"
  136. text: "This is a mock game application project that demonstrates use " +
  137. "of In-application Purchase API with Nokia DRM protected resources. " +
  138. "You can use that application as skeleton for your project.<br/><br/>" +
  139. "For more details please see the application project page : " +
  140. "<p style=\"color: darkblue\">TryAndBuyExample</p>"
  141. }
  142. MouseArea{
  143. anchors.fill: info
  144. onClicked: Qt.openUrlExternally(info.link)
  145. }
  146. tools: ToolBarLayout {
  147. ToolButton {
  148. iconSource: "toolbar-back"
  149. onClicked: theAPP.pageStack.pop()
  150. }
  151. }
  152. }
  153. }
  154. }