1
1
function Component()
2
2
{
3
- // default constructor
4
- component.forceInstallation = true;
3
+ component.forceInstallation = true; // Ensures component installs even if already present
5
4
}
6
5
7
6
Component.prototype.createOperations = function()
8
7
{
9
8
component.createOperations();
10
9
11
- // Remove old executable if it exists (optional cleanup)
12
- var oldExe = "@TargetDir@/{{ executable }}.exe"
13
- if (QFile.exists(oldExe)) {
14
- installer.performOperation("Delete", oldExe);
15
- }
10
+ var exePath = installer.value("TargetDir") + "/{{ executable }}.exe";
11
+ var shortcutPath = installer.value("StartMenuDir") + "/{{ executable }}.lnk";
16
12
17
- // Remove old shortcut if it exists (optional cleanup)
18
- var oldShortcut = "@StartMenuDir@/{{ executable }}.lnk";
19
- if (QFile.exists(oldShortcut)) {
20
- installer.performOperation("Delete", oldShortcut);
13
+ // Clean up old shortcut (QtIF doesn't remove shortcuts if renamed/moved)
14
+ if (installer.fileExists(shortcutPath)) {
15
+ installer.performOperation("Delete", shortcutPath);
21
16
}
22
17
23
- // Windows-specific shortcut creation
18
+ // Create Start Menu shortcut (Windows only)
24
19
if (systemInfo.productType === "windows") {
25
- component.addOperation("CreateShortcut", "@TargetDir@/{{ executable }}.exe",
26
- "@StartMenuDir@/{{ executable }}.lnk",
27
- "workingDirectory=@TargetDir@",
28
- "iconPath=@TargetDir@/{{ iconfilename }}",
29
- "description=Open {{ progname }}");
20
+ component.addOperation("CreateShortcut",
21
+ "@TargetDir@/{{ executable }}.exe",
22
+ "@StartMenuDir@/{{ executable }}.lnk",
23
+ "workingDirectory=@TargetDir@",
24
+ "iconPath=@TargetDir@/{{ iconfilename }}",
25
+ "description=Open {{ progname }}"
26
+ );
30
27
}
31
28
32
- // Optional: Run the application after install
29
+ // Optional: launch the application after install
33
30
component.addOperation("Execute",
34
31
"@TargetDir@/{{ executable }}.exe",
35
32
"",
36
33
"UNDOEXECUTE",
37
34
"@TargetDir@/{{ executable }}.exe"
38
35
);
39
- }
36
+ }
0 commit comments