component

Represents the current component that the Qt Script belongs to. More...

Properties

Signals

Methods

Detailed Description

A minimal valid script needs to contain a constructor, which can look like this:

function Component()
{
    // Access the global component's name property and log it to the debug console.
    console.log("component: " + component.displayName);
}

The Component class and the script engine both modify the script before it is evaluated. When the modifications are applied to the above snippet, the script changes to:

(function() { [1]
    var component = installer.componentByName('Component.Name.This.Script.Belongs.To'); [2]
    function Component()
    {
        // Access the global component's name property and log it to the debug console.
        console.log("component: " + component.displayName);
    }

    if (typeof Component != undefined) [1]
        return new Component; [1]
    else [1]
        throw "Missing Component constructor. Please check your script." [1]
})();

[1] Changes done by the script engine.
[2] Changes done by the Component class.

Note: The component (in lower case) is the global variable the C++ Component class introduced. The component variable represents the C++ Component object that the script belongs to. The Component (in upper case) is a JavaScript object that gets instantiated by the script engine.

Property Documentation

archives : stringlist

Returns the list of archive URL's (prefixed with installer://) registered for the component.

See also addDownloadableArchive and removeDownloadableArchive.


autoCreateOperations : boolean

Specifies whether some standard operations for the component should be automatically created when the installation starts. The default is true.


autoDependencies : stringlist

Returns the value of the <AutoDependOn> tag in the package information file.


default : boolean

This read-only property indicates if the component is a default one.

Note: Always false for virtual components.

See also isDefault.


dependencies : stringlist

This read-only property contains components this component depends on.


displayName : string

Returns the name of the component as shown in the user interface.


enabled : boolean

Indicates whether the component is currently enabled. The property is both readable and writable.


fromOnlineRepository : boolean

Returns whether this component has been loaded from an online repository.

See also isFromOnlineRepository.


installed : boolean

This read-only property returns if the component is installed.

See also isInstalled.


name : string

Returns the name of the component as set in the <Name> tag of the package information file.


repositoryUrl : url

Returns the repository URL the component is downloaded from. When this component is not downloaded from an online repository, returns an empty #QUrl.


userInterfaces : stringlist

Returns a list of all user interface class names known to this component.


Signal Documentation

loaded()

Emitted when the component has been loaded.

Note: The corresponding handler is onLoaded.


valueChanged(string key, string value)

Emitted when the value of the variable with the name key changes to value.

Note: The corresponding handler is onValueChanged.

See also setValue.


virtualStateChanged()

Emitted when the virtual state of the component changes.

Note: The corresponding handler is onVirtualStateChanged.


Method Documentation

boolean isAutoDependOn(QSet<string> componentsToInstall)

boolean isDefault()

Determines whether the component comes as an auto dependency. Returns true if all components in componentsToInstall are already installed or selected for installation and this component thus needs to be installed as well.

/*!

Indicates if the component is a default one.

Note: Always returns false for virtual components.

See also default.


void addAutoDependOn(string newDependOn)

Adds the component specified by newDependOn to the automatic depend-on list. Alternatively, multiple components can be specified by separating each with a comma.

See also autoDependencies.


void addDependency(string newDependency)

Adds a new component newDependency to the list of dependencies. Alternatively, multiple components can be specified by separating each with a comma.

See also dependencies.


void addDownloadableArchive(string path)

Adds the archive path to this component. This can only be called when this component was downloaded from an online repository. When adding path, it will be downloaded from the repository when the installation starts.

See also removeDownloadableArchive, fromOnlineRepository, and archives.


boolean addElevatedOperation(string operation, string parameter1 = "", string parameter2 = "", ..., string parameter10 = "")

Convenience method for calling addElevatedOperation(string, stringlist) with up to 10 arguments parameter1, parameter2, ... parameter10. Creates and adds an installation operation for operation. The operation is executed with elevated rights.


boolean addElevatedOperation(string operation, stringlist parameters)

Creates and adds an installation operation for operation. Add any number of parameters. The contents of the parameters get variables like "@TargetDir@" replaced with their values, if contained. operation is executed with elevated rights.


boolean addOperation(string operation, stringlist parameters)

Creates and adds an installation operation for operation. Add any number of parameters. The contents of the parameters get variables like "@TargetDir@" replaced with their values, if contained.

The method is typically called from within component::createOperations().


boolean addOperation(string operation, string parameter1 = "", string parameter2 = "", ..., string parameter10 = "")

Convenience method for calling addOperation(string, stringlist) with up to 10 arguments parameter1, parameter2, ... parameter10. Creates and adds an installation operation for operation.


void addStopProcessForUpdateRequest(string process)

Adds a request for quitting the process process before installing, updating, or uninstalling the component.


void beginInstallation()

Starts the component installation. You can override this method by providing a method with the same name in the component script.

Component.prototype.beginInstallation = function()
{
    // call default implementation
    component.beginInstallation();
    // ...
}

boolean componentChangeRequested()

Returns true if this component will be changed (update, installation, or uninstallation).


void createOperations()

Creates all operations needed to install this component. You can override this method by providing a method with the same name in the component script:

Component.prototype.createOperations = function()
{
    // call default implementation
    component.createOperations();
    // ... add custom operations
}

The default implementation calls createOperationsForArchive for all archives in this component.

See also component::addOperation().


void createOperationsForArchive(string archive)

Creates all operations needed to install this component's archive. This method gets called from createOperations. You can override this method by providing a method with the same name in the component script.

Note: If you call this method from a script, it will not call the script's method with the same name.

The default implementation calls createOperationsForPath for everything contained in the archive. If archive is a compressed archive known to the installer system, an Extract operation is created, instead.


void createOperationsForPath(string path)

Creates all operations needed to install this component's path. path is a full qualified filename including the component's name. This method gets called from createOperationsForArchive. You can override it by providing a method with the same name in the component script.

Note: RSA signature files are omitted by this method.

Note: If you call this method from a script, it will not call the script's method with the same name.

The default implementation is recursively creating Copy and Mkdir operations for all files and folders within path.


boolean installationRequested()

Determines whether the user wants to install the component.


boolean isForcedUpdate()

Returns true if the component is installed and has a ForcedUpdate flag set. Forced updates will be updated together with essential components before any other component can be updated or installed.


boolean isFromOnlineRepository()

Determines whether this component has been loaded from an online repository.

See also addDownloadableArchive and fromOnlineRepository.


boolean isInstalled()

Determines whether the component is installed.


boolean isUninstalled()

Determines whether the component is uninstalled.


boolean isUpdateAvailable()

Determines whether update is available for component.


void registerPathForUninstallation(string path, boolean wipe = false)

Registers the file or directory at path for being removed when this component gets uninstalled. In case of a directory, this will be recursive. If wipe is set to true, the directory will also be deleted if it contains changes done by the user after installation.


void removeDownloadableArchive(string path)

Removes the archive path previously added via addDownloadableArchive from this component. This can only be called when this component was downloaded from an online repository.

See also addDownloadableArchive, fromOnlineRepository, and archives.


void removeStopProcessForUpdateRequest(string process)

Removes the request for quitting the process process again.


void setAutoCreateOperations(boolean autoCreateOperations)

Sets the value of autoCreateOperations property to autoCreateOperations.


void setInstalled()

Set's the components state to installed.

See also isInstalled().


void setStopProcessForUpdateRequest(string process, boolean requested)

A convenience method for adding or removing the request for stopping process depending on whether requested is true (add) or false (remove).


void setUninstalled()

Sets the component state to uninstalled.

See also isUninstalled().


void setUpdateAvailable(boolean isUpdateAvailable)

Sets a flag that the core found an update based on the value of isUpdateAvailable.

See also isUpdateAvailable().


void setValue(string key, string value)

Sets the value of the variable with key to value.

See also value().


boolean uninstallationRequested()

Determines whether the user wants to uninstall the component.


boolean updateRequested()

Determines whether the user wants to install the update for this component.


QWidget userInterface(string name)

Returns the QWidget created for name or 0 if the widget has been deleted or cannot be found.


string value(string key, string defaultValue = "")

Returns the value of variable name key. If key is not known yet, defaultValue is returned.

Note: If a component is virtual and you ask for the component value with the key "Default", it will always return false.

See also setValue().


© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. The Qt Company, Qt and their respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.