CQtDeployer/installer/config/controlScript.js

80 lines
2.5 KiB
JavaScript
Raw Normal View History

2019-05-15 14:56:38 +03:00
function Controller()
{
generateTr();
installer.setMessageBoxAutomaticAnswer("OverwriteTargetDirectory", QMessageBox.Yes);
installer.uninstallationFinished.connect(this, Controller.prototype.uninstallationFinished);
installer.installationFinished.connect(this, Controller.prototype.installationFinished);
}
function generateTr() {
console.log("generate tr start ")
installer.setValue("Name", qsTr("CQtDeployer"));
installer.setValue("Title", qsTr("Install CQtDeployer"));
}
Controller.prototype.uninstallationFinished = function()
{
2019-05-16 15:26:39 +03:00
homeDir = installer.value("HomeDir", "");
console.log("hometDir " + homeDir)
if (systemInfo.kernelType === "winnt") {
if (!installer.gainAdminRights()) {
QMessageBox["warning"](qsTr("install in system"), qsTr("Installer"),
qsTr("To uninstall cqtdeployer on your system, you need administrator rights!. "), QMessageBox.Ok);
return;
}
installer.execute("DELETE", ["C:\Windows\system32\cqtdeployer.exe"])
installer.dropAdminRights();
} else {
installer.execute("rm", ["-f", homeDir + "/.local/bin/cqtdeployer"])
}
2019-05-15 14:56:38 +03:00
}
Controller.prototype.installationFinished = function()
{
2019-05-16 15:26:39 +03:00
targetDir = installer.value("TargetDir", "");
homeDir = installer.value("HomeDir", "");
console.log("targetDir " + targetDir)
console.log("hometDir " + homeDir)
if (systemInfo.kernelType === "winnt") {
2019-05-21 14:57:23 +03:00
installer.execute("SETX", [ "cqtdeployer", targetDir + "/cqtdeployer.exe"])
2019-05-16 15:26:39 +03:00
2019-05-21 14:50:11 +03:00
QMessageBox["information"](qsTr("install in system"), qsTr("Installer"),
qsTr("CQtDeployer successfully installed on your computer to use the call \"%cqtdeployer%\"."),
QMessageBox.Ok);
2019-05-16 15:26:39 +03:00
} else {
2019-05-19 18:48:42 +03:00
if (!installer.fileExists(homeDir + "/.local/bin")) {
installer.execute("mkpath", ["-p", homeDir + "/.local/bin"]);
2019-05-19 19:07:14 +03:00
QMessageBox["warning"](qsTr("install in system"), qsTr("Installer"),
qsTr("The \"~/local/bin\" folder was not initialized, you may need to reboot to work correctly!"),
QMessageBox.Ok);
2019-05-19 18:48:42 +03:00
}
2019-05-16 15:26:39 +03:00
installer.execute("ln", ["-sf", targetDir + "/cqtdeployer.sh",
homeDir + "/.local/bin/cqtdeployer"])
2019-05-21 14:50:11 +03:00
QMessageBox["information"](qsTr("install in system"), qsTr("Installer"),
qsTr("CQtDeployer successfully installed on your computer to use the call \"cqtdeployer\"."),
QMessageBox.Ok);
2019-05-16 15:26:39 +03:00
}
2019-05-21 14:50:11 +03:00
2019-05-15 14:56:38 +03:00
}