Qt Installer Framework : Create shortcut on the desktop - qt

I use Qt Installer framework 1.5
After the installation, I would like to add a shortcut on the desktop.
In my file installscript.qs, I tried :
Component.prototype.createOperationsForPath = function()
{
if (installer.value("os") === "win")
{
try {
component.addOperation("CreateShortcut", "#TargetDir#/App.exe", "#DesktopDir#/App.lnk");
}
catch (e) {
print(e);
}
}
}
But it doesn't work, the shortcut isn't created and I don't have any error messages.
The documentation on Internet is really light.
Any idea ?
Thank you

Try this. It's working for me.
Component.prototype.createOperations = function()
{
try {
// call the base create operations function
component.createOperations();
if (installer.value("os") == "win") {
try {
var userProfile = installer.environmentVariable("USERPROFILE");
installer.setValue("UserProfile", userProfile);
component.addOperation("CreateShortcut", "#TargetDir#\\MiamPlayer.exe", "#UserProfile#\\Desktop\\MiamPlayer.lnk");
} catch (e) {
// Do nothing if key doesn't exist
}
}
} catch (e) {
print(e);
}
}

I know this answer comes very late, but i hope it can help other users:
(Qt 5.13)
component.addOperation("CreateShortcut",
"#TargetDir#/App.exe",// target
"#DesktopDir#/App.lnk",// link-path
"workingDirectory=#TargetDir#",// working-dir
"iconPath=#TargetDir#/App.exe", "iconId=0",// icon
"description=Start App");// description

Related

Qt Installer Framework - load binary automatically once installation is finished

I want to load the binary automatically once installation is completed using Qt Installation framework. How this can be achieved?
I am trying to edit this script and added component.addOperation("CreateShortcut", "#TargetDir#/DistributionKit/Abc.sh"); But its not loading the script automatically. What i am missing ?
function Component()
{
installer.installationFinished.connect(this, Component.prototype.installationFinishedPageIsShown);
installer.finishButtonClicked.connect(this, Component.prototype.installationFinished);
}
Component.prototype.createOperations = function()
{
component.createOperations();
}
Component.prototype.installationFinishedPageIsShown = function()
{
try {
if (installer.isInstaller() && installer.status == QInstaller.Success) {
installer.addWizardPageItem( component, "ReadMeCheckBoxForm", QInstaller.InstallationFinished );
}
} catch(e) {
console.log(e);
}
}
Component.prototype.installationFinished = function()
{
try {
if (installer.isInstaller() && installer.status == QInstaller.Success) {
var isReadMeCheckBoxChecked = component.userInterface( "ReadMeCheckBoxForm" ).readMeCheckBox.checked;
if (isReadMeCheckBoxChecked) {
//QDesktopServices.openUrl("file:///" + installer.value("TargetDir") + "/Abc.sh");
component.addOperation("CreateShortcut", "#TargetDir#/DistributionKit/Abc.sh");
}
}
} catch(e) {
console.log(e);
}
}
Qt installer framework has an executeDetached function in the installer. I believe this is what you need to use to launch your program. In this case, your script would look like (only adding the affected function):
Component.prototype.installationFinished = function()
{
try {
if (installer.isInstaller() && installer.status == QInstaller.Success) {
var isReadMeCheckBoxChecked = component.userInterface( "ReadMeCheckBoxForm" ).readMeCheckBox.checked;
if (isReadMeCheckBoxChecked) {
installer.exectueDetached("bash", installer.value("TargetDir") + "/Abc.sh");
component.addOperation("CreateShortcut", "#TargetDir#/DistributionKit/Abc.sh");
}
}
} catch(e) {
console.log(e);
}
}
Note that you actually need to run "bash" as executeDetached and pass your script as an argument to the bash. If you were running an executable you would not have "bash" in the exectueDetached command.
*Note that I did not add "/DistributionKint/" in the exectueDetached. This is because in the commented line in your original question Abc.sh was directly under #TargetDir#. Obviously, you need to pass the installer.executeDetached the right path to your sh script.

Qt installer scripting API: Can't select latest Qt version in online installer

A recent update to the metadata pulled by the Qt online installer has made some significant changes which have broken my installation script for Windows CI/CD.
I've solved one issue (bypassing the statistics collection screen - see DynamicTelemetryPluginFormCallback below), but I'm having trouble with another issue. On the "Select Components" screen, the default selected package category is now just LTS, and there doesn't seem to be a way to change it from the script. This means I can't install the latest Qt version, Qt 5.13.1. I can't use 5.12, since it doesn't have the Qt Controls 2 SplitView, which I am using in my application. Here's my current installer script, partially sourced from this answer. It worked fine before October 8, 2019:
function Controller() {
installer.autoRejectMessageBoxes();
installer.setMessageBoxAutomaticAnswer("installationErrorWithRetry", QMessageBox.Ignore);
installer.setMessageBoxAutomaticAnswer("installationError", QMessageBox.Ignore);
installer.installationFinished.connect(function() {
gui.clickButton(buttons.NextButton);
});
}
Controller.prototype.WelcomePageCallback = function() {
// click delay here because the next button is initially disabled for ~1 second
gui.clickButton(buttons.NextButton, 10000);
}
Controller.prototype.CredentialsPageCallback = function() {
gui.clickButton(buttons.NextButton);
}
Controller.prototype.IntroductionPageCallback = function() {
gui.clickButton(buttons.NextButton);
}
Controller.prototype.DynamicTelemetryPluginFormCallback = function() {
var widget = gui.currentPageWidget();
widget.TelemetryPluginForm.statisticGroupBox.disableStatisticRadioButton.checked = true;
gui.clickButton(buttons.NextButton);
}
Controller.prototype.TargetDirectoryPageCallback = function() {
gui.currentPageWidget().TargetDirectoryLineEdit.setText("C:\\Qt");
gui.clickButton(buttons.NextButton);
}
Controller.prototype.ComponentSelectionPageCallback = function() {
var widget = gui.currentPageWidget();
console.log(JSON.stringify(widget));
widget.ComponentsTreeView.
widget.deselectAll();
widget.selectComponent("qt.qt5.5131.win64_mingw73");
widget.selectComponent("qt.tools.win64_mingw730");
gui.clickButton(buttons.NextButton);
}
Controller.prototype.LicenseAgreementPageCallback = function() {
gui.currentPageWidget().AcceptLicenseRadioButton.setChecked(true);
gui.clickButton(buttons.NextButton);
}
Controller.prototype.StartMenuDirectoryPageCallback = function() {
gui.clickButton(buttons.NextButton);
}
Controller.prototype.ReadyForInstallationPageCallback = function() {
gui.clickButton(buttons.NextButton);
}
Controller.prototype.FinishedPageCallback = function() {
var checkBoxForm = gui.currentPageWidget().LaunchQtCreatorCheckBoxForm;
if (checkBoxForm && checkBoxForm.launchQtCreatorCheckBox) {
checkBoxForm.launchQtCreatorCheckBox.checked = false;
}
gui.clickButton(buttons.FinishButton);
}
I'm running the script with <path to installer>.exe --script <path to installer script>.qs --verbose
Running the online installer with this install script doesn't cause any errors, but it just doesn't install qt.qt5.5131.win64_mingw73.
I found an example on Github that takes care of my issue. My ComponentSelectionPageCallback now looks like this:
Controller.prototype.ComponentSelectionPageCallback = function() {
var page = gui.pageWidgetByObjectName("ComponentSelectionPage");
var checkBox = gui.findChild(page, "Latest releases");
var fetchButton = gui.findChild(page, "FetchCategoryButton");
checkBox.click();
fetchButton.click();
var widget = gui.currentPageWidget();
widget.deselectAll();
widget.selectComponent("qt.qt5.5131.win64_mingw73");
widget.selectComponent("qt.tools.win64_mingw730");
gui.clickButton(buttons.NextButton);
}
See this file on Github for a complete example.

Change width of Qt Maintenance Tool window?

I want to make the maintenance tool window wider. Users are confused by the version page, as it is truncated and they do not see what the new version is.
I tried making a really long title description, but that did not work.
I have not found a scripting solution, but here is my installscript.js
function Component()
{
}
Component.prototype.isDefault = function()
{
// select the component by default
return true;
}
Component.prototype.createOperations = function()
{
try {
component.createOperations();
if (installer.value("os") === "win") {
component.addOperation("CreateShortcut", "#TargetDir#/winnow.exe", "#StartMenuDir#/Winnow.lnk");
}
} catch (e) {
console.log(e);
}
}
Use WizardDefaultWidth WizardDefaultHeight in config.xml
see http://doc.qt.io/qtinstallerframework/ifw-globalconfig.html

Meteor - Conditionally return a group of event Handlers

In Meteor what is the best way to conditionally add a set of event handlers?
For example I'm trying to do something like this code below (this code does not work, but you will get the idea of what I'm trying to achieve.)
Template.page_article.events( function(){
if (something){
return {
some_event_name1,
some_event_name2,
}
} else {
return {
some_event_name3,
some_event_name4,
}
}
})
What is the best way to do this? I tried to set a variable outside the events() but I do not like that solution because the variable gets shared amongst ALL other templates.
What you're trying to achieve sounds like a bad solution to me, but here's a way to do it:
Template.page_article.events((function(){
if (something){
return {
'<event>': function(){ console.log("A1") },
'<event>': function(){ console.log("A2") }
}
} else {
return {
'<event>': function(){ console.log("B1") },
'<event>': function(){ console.log("B2") }
}
}
})())
EDIT
And with your added comment, it definitely sounds like a bad solution. Do something like this instead:
Template.page_article.events({
'<event>': function(event, template){
if(something){
console.log("Do something A1")
}else{
console.log("Do something B1")
}
}
'<event>': function(event, template){
if(something){
console.log("Do something A2")
}else{
console.log("Do something B2")
}
}
})

Menu buttons not working

I am trying to make a menu screen that allows users to press on buttons that contain their following instances. I know I almost have it but I can't figure out what is wrong with it.
stop();
home_btn.onRelease {
gotoAndStop(1);
}
graphics_btn.onRelease {
gotoAndStop(3);
}
animation_btn.onRelease {
gotoAndStop(2);
}
You can use the mx.utils.Delegate class :
import mx.utils.Delegate;
home_btn.onRelease = Delegate.create(this, function() {
gotoAndStop(1);
})
http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00002284.html
stop();
home_btn.onRelease = function() {
gotoAndStop(1);
}
graphics_btn.onRelease = function() {
gotoAndStop(3);
}
animation_btn.onRelease = function() {
gotoAndStop(2);
}
Add =function()

Resources