aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/sqlitestudio/installscript.qs
blob: 8e6b84b7c3f3ddb766f125742c6a1f552b8ed8d2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
function Component()
{
	if (installer.value("os") === "win") {
		component.loaded.connect(this, addOptionsCheckBoxForm);
		component.fileTypes = ['db', 'db3', 'sqlite', 'sqlite3', 'sdb', 's3db'];
	}
}

addOptionsCheckBoxForm = function()
{
    // don't show when updating or uninstalling
    if (installer.isInstaller()) {
        installer.addWizardPageItem(component, "OptionsCheckBoxForm", QInstaller.TargetDirectory);
		var form = component.userInterface("OptionsCheckBoxForm");
		
		var assocCheckBox = form.RegisterFileCheckBox;
        assocCheckBox.text = assocCheckBox.text + component.fileTypes.join(', ');

		var startMenuCheckbox = form.CreateStartMenuEntry;
		startMenuCheckbox.stateChanged.connect(this, function() {
			installer.setDefaultPageVisible(QInstaller.StartMenuSelection, startMenuCheckbox.checked);
		});
	}
}

Component.prototype.createOperations = function()
{
    // call default implementation to actually install the app
    component.createOperations();

    if (installer.value("os") === "win") {
		var form = component.userInterface("OptionsCheckBoxForm");
		var isRegisterFileChecked = form.RegisterFileCheckBox.checked;
		var isStartMenuEntryChecked = form.CreateStartMenuEntry.checked;
		var forAllUsersChecked = form.CreateStartMenuEntry.ForAllUsers.checked;
	
        var executable = "@TargetDir@/SQLiteStudio.exe";
		
		var linkPrefix = "@UserStartMenuProgramsPath@";
		if (forAllUsersChecked) {
			linkPrefix = "@AllUsersStartMenuProgramsPath@";
		}

		if (isRegisterFileChecked) {
			component.addOperation("CreateShortcut", executable, linkPrefix + "/@StartMenuDir@/SQLiteStudio.lnk",
				"workingDirectory=@TargetDir@", "iconPath=@TargetDir@/SQLiteStudio.exe",
				"iconId=0", "description=SQLiteStudio");
		}
			
		if (isRegisterFileChecked) {	
			component.fileTypes.forEach(function(fileType) {
				component.addOperation(
					"RegisterFileType",
					fileType,
					executable + " '%1'",
					"SQLite database",
					"application/octet-stream",
					executable + ",0",
					"ProgId=SQLiteStudio." + fileType
				);
			});
		}
    }
}