Skip to content

Commit

Permalink
Added openViaOs function to installer along with integration of it in…
Browse files Browse the repository at this point in the history
…to QtIfwOnFinishedCheckbox. (Some minor cleanup needed in demo of it...)
  • Loading branch information
BuvinJ committed Nov 13, 2020
1 parent bf76e36 commit 8892f61
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
16 changes: 13 additions & 3 deletions distbuilder/qt_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2302,6 +2302,8 @@ class QtIfwControlScript( _QtIfwScript ):
%s
}
""" )

__OPEN_VIA_OS_TMPL = "QDesktopServices.openUrl( resolveDynamicVars( %s ) );\n"

BACK_BUTTON = "buttons.BackButton"
NEXT_BUTTON = "buttons.NextButton"
Expand Down Expand Up @@ -2502,6 +2504,11 @@ def setCustomText( controlName, text, isAutoQuote=True, pageVar="page" ):
def getCustomText( controlName, pageVar="page" ):
return QtIfwControlScript.__GET_CUSTPAGE_TEXT_TMPL % (pageVar, controlName)

@staticmethod
def openViaOs( path, isAutoQuote=True ):
return QtIfwControlScript.__OPEN_VIA_OS_TMPL % (
_QtIfwScript._autoQuote( path, isAutoQuote ) )

# QtIfwControlScript
def __init__( self,
fileName=DEFAULT_QT_IFW_SCRIPT_NAME,
Expand Down Expand Up @@ -5609,9 +5616,10 @@ class QtIfwOnFinishedCheckbox( QtIfwWidget ):
__EXEC_DETACHED_TMPLT='executeDetached( resolveQtIfwPath( "%s" ), %s );\n'

# QtIfwOnFinishedCheckbox
def __init__( self, name, position=None,
def __init__( self, name, text=None, position=None,
ifwPackage=None, script=None,
text=None, runProgram=None, argList=None,
openViaOsPath=None,
runProgram=None, argList=None,
isVisible=True, isEnabled=True, isChecked=True ) :
QtIfwWidget.__init__( self, name, QtIfwOnFinishedCheckbox.__PAGE_ID,
position=( position if position else
Expand All @@ -5623,7 +5631,9 @@ def __init__( self, name, position=None,
if isinstance( ifwPackage, QtIfwPackage ):
self.__setFromPackage( ifwPackage, argList )
elif isinstance( script, ExecutableScript ):
self.__setFromScript( script, argList )
self.__setFromScript( script, argList )
elif openViaOsPath:
self._action = QtIfwControlScript.openViaOs( openViaOsPath )
else :
self.runProgram = runProgram
self.argList = argList
Expand Down
4 changes: 2 additions & 2 deletions docs/ConfigClasses.md
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ to access the UI elements.
generating. (This not somehow literally "invoke" the function when called from the Python
library! )

## QtIfwOnPriorInstallationPage
### QtIfwOnPriorInstallationPage

This class is derived from `QtIfwUiPage`. As one would assume, this provides a base
from which to start modifying the distbuilder addition to QtIFW "Prior Installation Detected"
Expand Down Expand Up @@ -1306,7 +1306,7 @@ Constructor:
title="", text="",
onLoad=None, onEnter=None )

### QtIfwWidget
## QtIfwWidget

This class closely resembles [QtIfwUiPage](#qtifwuipage). They internally derive
from a common (protected) base class. In contrast, however, QtIfwWidgets are
Expand Down
2 changes: 2 additions & 0 deletions docs/LowLevel.md
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,8 @@ Static Constants :

Static Functions:

openViaOs( path, isAutoQuote=True )

currentPageWidget()
assignCurrentPageWidgetVar( varName="page" )
Expand Down
27 changes: 24 additions & 3 deletions examples/hello_packages/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,19 @@ def customizeFinishedPage( cfg, tkPkg, cliPkg ):
runTkCheckbox = QtIfwOnFinishedCheckbox(
"runTk", ifwPackage=tkPkg )
runCliCheckbox = QtIfwOnFinishedCheckbox(
"runCli", ifwPackage=cliPkg )
cfg.addUiElements( [ runTkCheckbox, runCliCheckbox ] )
"runCli", ifwPackage=cliPkg )
openLicenseViaOsCheckbox = QtIfwOnFinishedCheckbox(
"openLicViaOs", text="Open License w/ Default Editor",
openViaOsPath=joinPathQtIfw( QT_IFW_TARGET_DIR, "LICENSE" ) )
openOnlineManualViaOsCheckbox = QtIfwOnFinishedCheckbox(
"openOnlineManualViaOs", text="Open Online Manual",
openViaOsPath="https://distribution-builder.readthedocs.io/en/latest/" )
cfg.addUiElements([
runTkCheckbox
, runCliCheckbox
, openLicenseViaOsCheckbox
, openOnlineManualViaOsCheckbox
])

# Add custom QScript to the finished page
SCRPT = QtIfwControlScript
Expand All @@ -88,6 +99,10 @@ def customizeFinishedPage( cfg, tkPkg, cliPkg ):
runTkCheckbox.setVisible( False ) +
runCliCheckbox.setChecked( False ) +
runCliCheckbox.setVisible( False ) +
openLicenseViaOsCheckbox.setVisible( False ) +
openLicenseViaOsCheckbox.setVisible( False ) +
openOnlineManualViaOsCheckbox.setChecked( True ) +
openOnlineManualViaOsCheckbox.setVisible( True ) +
EBLK + ELSE + SBLK +
SCRPT.setText( MSG_LBL, DEFAULT_MSG ) +
SCRPT.ifComponentInstalled( tkPkg.name ) +
Expand All @@ -105,7 +120,13 @@ def customizeFinishedPage( cfg, tkPkg, cliPkg ):
runCliCheckbox.setChecked(
SCRPT.isComponentInstalled( cliPkg.name ) ) +
runCliCheckbox.setVisible(
SCRPT.isComponentInstalled( cliPkg.name ) ) +
SCRPT.isComponentInstalled( cliPkg.name ) ) +
openLicenseViaOsCheckbox.setChecked(
SCRPT.isComponentInstalled( cliPkg.name ) ) +
openLicenseViaOsCheckbox.setVisible(
SCRPT.isComponentInstalled( cliPkg.name ) ) +
openOnlineManualViaOsCheckbox.setChecked( True ) +
openOnlineManualViaOsCheckbox.setVisible( True ) +
EBLK
)

Expand Down

0 comments on commit 8892f61

Please sign in to comment.