Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QtScript in Qt Installer framework
QtWS25 Last Chance

QtScript in Qt Installer framework

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Noturnoz
    wrote on last edited by
    #1

    Hello,

    I have a simple .ui file which contains checkbox object named "LogOut", the man frame is object named "LogOutCheckBoxForm". I add this to the QInstaller.InstallationFinished page. It is correctly added there, I can see it the at end of the installation. I want to log out the user from the computer (Mac OS X) when the checkbox is checked and the user clicks finish. But the problem is that when the user checks the checkbox and clicks the Finish button, nothing happens.

    I have following installscript.js

    @function Component(){
    component.loaded.connect(this, componentLoaded);
    installer.finishButtonClicked.connect(this, finishClicked);
    }

    componentLoaded = function(){
    if(installer.isInstaller()){
    installer.addWizardPageItem(component, "LogOutCheckBoxForm", QInstaller.InstallationFinished);

    }
    

    }

    finishClicked = function(){
    if(!component.installed)
    return;

    if(installer.isInstaller() && installer.status == QInstaller.Success){
        var isLogOutChecked = component.userInterface("LogOutCheckBoxForm").LogOut.checked;
        if (isLogOutChecked) {
            installer.execute("osascript", new Array("-e \'tell application \"loginwindow\" to  «event aevtrlgo»\'"));
        }
    }
    

    }@

    package.xml:
    @<?xml version="1.0" encoding="UTF-8"?>
    <Package>
    <DisplayName>Log out test/DisplayName>
    <Description>Log out test</Description>
    <Version>1.0.0</Version>
    <ReleaseDate>2015-01-23</ReleaseDate>
    <Default>true</Default>
    [removed]installscript.qs[removed]
    <ForcedInstallation>true</ForcedInstallation>
    <RequiresAdminRights>true</RequiresAdminRights>
    <UserInterfaces>
    <UserInterface>logoutcheckboxform.ui</UserInterface>
    </UserInterfaces>
    </Package>@

    Edit:

    Ok, I've found out that problem is with the @installer.execute("osascript", new Array("-e 'tell application "loginwindow" to «event aevtrlgo»'"));@ part, because when I place there QDesktopServices.openUrl(http://www.qt-project.org) it opens the web page.

    Am I calling it wrong? Is there any other way to call shell command from qtscript?

    1 Reply Last reply
    0
    • W Offline
      W Offline
      Wilmord
      wrote on last edited by Wilmord
      #2

      Hello,

      I want to ask another question to you. How can I make the Uninstaller check exe is running or not before uninstalling? I can do this with installing process but I can not write correct script (installscript.qs) for uninstalling process.

      This is my script. Or Should I write another script for Uninstaller?

      function cancelInstaller()
      {
      installer.setDefaultPageVisible(QInstaller.Introduction, false);
      installer.setDefaultPageVisible(QInstaller.TargetDirectory, false);
      installer.setDefaultPageVisible(QInstaller.ComponentSelection, false);
      installer.setDefaultPageVisible(QInstaller.ReadyForInstallation, false);
      installer.setDefaultPageVisible(QInstaller.StartMenuSelection, false);
      installer.setDefaultPageVisible(QInstaller.PerformInstallation, false);
      installer.setDefaultPageVisible(QInstaller.LicenseCheck, false);

      installer.setValue("FinishedText", "Operation was canceled!");
      

      }

      function Component()
      {
      var programFiles = installer.environmentVariable("ProgramFiles");
      if (programFiles != "")
      installer.setValue("TargetDir", programFiles + "/A");

      var programValid = true;
      
      if(installer.isProcessRunning("A.exe") == true)
      {			
      	QMessageBox["warning"]("os.warning", "Installer","Program is currently running!",QMessageBox.Ok);
      	
      	programValid = false;
      	
      }
      
      	
      if (!programValid) {
      	cancelInstaller();
      	return;
      }
      

      }

      Component.prototype.isDefault = function()
      {
      // select the component by default
      return true;
      }

      Component.prototype.createOperations = function()
      {
      try {
      // call the base create operations function
      component.createOperations();
      if (installer.value("os") === "win") {
      component.addElevatedOperation("Execute", "{0,3010}", "@TargetDir@\vcredist\vcredist_x86.exe", "/norestart", "/q");
      component.addOperation("CreateShortcut", "@TargetDir@/A.exe", "@StartMenuDir@/A.lnk");
      component.addOperation("CreateShortcut", "@TargetDir@/uninstall.exe", "@StartMenuDir@/Uninstall.lnk");
      component.addOperation("CreateShortcut", "@TargetDir@/A.exe", "@DesktopDir@/A.lnk");
      }
      } catch (e) {
      print(e);
      }
      }

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved