Skip to content

Commit

Permalink
Revised QtIFW auto elevation workflow, to ensure an UNinstaller canno…
Browse files Browse the repository at this point in the history
…t enter a (funky) broken state by failing to accept a Windows UAC warning.
  • Loading branch information
BuvinJ committed Jan 11, 2021
1 parent 5f74720 commit 03e428c
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 42 deletions.
2 changes: 1 addition & 1 deletion distbuilder/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.7.8.27"
__version__ = "0.7.8.28"
17 changes: 14 additions & 3 deletions distbuilder/qt_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3377,7 +3377,8 @@ def __genPageChangeCallbackBody( self ):
NEW = _QtIfwScript.NEW_LINE
SBLK = _QtIfwScript.START_BLOCK
EBLK = _QtIfwScript.END_BLOCK

ELSE = _QtIfwScript.ELSE

prepend =(
TAB + _QtIfwScript.log( '"page changed to id: " + pageId', isAutoQuote=False ) +
TAB + _QtIfwScript.ifInstalling( isMultiLine=True ) +
Expand All @@ -3397,7 +3398,16 @@ def __genPageChangeCallbackBody( self ):
(2*TAB) + EBLK
if self._isLicenseRequired else ""
) +
EBLK
TAB + EBLK +
TAB + ELSE + SBLK +
(2*TAB) + ('if( pageId == %s )' % (
QtIfwControlScript.toDefaultPageId(
QT_IFW_READY_PAGE),)) + SBLK +
TAB + _QtIfwScript.ifElevated( isNegated=True ) +
_QtIfwScript.quit( "Elevated privileges required!",
isError=True, isSilent=True ) +
(2*TAB) + EBLK +
TAB + EBLK
)
append = ""

Expand Down Expand Up @@ -3786,7 +3796,8 @@ def __genReadyForInstallationPageCallbackBody( self ):
("" if self.readyForInstallationPageOnInstall is None else
(2*TAB) + self.readyForInstallationPageOnInstall) +
EBLK +
ELSE + SBLK +
ELSE + SBLK +
_QtIfwScript.elevate() +
("" if self.readyForInstallationPageOnMaintain is None else
(2*_QtIfwScript.TAB) + self.readyForInstallationPageOnMaintain) +
EBLK +
Expand Down
76 changes: 41 additions & 35 deletions docs/Examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,40 +234,6 @@ produced by, [QtIfwConfigXml](ConfigClasses.md#qtifwpackage) and
[QtIfwPackageXml](ConfigClasses.md#qtifwpackage) objects to give you further
insight into the design patterns and functionality of the library.

## Hello Dynamic Finish Example

TODO: FILL IN!

## Hello Installer UI Example

A QtIwf installer is extremely customizable. In addition to simply copying
files to another machine, it can perform extended operations on that target
to further refine the environment where the program will run. Not only that,
but the installer's interface, and logic flow, can be manipulated to precisely
fit your use case. This example demonstrates a proof of concept modification
to that UI.

This example requires the Hello World Tk files be present in the testing environment
within a directory adjacent to where you will place the build script for this one.
That required folder must be named `hello_world_tk` for this "master" script to
function.

You may download/copy the example file directly from GitHub
(into a `hello_qtifw_ui` directory):

Build script: [build.py](https://raw.githubusercontent.com/BuvinJT/distbuilder/master/examples/hello_qtifw_ui/build.py)

The demo shows how one may assign the [ifwUiPages](HighLevel.md#ifwuipages) attribute of a ConfigFactory to to easily add or replace default installer "pages" / "screens"
with custom definitions. Those pages are represented using [QtIfwUiPage](ConfigClasses.md#qtifwuipage) objects.

The QtIfwUiPage class is designed with the expectation that you may wish to create custom pages using the [Qt Designer WYSIWYG](https://doc.qt.io/qt-5/designer-quick-start.html) tool. Alternatively, your needs maybe met by employing a derived class
e.g. [QtIfwSimpleTextPage](ConfigClasses.md#qtifwsimpletextpage), which draws upon
a built-in library resource file for the page layout.

In concert with altering these visual dimensions of the user experience, you may
revise the logic via [Installer Scripting](LowLevel.md#installer-scripting), or call upon the higher level script abstraction classes [QtIfwControlScript](ConfigClasses.md#qtifwcontrolscript) or
[QtIfwPackageScript](ConfigClasses.md#qtifwpackagescript).

## Hello Wrapper Example

This example provides a **collection** of demonstrations using the
Expand Down Expand Up @@ -317,18 +283,58 @@ If desired, you may also wish to test running these demo programs post installat

TODO: FILL IN!

### Low Level Embedded Script Operations Example

TODO: FILL IN!

### High Level Convenience Operations Example

TODO: FILL IN!

### Low Level Embedded Script Operations Example
### Cascading Scripts Example

TODO: FILL IN!

### Windows Registry Interactions Example

TODO: FILL IN!

## Hello Installer UI Example

A QtIwf installer is extremely customizable. In addition to simply copying
files to another machine, it can perform extended operations on that target
to further refine the environment where the program will run. Not only that,
but the installer's interface, and logic flow, can be manipulated to precisely
fit your use case. This example demonstrates a proof of concept modification
to that UI.

This example requires the Hello World Tk files be present in the testing environment
within a directory adjacent to where you will place the build script for this one.
That required folder must be named `hello_world_tk` for this "master" script to
function.

You may download/copy the example file directly from GitHub
(into a `hello_qtifw_ui` directory):

Build script: [build.py](https://raw.githubusercontent.com/BuvinJT/distbuilder/master/examples/hello_qtifw_ui/build.py)

The demo shows how one may assign the [ifwUiPages](HighLevel.md#ifwuipages) attribute of a ConfigFactory to to easily add or replace default installer "pages" / "screens"
with custom definitions. Those pages are represented using [QtIfwUiPage](ConfigClasses.md#qtifwuipage) objects.

The QtIfwUiPage class is designed with the expectation that you may wish to create custom pages using the [Qt Designer WYSIWYG](https://doc.qt.io/qt-5/designer-quick-start.html) tool. Alternatively, your needs maybe met by employing a derived class
e.g. [QtIfwSimpleTextPage](ConfigClasses.md#qtifwsimpletextpage), which draws upon
a built-in library resource file for the page layout.

In concert with altering these visual dimensions of the user experience, you may
revise the logic via [Installer Scripting](LowLevel.md#installer-scripting), or call upon the higher level script abstraction classes [QtIfwControlScript](ConfigClasses.md#qtifwcontrolscript) or
[QtIfwPackageScript](ConfigClasses.md#qtifwpackagescript).

TODO: Expand to demo custom widgets injected on built-in pages.

## Hello Dynamic Finish Example

TODO: FILL IN!

## Hello Startup Example

TODO: FILL IN!
Expand Down
6 changes: 3 additions & 3 deletions examples/hello_qtiwf_ui/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from distbuilder import PyToBinInstallerProcess, ConfigFactory, \
QtIfwSimpleTextPage, QT_IFW_TARGET_DIR_PAGE, QtIfwControlScript as script
QtIfwSimpleTextPage, QT_IFW_TARGET_DIR_PAGE, QtIfwControlScript as Script

f = configFactory = ConfigFactory()
f.productName = "Hello Custom Installer UI Example"
Expand All @@ -16,8 +16,8 @@
f.ifwUiPages = QtIfwSimpleTextPage( "Example", QT_IFW_TARGET_DIR_PAGE,
title="Custom Page",
text="This is a custom page for the @ProductName@ wizard!",
onEnter=( script.assignCustomPageWidgetVar( "Example" ) +
script.ifYesNoPopup( "Would you like to perform a dynamic action?" ) +
onEnter=( Script.assignCustomPageWidgetVar( "Example" ) +
Script.ifYesNoPopup( "Would you like to perform a dynamic action?" ) +
'page.description.setText( ' +
'"<p style=\\"color: red\\">" + page.description.text + "</p>");'
)
Expand Down

0 comments on commit 03e428c

Please sign in to comment.