I'm trying to create a desktop entry using a script file with the installer framework but not working.

Here is the content of the script file:

Qt Code:
  1. function Component() {
  2. installer.finishButtonClicked.connect(this, Component.prototype.installationFinished);
  3. }
  4.  
  5. Component.prototype.createOperations = function() {
  6. component.createOperations();
  7. }
  8.  
  9. Component.prototype.installationFinished = function() {
  10. try {
  11. if (installer.isInstaller() && installer.status == QInstaller.Success) {
  12. component.addOperation("CreateDesktopEntry",
  13. "@HomeDir@/.local/share/applications/Cumulus.desktop",
  14. "Type=Application\n
  15. Terminal=false\n
  16. Exec=@TargetDir@/Cumulus\n
  17. Name=Cumulus\n
  18. Icon=@TargetDir@/cumulus.svg");
  19. component.addOperation("Copy", "@HomeDir@/.local/share/applications/Cumulus.desktop", "@HomeDir@/Desktop/Cumulus.desktop");
  20. QDesktopServices.openUrl("file:///" + installer.value("TargetDir") + "/InstallationLog.txt");
  21. }
  22. } catch(e) {
  23. console.log(e);
  24. }
  25. }
To copy to clipboard, switch view to plain text mode 

I also have tried the following version for installation Finished:

Qt Code:
  1. Component.prototype.installationFinished = function() {
  2. var targetDir = installer.value("TargetDir");
  3. var homeDir = installer.value("HomeDir");
  4. var desktopFileTarget = installer.value("HomeDir") + "/.local/share/applications";
  5. try {
  6. if (installer.isInstaller() && installer.status == QInstaller.Success) {
  7. component.addOperation("CreateDesktopEntry",
  8. desktopFileTarget + "/Cumulus.desktop",
  9. "Type=Application\nTerminal=false\nExec= " + targetDir + "/Cumulus\nName=Cumulus\nIcon= " + targetDir + "/cumulus.svg");
  10. QDesktopServices.openUrl("file:///" + installer.value("TargetDir") + "/InstallationLog.txt");
  11. }
  12. } catch(e) {
  13. console.log(e);
  14. }
  15. }
To copy to clipboard, switch view to plain text mode 

The script runs and no error is logged, when finishing the InstallationLog.txt opens and is there to confirm that the script is running.
I have also tried copying a file from within installation using Copy operation but not working at all either.