MainPage.qml 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
  2. import QtQuick 1.1
  3. import iapminimal.com 1.0
  4. import Analytics 1.0
  5. import com.nokia.symbian 1.1
  6. import "inneractive"
  7. Page {
  8. id: myscreen
  9. property string iapstate: "getProductData"
  10. Component.onCompleted: {
  11. // Initialize item with \e {Application key} and \e {Agent name} values.
  12. analyticsExample.initialize("2e15a80cf765630bf2b971d7a3c011f4", "iapminimal");
  13. // Start gathering analytics events.
  14. analyticsExample.start("iapminimalStarted");
  15. }
  16. // Create Analytics QML-item and set values for all available optional properties.
  17. Analytics {
  18. id: analyticsExample
  19. connectionTypePreference: Analytics.AnyConnection // optional
  20. appLanguage: "Fi" // optional
  21. minBundleSize: 20 // optional
  22. loggingEnabled: true // optional
  23. }
  24. TextArea {
  25. id: screenText
  26. readOnly : true
  27. text: qsTr("Clickme to see product data")
  28. anchors.centerIn: parent
  29. }
  30. MouseArea {
  31. anchors.fill: parent
  32. onClicked: {
  33. analyticsExample.logEvent("onclicked", myscreen.iapstate, Analytics.ActivityLogEvent);
  34. if(myscreen.iapstate === "exitApp"){
  35. analyticsExample.stop("stopAnalytic", Analytics.AppExit);
  36. //TODO: to emulate 20 seconds delay before application exit,
  37. // comment Qt.quit() and uncomment iap.closeIAP()
  38. Qt.quit();
  39. //iap.closeIAP();
  40. } else if(myscreen.iapstate === "getProductData"){
  41. iap.getProductData();
  42. } else if(myscreen.iapstate === "purchaseProduct"){
  43. iap.purchaseProduct();
  44. }
  45. }
  46. }
  47. IAPmin{
  48. id: iap
  49. onStatusBusy: screenText.text = "please wait..."
  50. onProductDataComplete: {
  51. screenText.text = data;
  52. myscreen.iapstate = "purchaseProduct";
  53. }
  54. onProductPurchaseComplete: {
  55. screenText.text = data;
  56. myscreen.iapstate = "exitApp";
  57. }
  58. onIapClosed: Qt.quit()
  59. }
  60. AdItem {
  61. parameters: params
  62. anchors.top: parent.top
  63. anchors.horizontalCenter: parent.horizontalCenter
  64. showText: false
  65. }
  66. AdItem {
  67. id: ad
  68. retryOnError: true
  69. reloadInterval: 100
  70. parameters: params
  71. anchors.bottom: parent.bottom
  72. anchors.horizontalCenter: parent.horizontalCenter
  73. }
  74. AdParameters {
  75. id: params
  76. applicationId: "IA_GameTest"
  77. }
  78. }