demoitemcore.js 937 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2011 Nokia Corporation.
  3. */
  4. // Holds the dynamically loaded demo, only one demo can be loaded at the time.
  5. // This way resources usage is kept as low as possible.
  6. var loadedDemo = null;
  7. function loadDemo() {
  8. if(loadedDemo != null) {
  9. console.log("Demo was not null! There is something wrong in QML code!!! Calling unloadDemo!")
  10. unloadDemo()
  11. }
  12. try {
  13. loadedDemo = Qt.createQmlObject(gridItem.qmlCode, demoHolder, qmlFolder)
  14. //loadedDemo = createQmlObject(gridItem.qmlCode, demoHolder, qmlFolder)
  15. }
  16. catch(err) {
  17. errorDialog.show(err.qmlErrors[0].lineNumber, 'Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message)
  18. }
  19. }
  20. function startDemo() {
  21. if(loadedDemo != null) {
  22. loadedDemo.initialize()
  23. }
  24. }
  25. function unloadDemo() {
  26. if(loadedDemo != null) {
  27. loadedDemo.destroy()
  28. loadedDemo = null
  29. }
  30. }