main.qml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import QtQuick 1.0
  2. import com.nokia.symbian 1.0
  3. // use the NfcSettings class (/nfcsettings/nfcsettings.h)
  4. import NfcSettings 1.0
  5. // for InfoBanner
  6. import com.nokia.extras 1.0
  7. Window {
  8. id: window
  9. NfcSettings {
  10. id: nfcSettings
  11. onNfcErrorOccurred: {
  12. // hadle settings reading errors
  13. banner.text = "NFC error " + error.toString() + " occured on " + nfcError.toString()
  14. banner.open();
  15. console.log(banner.text);
  16. }
  17. onNfcModeChanged: {
  18. // react to NFC mode changes
  19. // e.g. disable NFC features when the radio is turned off
  20. if(nfcSettings.nfcMode == NfcSettings.NfcModeOn)
  21. banner.text = "NFC mode: on"
  22. else if (nfcSettings.nfcMode == NfcSettings.NfcModeOff)
  23. banner.text = "NFC mode: off"
  24. banner.open();
  25. console.log(banner.text);
  26. }
  27. }
  28. InfoBanner {
  29. id: banner
  30. }
  31. StatusBar {
  32. id: statusBar
  33. anchors.top: window.top
  34. }
  35. Text {
  36. id: mainText
  37. text: "Hello World!"
  38. width: parent.width-40;
  39. anchors.centerIn: parent
  40. color: platformStyle.colorNormalLight
  41. font.pixelSize: 20
  42. wrapMode: Text.Wrap
  43. }
  44. ToolBar {
  45. id: toolBar
  46. anchors.bottom: window.bottom
  47. tools: ToolBarLayout {
  48. id: toolBarLayout
  49. ToolButton {
  50. flat: true
  51. iconSource: "toolbar-back"
  52. onClicked: Qt.quit()
  53. }
  54. }
  55. }
  56. Component.onCompleted: {
  57. if(nfcSettings.nfcFeature == NfcSettings.NfcFeatureSupportedViaFirmwareUpdate)
  58. {
  59. // if your app depends on having NFC support, show message then exit
  60. mainText.text = qsTr("FirmwareUpdateMandatory");
  61. // Qt.quit();
  62. // if your application can work even without NFC support, show message then continue
  63. mainText.text = qsTr("FirmwareUpdateRecommended");
  64. }
  65. }
  66. }