Skip to content

Commit

Permalink
Continued ironing out assorted deeper logic issues with QtIfwOnFinish…
Browse files Browse the repository at this point in the history
…edCheckbox. Added .txt extension to example/demo license file and references to it.
  • Loading branch information
BuvinJ committed Nov 13, 2020
1 parent 8892f61 commit cdf201e
Show file tree
Hide file tree
Showing 14 changed files with 150 additions and 111 deletions.
1 change: 0 additions & 1 deletion distbuilder/master.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import sys
import six
from abc import ABCMeta, abstractmethod
from copy import deepcopy
from datetime import datetime
from time import time as curTime

Expand Down
128 changes: 83 additions & 45 deletions distbuilder/qt_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,21 @@ def add( pkg, ui ):
pkg.pkgScript.uiPages.append( page )
self.controlScript.uiPages.append( page )
elif widget:
# order doesn't matter for these lists, but the items should be unique
# items must unique and sorted
sortAttr1 = "pageName"
sortAttr2 = "position"
sortAttr3 = "name"
pkg.widgets.append( widget )
pkg.widgets = list(set(pkg.widgets))
pkg.pkgScript.widgets.append( widget )
pkg.pkgScript.widgets = list(set(pkg.pkgScript.widgets))
pkg.widgets = sorted(list(set(pkg.widgets)),
key=attrgetter(sortAttr1, sortAttr2, sortAttr3) )
# a copy here might be faster than another append + sort?
pkg.pkgScript.widgets = deepcopy( pkg.widgets )
# can't just copy this from the package, because it is a
# different (encompassing) collection
self.controlScript.widgets.append( widget )
self.controlScript.widgets = list(set(self.controlScript.widgets))
self.controlScript.widgets = sorted(list(set(
self.controlScript.widgets)),
key=attrgetter(sortAttr1, sortAttr2, sortAttr3) )
# order doesn't matter for this list, but the items should be unique
pkg.pkgXml.UserInterfaces.append( ui.fileName() )
pkg.pkgXml.UserInterfaces = list(set(pkg.pkgXml.UserInterfaces))
Expand Down Expand Up @@ -1028,11 +1036,12 @@ def lookupValue( key, default="", isAutoQuote=True ):
_QtIfwScript._autoQuote( default, isAutoQuote ))

@staticmethod
def lookupBoolValue( key, isAutoQuote=True ):
return ( '(%s=="%s")' %
( _QtIfwScript.lookupValue( key, isAutoQuote=isAutoQuote ) ,
_QtIfwScript.TRUE ) )

def lookupBoolValue( key, isNegated=False, isHardFalse=False, isAutoQuote=True ):
return '( %s%s"%s" )' % (
_QtIfwScript.lookupValue( key, isAutoQuote=isAutoQuote ),
("!=" if isNegated and not isHardFalse else "==") ,
(_QtIfwScript.FALSE if isHardFalse else _QtIfwScript.TRUE) )

@staticmethod
def ifValueDefined( key, isNegated=False, isMultiLine=False ):
return 'if( %s%s"" )%s\n%s' % (
Expand All @@ -1041,12 +1050,11 @@ def ifValueDefined( key, isNegated=False, isMultiLine=False ):
("{" if isMultiLine else ""), (2*_QtIfwScript.TAB) )

@staticmethod
def ifBoolValue( key, isNegated=False, isHardFalse=False, isMultiLine=False ):
if isHardFalse: isNegated=True
def ifBoolValue( key, isNegated=False, isHardFalse=False, isMultiLine=False ):
return 'if( %s%s"%s" )%s\n%s' % (
_QtIfwScript.lookupValue( key ),
("!=" if isNegated and not isHardFalse else "==") ,
(_QtIfwScript.TRUE if isNegated and isHardFalse else _QtIfwScript.TRUE),
(_QtIfwScript.FALSE if isHardFalse else _QtIfwScript.TRUE),
("{" if isMultiLine else ""), (2*_QtIfwScript.TAB) )

@staticmethod
Expand Down Expand Up @@ -1135,8 +1143,9 @@ def cmdLineArg( arg, default="" ):
return _QtIfwScript.lookupValue( arg, default )

@staticmethod
def cmdLineSwitchArg( arg, isAutoQuote=True ):
return _QtIfwScript.lookupBoolValue( arg, isAutoQuote )
def cmdLineSwitchArg( arg, isNegated=False, isHardFalse=False ):
return _QtIfwScript.lookupBoolValue( arg,
isNegated=isNegated, isHardFalse=isHardFalse )

@staticmethod
def cmdLineListArg( arg, default=None ):
Expand All @@ -1162,6 +1171,16 @@ def ifInstalling( isMultiLine=False ):
_QtIfwScript.__IS_INSTALLER,
("{" if isMultiLine else ""), (2*_QtIfwScript.TAB) )

@staticmethod
def isAutoPilot( isNegated=False ):
return _QtIfwScript.lookupBoolValue( _QtIfwScript.AUTO_PILOT_CMD_ARG,
isNegated=isNegated )

@staticmethod
def ifAutoPilot( isNegated=False, isMultiLine=False ):
return _QtIfwScript.ifCmdLineSwitch( _QtIfwScript.AUTO_PILOT_CMD_ARG,
isNegated=isNegated, isMultiLine=isMultiLine )

@staticmethod
def yesNoPopup( msg, title="Question", resultVar="result" ):
return _QtIfwScript.__YES_NO_POPUP_TMPL % ( resultVar, title, msg )
Expand Down Expand Up @@ -2578,7 +2597,7 @@ def __init__( self,

self.isFinishedPageVisible = True
self.finishedPageCallbackBody = None
self.finishedPageCallBackTail = None
self.finishedPageOnInstall = None
self.isAutoFinishedPageCallback = True

self.isRunProgVisible = True
Expand Down Expand Up @@ -2776,19 +2795,28 @@ def __genPageVisibilityRequestCallbackBody( self ):
isAutoQuote=False )

def __genFinishedClickedCallbackBody( self ):
EBLK =_QtIfwScript.END_BLOCK
TAB = _QtIfwScript.TAB
EBLK = _QtIfwScript.END_BLOCK

prepend = _QtIfwScript.log( "finish clicked" )

for w in self.widgets:
if isinstance( w, QtIfwOnFinishedCheckbox ):
prepend += (
QtIfwControlScript.ifChecked( w.checkboxName,
# Execute custom on wizard finished/exited actions
finshedCheckboxes = [ w for w in self.widgets
if isinstance( w, QtIfwOnFinishedCheckbox ) ]
if len(finshedCheckboxes) > 0:
prepend +=( TAB +
_QtIfwScript.ifBoolValue( _QtIfwScript.INTERUPTED_KEY,
isNegated=True, isMultiLine=True ) +
(2*TAB) + _QtIfwScript.ifInstalling( isMultiLine=True )
)
for checkbox in finshedCheckboxes:
prepend += ( (3*TAB) +
QtIfwControlScript.ifChecked( checkbox.checkboxName,
isMultiLine=True ) +
w._action +
EBLK
)
checkbox._action + EBLK )
prepend += EBLK + EBLK

# Remove keep alive file
append =(
_QtIfwScript.ifMaintenanceTool( isNegated=True, isMultiLine=True ) +
_QtIfwScript.ifCmdLineArg( _QtIfwScript._KEEP_ALIVE_PATH_CMD_ARG ) +
Expand All @@ -2797,6 +2825,7 @@ def __genFinishedClickedCallbackBody( self ):
isAutoQuote=False ) +
EBLK
)

if self.onFinishedClickedCallbackBody is None:
self.onFinishedClickedCallbackBody=""
self.onFinishedClickedCallbackBody =(
Expand Down Expand Up @@ -3180,36 +3209,45 @@ def __genPerformInstallationPageCallbackBody( self ):

def __genFinishedPageCallbackBody( self ):
TAB = _QtIfwScript.TAB
SBLK = _QtIfwScript.START_BLOCK
EBLK = _QtIfwScript.END_BLOCK
self.finishedPageCallbackBody = (
TAB + _QtIfwScript.log("FinishedPageCallback") +
TAB + _QtIfwScript.ifBoolValue( _QtIfwScript.INTERUPTED_KEY, isMultiLine=True ) +
QtIfwControlScript.setVisible(
QtIfwControlScript.RUN_PROGRAM_CHECKBOX, False ) +
(2*TAB) + QtIfwControlScript.enable(
QtIfwControlScript.RUN_PROGRAM_CHECKBOX, False ) +
(2*TAB) + QtIfwControlScript.setChecked(
QtIfwControlScript.RUN_PROGRAM_CHECKBOX, False ) +
QtIfwControlScript.RUN_PROGRAM_CHECKBOX, False )
)
for w in self.widgets:
# TODO: Do something similar for all widgets, in some unified manner?
# Perhaps an abstract onInterupted function?
if isinstance( w, QtIfwOnFinishedCheckbox ):
self.finishedPageCallbackBody += (
w.setVisible( False ) + w.setChecked( False ) )
self.finishedPageCallbackBody += (
EBLK +
TAB + "else " + _QtIfwScript.ifInstalling( isMultiLine=True ) +
TAB + QtIfwControlScript.setVisible(
QtIfwControlScript.RUN_PROGRAM_CHECKBOX,
self.isRunProgVisible ) +
TAB + QtIfwControlScript.enable(
QtIfwControlScript.RUN_PROGRAM_CHECKBOX,
self.isRunProgEnabled ) +
(TAB + _QtIfwScript.ifCmdLineArg(
_QtIfwScript.RUN_PROGRAM_CMD_ARG ) +
_QtIfwScript.TAB + QtIfwControlScript.setChecked(
TAB + "else " + SBLK +
(2*TAB) + _QtIfwScript.ifInstalling( isMultiLine=True ) +
(3*TAB) + QtIfwControlScript.setVisible(
QtIfwControlScript.RUN_PROGRAM_CHECKBOX,
self.isRunProgVisible ) +
(3*TAB) + QtIfwControlScript.enable(
QtIfwControlScript.RUN_PROGRAM_CHECKBOX,
_QtIfwScript.cmdLineSwitchArg(
_QtIfwScript.RUN_PROGRAM_CMD_ARG ) )
if self.isRunProgChecked else
TAB + QtIfwControlScript.setChecked(
QtIfwControlScript.RUN_PROGRAM_CHECKBOX, False )
) +
("" if self.finishedPageCallBackTail is None else
self.finishedPageCallBackTail) +
self.isRunProgEnabled ) +
((3*TAB) + _QtIfwScript.ifCmdLineArg(
_QtIfwScript.RUN_PROGRAM_CMD_ARG ) +
_QtIfwScript.TAB + QtIfwControlScript.setChecked(
QtIfwControlScript.RUN_PROGRAM_CHECKBOX,
_QtIfwScript.cmdLineSwitchArg(
_QtIfwScript.RUN_PROGRAM_CMD_ARG ) )
if self.isRunProgChecked else
(3*TAB) + QtIfwControlScript.setChecked(
QtIfwControlScript.RUN_PROGRAM_CHECKBOX, False )
) +
("" if self.finishedPageOnInstall is None else
(2*TAB) + self.finishedPageOnInstall) +
(2*TAB) + EBLK +
TAB + EBLK +
TAB + _QtIfwScript.ifCmdLineSwitch( _QtIfwScript.AUTO_PILOT_CMD_ARG ) +
TAB + QtIfwControlScript.clickButton(
Expand Down
2 changes: 2 additions & 0 deletions distbuilder/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
from time import sleep
from struct import calcsize
import base64 # @UnusedImport
from operator import attrgetter # @UnusedImport
from copy import deepcopy # @UnusedImport

# -----------------------------------------------------------------------------
__plat = platform.system()
Expand Down
2 changes: 1 addition & 1 deletion docs/ConfigClasses.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ Attributes & default values:
isFinishedPageVisible = True
finishedPageCallbackBody = None
finishedPageCallBackTail = None
finishedPageOnInstall = None
isAutoFinishedPageCallback = True

isRunProgVisible = True
Expand Down
7 changes: 5 additions & 2 deletions docs/LowLevel.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,22 +469,25 @@ Static Functions:
setBoolValue( key, b, isAutoQuote=True )
lookupValue( key, default="", isAutoQuote=True )
lookupBoolValue( key, isAutoQuote=True )
lookupBoolValue( key, isNegated=False, isHardFalse=False, isAutoQuote=True )
lookupValueList( key, defaultList=[], isAutoQuote=True,
delimiter=None )

ifValueDefined( key, isNegated=False, isMultiLine=False )
ifBoolValue( key, isNegated=False, isHardFalse=False, isMultiLine=False )

cmdLineArg( arg, default="" )
cmdLineSwitchArg( arg )
cmdLineSwitchArg( arg, isNegated=False, isHardFalse=False )
cmdLineListArg( arg, default=[] )
ifCmdLineArg( arg, isNegated=False, isMultiLine=False, )
ifCmdLineSwitch( arg, isNegated=False, isHardFalse=False, isMultiLine=False )
isMaintenanceTool( isNegated=False )
ifMaintenanceTool( isNegated=False, isMultiLine=False )
ifInstalling( isMultiLine=False )

isAutoPilot( isNegated=False )
ifAutoPilot( isNegated=False, isMultiLine=False )

isElevated()
ifElevated( isNegated=False, isMultiLine=False )
Expand Down
4 changes: 4 additions & 0 deletions docs/ToDo.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ Have prompts questioning if the using wants to update or revert to a prior versi

* Add "pure" QScript (custom operations) examples / features for QtIFW.

* Determine if custom UI elements can be used in an uninstaller context? How about an update?
The ui forms are contained in packages, per QtIFW design. But packages are not loaded
during uninstallation, so it seems an uninstaller couldn't support such ui customization...

## v.0.8.1

* Revisit "QtIfwExeWrapper" details. Specifically: NON gui on Windows? Used with QtIfwOnFinishedCheckbox?
Expand Down
13 changes: 9 additions & 4 deletions examples/hello_merge/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
f.version = (1,0,0,0)
f.setupName = "HelloMergeSetup"

# Define a "Package Factory Dictionary"
# Note: None values for a ConfigFactory results in making a clone of the
# master, which can then be customization from that "base" within
# RobustInstallerProcess.onConfigFactory
TK_CONFIG_KEY = "tk"
CLI_CONFIG_KEY = "cli"
pkgFactories={ TK_CONFIG_KEY:None, CLI_CONFIG_KEY:None }
Expand Down Expand Up @@ -36,7 +40,7 @@ def onConfigFactory( self, key, f ):
f.entryPointPy = "hello.py"
f.isObfuscating = False
f.iconFilePath = None
f.distResources = ["LICENSE"]
f.distResources = ["LICENSE.TXT"]

def onOpyConfig( self, key, cfg ):
if key==TK_CONFIG_KEY:
Expand All @@ -47,9 +51,10 @@ def onPackagesStaged( self, cfg, pkgs ):
comboPkg = mergeQtIfwPackages( pkgs, CLI_CONFIG_KEY, TK_CONFIG_KEY )
#comboPkg = nestQtIfwPackage( pkgs, CLI_CONFIG_KEY, TK_CONFIG_KEY )

# Note: it would be more efficient to set these to the desired values
# prior to the package merge, but this illustrates how you can revise
# these configurations manually at this point in the build process.
# Note: it may be slightly more efficient to set these to the desired
# values prior to the package merge, but this illustrates how you can
# revise these configurations manually at this point in the build
# process.
configXml = cfg.configXml
configXml.RunProgramDescription = "Start Hello World Tk Example"
print( "Regenerating {0}...".format( configXml.path() ) )
Expand Down

0 comments on commit cdf201e

Please sign in to comment.