【问题标题】:Qt Installer Framework: conditional action based on whether a component was selected for installationQt Installer Framework:基于是否选择安装组件的条件操作
【发布时间】:2018-07-15 22:30:06
【问题描述】:

通常:我需要一个 bool 或其他挂钩来确定是否已选择安装组件,以便我的 controlscript.qs(或特定于组件的 installscript.qs)可以采取适当的操作。

特别是:Qt 安装程序框架有几个默认页面供用户单击。在 Windows 上,有一个 StartMenuSelection 页面,允许用户在 Windows 开始菜单中指定应用程序的快捷方式应该进入哪个组(如果有)。

Start Menu group selection example

我要安装的组件之一是“开始”菜单中的(可选)快捷方式。如果未选择安装,则在开始菜单中将没有已安装应用程序的快捷方式。

我的问题是,无论用户是否在“开始”菜单中请求快捷方式,都会显示“开始菜单”组选择页面。我知道如何在所有情况下摆脱它。但不是以是否实际安装开始菜单快捷方式为条件。

我有一个包含以下内容的控制脚本:

function Controller()
{
}

Controller.prototype.StartMenuDirectoryPageCallback = function()
{
  // Get the current wizard page
  var widget = gui.currentPageWidget(); 
  if (widget != null) {
    var component = installer.componentByName("startmenu"); // startmenu is the component name
    //if (!component.isSelected){
    //if (!component.isSelectedForInstallation){
    if (!component.isInstalled){
      // I only want this hidden if the user didn't want a start menu link
      // Either of the below commands will skip the startMenuSelection page
      installer.setDefaultPageVisible(QInstaller.StartMenuSelection, false);
      //gui.clickButton(buttons.NextButton);
    }
  }
}

但这不起作用。 component.isSelected 和 component.isSelectedForInstallation 始终返回 false,而 component.isInstalled 始终返回 true,无论是否实际选择了组件进行安装。也许这些是错误的布尔值?

或者也许这是错误的方法?本质上,我只需要一个钩子来确定一个组件是否被选中。

【问题讨论】:

    标签: qt


    【解决方案1】:

    刚刚找到这个链接: https://github.com/danimo/qt-creator/blob/master/dist/installer/ifw/packages/org.qtproject.qtcreator.application/meta/installscript.qs

    他们在这里使用:

    component.installed

    isInstalled 是一个函数 (http://doc.qt.io/qtinstallerframework/scripting-component.html#isInstalled-method),这就是为什么它可能总是返回 true。 所以可能component.isInstalled() 也可以工作......

    要么,installationRequested() 将是另一种使用的可能性。这可能是在实际安装之前设置的。

    【讨论】:

    • 感谢您的建议。 component.installed 或正确使用 isInstalled() 作为函数都不起作用,但起作用的是 installationRequested()。我不知道我以前是怎么错过的。如果不是你的评论,我不会找到它。因此,如果您编辑答案,我会接受。
    猜你喜欢
    • 2019-11-16
    • 2013-10-03
    • 1970-01-01
    • 2016-01-25
    • 2017-08-14
    • 1970-01-01
    • 1970-01-01
    • 2022-06-10
    • 1970-01-01
    相关资源
    最近更新 更多