您可以在卸载程序(QtInstallerFramework)上添加WizardPage吗?

问题描述 投票:0回答:1

我正在使用

QtInstallerFramework
,并且我尝试在 卸载应用程序时添加自定义页面。

我有

custompage.ui
文件(简单文本),我将其添加到我的
package.xml
:

<UserInterfaces>
        <UserInterface>custompage.ui</UserInterface>
</UserInterfaces>

这就是我在我的

componentscript.js
中使用它的方式:

Component.prototype.componentLoaded = function ()
{
    installer.addWizardPage(component, "CustomPage", QInstaller.ReadyForInstallation)
}

问题是只有当我安装应用程序时才会显示该页面。当我卸载它时,自定义页面不显示。

另外,用另一种方法,如果我尝试在我的

controlscript.js
中添加自定义页面,如下所示:

Controller.prototype.ReadyForInstallationPageCallback = function ()
{
    try {
        installer.addWizardPage(component, "CustomPage", QInstaller.ReadyForInstallation);
    }
    catch (e) {
        QMessageBox.warning("QMessageBox", "", e, QMessageBox.Ok);
    }
}

我收到此错误:

ReferenceError: component is not defined

所以,卸载应用程序时,看起来该组件根本没有加载。
Qt文档我们只能在带有<UserInterfaces>

标签的组件xml
文件中添加自定义页面。
这是否意味着我们无法在卸载程序中使用自定义 GUI 页面或者我丢失了某些内容?

javascript qt windows-installer uninstallation qt-installer
1个回答
0
投票

安装过程中,

package.xml
componentscript.js
完全有效,允许动态添加向导页面。
但是,在卸载过程中,框架不会以相同的方式处理组件脚本,这就是为什么您会看到自定义页面没有出现。

[Installer/Uninstaller Process]
┌────────────────────┐   ┌──────────────────────────┐   ┌─────────────────────────┐
│ package.xml        │   │ componentscript.js       │   │ installscript.qs        │
│  └─ UserInterfaces │──►│  └─ addWizardPage(...)   │──►│  └─ Conditionall        │
└────────────────────┘   └──────────────────────────┘   │    modify wizard        │
            │                              ▲            └─────────────────────────┘
            │                              │                        ▲
            └──────────────────────────────┘                        │
                         Installation Process                       │
                                                            Uninstallation Process

您应该使用

installscript.qs
注入在 both 安装和卸载期间运行的自定义逻辑(如本示例中的 )。
由于此脚本在两种上下文中执行,因此它是有条件地应用卸载过程修改的理想位置。
它可以通过条件检查区分安装和卸载,从而在卸载阶段启用特定操作。

使用

installer.isUninstaller()
确定卸载过程是否正在进行,然后继续执行添加或修改向导页面的自定义逻辑。

您可以通过

installer.addWizardPage
为安装过程添加自定义页面。
对于卸载,请考虑修改现有页面或使用installscript.qs中的
可用挂钩
与卸载过程进行交互。

installscript.qs

function Controller() {
    // Constructor for script
}

Controller.prototype.IntroductionPageCallback = function() {
    if (installer.isUninstaller()) {
        // Custom logic for uninstallation, e.g., modifying the Introduction page
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.