Warning, /frameworks/syntax-highlighting/autotests/folding/installer_krita.nsi.fold is written in an unsupported language. File is not indexed.

0001 !ifndef KRITA_INSTALLER_32 & KRITA_INSTALLER_64
0002         !error "Either one of KRITA_INSTALLER_32 or KRITA_INSTALLER_64 must be defined."
0003 !endif
0004 !ifdef KRITA_INSTALLER_32 & KRITA_INSTALLER_64
0005         !error "Only one of KRITA_INSTALLER_32 or KRITA_INSTALLER_64 should be defined."
0006 !endif
0007 
0008 !ifndef KRITA_PACKAGE_ROOT
0009         !error "KRITA_PACKAGE_ROOT should be defined and point to the root of the package files."
0010 !endif
0011 
0012 !ifdef KRITA_INSTALLER_64
0013         !define KRITA_INSTALLER_BITNESS 64
0014 !else
0015         !define KRITA_INSTALLER_BITNESS 32
0016 !endif
0017 
0018 Unicode true
0019 # Enabling DPI awareness creates awful CJK text in some sizes, so don't enable it.
0020 ManifestDPIAware false
0021 
0022 # Krita constants (can be overridden in command line params)
0023 !define /ifndef KRITA_VERSION "0.0.0.0"
0024 !define /ifndef KRITA_VERSION_DISPLAY "test-version"
0025 #!define /ifndef KRITA_VERSION_GIT ""
0026 !define /ifndef KRITA_INSTALLER_OUTPUT_DIR ""
0027 !ifdef KRITA_INSTALLER_64
0028         !define /ifndef KRITA_INSTALLER_OUTPUT_NAME "krita_x64_setup.exe"
0029 !else
0030         !define /ifndef KRITA_INSTALLER_OUTPUT_NAME "krita_x86_setup.exe"
0031 !endif
0032 
0033 # Krita constants (fixed)
0034 !if "${KRITA_INSTALLER_OUTPUT_DIR}" == ""
0035         !define KRITA_INSTALLER_OUTPUT "${KRITA_INSTALLER_OUTPUT_NAME}"
0036 !else
0037         !define KRITA_INSTALLER_OUTPUT "${KRITA_INSTALLER_OUTPUT_DIR}\${KRITA_INSTALLER_OUTPUT_NAME}"
0038 !endif
0039 !define KRTIA_PUBLISHER "Krita Foundation"
0040 !ifdef KRITA_INSTALLER_64
0041         !define KRITA_PRODUCTNAME "Krita (x64)"
0042         !define KRITA_UNINSTALL_REGKEY "Krita_x64"
0043 !else
0044         !define KRITA_PRODUCTNAME "Krita (x86)"
0045         !define KRITA_UNINSTALL_REGKEY "Krita_x86"
0046 !endif
0047 
0048 VIProductVersion "${KRITA_VERSION}"
0049 VIAddVersionKey "CompanyName" "${KRTIA_PUBLISHER}"
0050 VIAddVersionKey "FileDescription" "${KRITA_PRODUCTNAME} ${KRITA_VERSION_DISPLAY} Setup"
0051 VIAddVersionKey "FileVersion" "${KRITA_VERSION}"
0052 VIAddVersionKey "InternalName" "${KRITA_INSTALLER_OUTPUT_NAME}"
0053 VIAddVersionKey "LegalCopyright" "${KRTIA_PUBLISHER}"
0054 VIAddVersionKey "OriginalFileName" "${KRITA_INSTALLER_OUTPUT_NAME}"
0055 VIAddVersionKey "ProductName" "${KRITA_PRODUCTNAME} ${KRITA_VERSION_DISPLAY} Setup"
0056 VIAddVersionKey "ProductVersion" "${KRITA_VERSION}"
0057 
0058 BrandingText "[NSIS ${NSIS_VERSION}]  ${KRITA_PRODUCTNAME} ${KRITA_VERSION}"
0059 
0060 Name "${KRITA_PRODUCTNAME} ${KRITA_VERSION_DISPLAY}"
0061 OutFile ${KRITA_INSTALLER_OUTPUT}
0062 !ifdef KRITA_INSTALLER_64
0063         InstallDir "$PROGRAMFILES64\Krita (x64)"
0064 !else
0065         InstallDir "$PROGRAMFILES32\Krita (x86)"
0066 !endif
0067 XPstyle on
0068 
0069 ShowInstDetails show
0070 ShowUninstDetails show
0071 
0072 Var KritaStartMenuFolder
0073 Var CreateDesktopIcon
0074 
0075 !include MUI2.nsh
0076 
0077 !define MUI_FINISHPAGE_NOAUTOCLOSE
0078 
0079 # Installer Pages
0080 !insertmacro MUI_PAGE_WELCOME
0081 !define MUI_LICENSEPAGE_CHECKBOX
0082 !insertmacro MUI_PAGE_LICENSE "license_gpl-3.0.rtf"
0083 !insertmacro MUI_PAGE_DIRECTORY
0084 !insertmacro MUI_PAGE_COMPONENTS
0085 !define MUI_PAGE_CUSTOMFUNCTION_PRE  func_ShellExLicensePage_Init
0086 !define MUI_PAGE_HEADER_TEXT "$(ShellExLicensePageHeader)"
0087 !insertmacro MUI_PAGE_LICENSE "license.rtf"
0088 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "Krita"
0089 !define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
0090 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Krita"
0091 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "StartMenuFolder"
0092 !define MUI_STARTMENUPAGE_NODISABLE
0093 !insertmacro MUI_PAGE_STARTMENU Krita $KritaStartMenuFolder
0094 Page Custom func_BeforeInstallPage_Init
0095 !insertmacro MUI_PAGE_INSTFILES
0096 !insertmacro MUI_PAGE_FINISH
0097 
0098 # Uninstaller Pages
0099 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.func_UnintallFirstpage_Init
0100 !insertmacro MUI_UNPAGE_CONFIRM
0101 !insertmacro MUI_UNPAGE_INSTFILES
0102 
0103 # Languages
0104 !insertmacro MUI_LANGUAGE "English"
0105 !insertmacro MUI_LANGUAGE "TradChinese"
0106 !insertmacro MUI_LANGUAGE "SimpChinese"
0107 
0108 !include Sections.nsh
0109 !include LogicLib.nsh
0110 !include x64.nsh
0111 !include WinVer.nsh
0112 !include WordFunc.nsh
0113 
0114 !define KRITA_SHELLEX_DIR "$INSTDIR\shellex"
0115 
0116 !include "include\FileExists2.nsh"
0117 !include "include\IsFileInUse.nsh"
0118 !include "krita_versions_detect.nsh"
0119 !include "krita_shell_integration.nsh"
0120 
0121 Var KritaMsiProductX86
0122 Var KritaMsiProductX64
0123 Var KritaNsisVersion
0124 Var KritaNsisBitness
0125 Var KritaNsisInstallLocation
0126 
0127 Var PrevShellExInstallLocation
0128 Var PrevShellExStandalone
0129 
0130 Var UninstallShellExStandalone
0131 
0132 Section "-Remove_shellex" SEC_remove_shellex
0133         ${If} $PrevShellExInstallLocation != ""
0134         ${AndIf} $PrevShellExStandalone == 1
0135         ${AndIf} $KritaNsisVersion == ""
0136         ${AndIf} ${FileExists} "$PrevShellExInstallLocation\uninstall.exe"
0137                 push $R0
0138                 DetailPrint "$(RemovingShellEx)"
0139                 SetDetailsPrint listonly
0140                 ExecWait "$PrevShellExInstallLocation\uninstall.exe /S _?=$PrevShellExInstallLocation" $R0
0141                 ${If} $R0 != 0
0142                         ${IfNot} ${Silent}
0143                                 MessageBox MB_OK|MB_ICONSTOP "$(RemoveShellExFailed)"
0144                         ${EndIf}
0145                         SetDetailsPrint both
0146                         DetailPrint "$(RemoveShellExFailed)"
0147                         Abort
0148                 ${EndIf}
0149                 Delete "$PrevShellExInstallLocation\uninstall.exe"
0150                 RMDir /REBOOTOK "$PrevShellExInstallLocation"
0151                 SetRebootFlag false
0152                 SetDetailsPrint lastused
0153                 DetailPrint "$(RemoveShellExDone)"
0154                 pop $R0
0155         ${EndIf}
0156 SectionEnd
0157 
0158 Section "$(SectionRemoveOldVer)" SEC_remove_old_version
0159         ${If} $KritaNsisInstallLocation != ""
0160         ${AndIf} ${FileExists} "$KritaNsisInstallLocation\uninstall.exe"
0161                 push $R0
0162                 DetailPrint "$(RemovingOldVer)"
0163                 SetDetailsPrint listonly
0164                 ExecWait "$KritaNsisInstallLocation\uninstall.exe /S _?=$KritaNsisInstallLocation" $R0
0165                 ${If} $R0 != 0
0166                         ${IfNot} ${Silent}
0167                                 MessageBox MB_OK|MB_ICONSTOP "$(RemoveOldVerFailed)"
0168                         ${EndIf}
0169                         SetDetailsPrint both
0170                         DetailPrint "$(RemoveOldVerFailed)"
0171                         Abort
0172                 ${EndIf}
0173                 Delete "$KritaNsisInstallLocation\uninstall.exe"
0174                 RMDir /REBOOTOK "$KritaNsisInstallLocation"
0175                 SetRebootFlag false
0176                 SetDetailsPrint lastused
0177                 DetailPrint "$(RemoveOldVerDone)"
0178                 pop $R0
0179         ${EndIf}
0180 SectionEnd
0181 
0182 Section "-Thing"
0183         SetOutPath $INSTDIR
0184         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${KRITA_UNINSTALL_REGKEY}" \
0185                          "DisplayName" "${KRITA_PRODUCTNAME} ${KRITA_VERSION_DISPLAY}"
0186         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${KRITA_UNINSTALL_REGKEY}" \
0187                          "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
0188         WriteUninstaller $INSTDIR\uninstall.exe
0189         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${KRITA_UNINSTALL_REGKEY}" \
0190                          "DisplayVersion" "${KRITA_VERSION}"
0191         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${KRITA_UNINSTALL_REGKEY}" \
0192                          "DisplayIcon" "$\"$INSTDIR\shellex\krita.ico$\",0"
0193         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${KRITA_UNINSTALL_REGKEY}" \
0194                          "URLInfoAbout" "https://krita.org/"
0195         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${KRITA_UNINSTALL_REGKEY}" \
0196                          "InstallLocation" "$INSTDIR"
0197         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${KRITA_UNINSTALL_REGKEY}" \
0198                          "Publisher" "${KRTIA_PUBLISHER}"
0199         #WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${KRITA_UNINSTALL_REGKEY}" \
0200         #                   "EstimatedSize" 250000
0201         WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${KRITA_UNINSTALL_REGKEY}" \
0202                            "NoModify" 1
0203         WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${KRITA_UNINSTALL_REGKEY}" \
0204                            "NoRepair" 1
0205         # Registry entries for version recognition
0206         #   InstallLocation:
0207         #     Where krita is installed
0208         WriteRegStr HKLM "Software\Krita" \
0209                          "InstallLocation" "$INSTDIR"
0210         #   Version:
0211         #     Version of Krita
0212         WriteRegStr HKLM "Software\Krita" \
0213                          "Version" "${KRITA_VERSION}"
0214         #   x64:
0215         #     Set to 1 for 64-bit Krita, can be missing for 32-bit Krita
0216 !ifdef KRITA_INSTALLER_64
0217         WriteRegDWORD HKLM "Software\Krita" \
0218                            "x64" 1
0219 !else
0220         DeleteRegValue HKLM "Software\Krita" "x64"
0221 !endif
0222         #   InstallerLanguage:
0223         #     Language used by the installer (to be re-used for the uninstaller)
0224         WriteRegStr HKLM "Software\Krita" \
0225                          "InstallerLanguage" "$LANGUAGE"
0226         #   StartMenuFolder:
0227         #     Start Menu Folder
0228         #     Handled by Modern UI 2.0 MUI_PAGE_STARTMENU
0229 SectionEnd
0230 
0231 Section "${KRITA_PRODUCTNAME}" SEC_product_main
0232         # TODO: Maybe switch to explicit file list?
0233         File /r /x ffmpeg.exe /x ffmpeg_README.txt /x ffmpeg_LICENSE.txt ${KRITA_PACKAGE_ROOT}\bin
0234         File /r ${KRITA_PACKAGE_ROOT}\lib
0235         File /r ${KRITA_PACKAGE_ROOT}\share
0236         File /r ${KRITA_PACKAGE_ROOT}\python
0237 SectionEnd
0238 
0239 Section "-Main_associate"
0240         CreateDirectory ${KRITA_SHELLEX_DIR}
0241         ${Krita_RegisterFileAssociation} "$INSTDIR\bin\krita.exe"
0242 SectionEnd
0243 
0244 Section "-Main_Shortcuts"
0245         # Placing this after Krita_RegisterFileAssociation to get the icon
0246         !insertmacro MUI_STARTMENU_WRITE_BEGIN Krita
0247                 CreateDirectory "$SMPROGRAMS\$KritaStartMenuFolder"
0248                 CreateShortcut "$SMPROGRAMS\$KritaStartMenuFolder\${KRITA_PRODUCTNAME}.lnk" "$INSTDIR\bin\krita.exe" "" "$INSTDIR\shellex\krita.ico" 0
0249         !insertmacro MUI_STARTMENU_WRITE_END
0250         ${If} $CreateDesktopIcon == 1
0251                 # For the desktop icon, keep the name short and omit version info
0252                 CreateShortcut "$DESKTOP\Krita.lnk" "$INSTDIR\bin\krita.exe" "" "$INSTDIR\shellex\krita.ico" 0
0253         ${EndIf}
0254 SectionEnd
0255 
0256 Section "$(SectionShellEx)" SEC_shellex
0257         ${If} ${RunningX64}
0258                 ${Krita_RegisterComComonents} 64
0259         ${EndIf}
0260         ${Krita_RegisterComComonents} 32
0261 
0262         ${Krita_RegisterShellExtension}
0263 
0264         #   ShellExtension\InstallLocation:
0265         #     Where the shell extension is installed
0266         #     If installed by Krita installer, this must point to shellex sub-dir
0267         WriteRegStr HKLM "Software\Krita\ShellExtension" \
0268                          "InstallLocation" "$INSTDIR\shellex"
0269         #   ShellExtension\Version:
0270         #     Version of the shell extension
0271         WriteRegStr HKLM "Software\Krita\ShellExtension" \
0272                          "Version" "${KRITASHELLEX_VERSION}"
0273         #   ShellExtension\Standalone:
0274         #     0 = Installed by Krita installer
0275         #     1 = Standalone installer
0276         WriteRegDWORD HKLM "Software\Krita\ShellExtension" \
0277                            "Standalone" 0
0278         #   ShellExtension\KritaExePath:
0279         #     Path to krita.exe as specified by user or by Krita installer
0280         #     Empty if not specified
0281         WriteRegStr HKLM "Software\Krita\ShellExtension" \
0282                          "KritaExePath" "$INSTDIR\bin\krita.exe"
0283 SectionEnd
0284 
0285 !ifdef HAS_FFMPEG
0286 Section "$(SectionBundledFfmpeg)" SEC_ffmpeg
0287         File /oname=bin\ffmpeg.exe ${KRITA_PACKAGE_ROOT}\bin\ffmpeg.exe
0288         File /oname=bin\ffmpeg_LICENSE.txt ${KRITA_PACKAGE_ROOT}\bin\ffmpeg_LICENSE.txt
0289         File /oname=bin\ffmpeg_README.txt ${KRITA_PACKAGE_ROOT}\bin\ffmpeg_README.txt
0290 SectionEnd
0291 !endif
0292 
0293 Section "-Main_refreshShell"
0294         ${RefreshShell}
0295 SectionEnd
0296 
0297 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
0298         #!insertmacro MUI_DESCRIPTION_TEXT ${SEC_remove_shellex} "Remove previously installed Krita Shell Integration."
0299         !insertmacro MUI_DESCRIPTION_TEXT ${SEC_remove_old_version} "$(SectionRemoveOldVerDesc)"
0300         !insertmacro MUI_DESCRIPTION_TEXT ${SEC_product_main} "$(SectionMainDesc)"
0301         !insertmacro MUI_DESCRIPTION_TEXT ${SEC_shellex} "$(SectionShellExDesc)"
0302 !ifdef HAS_FFMPEG
0303         !insertmacro MUI_DESCRIPTION_TEXT ${SEC_ffmpeg} "$(SectionBundledFfmpegDesc)"
0304 !endif
0305 !insertmacro MUI_FUNCTION_DESCRIPTION_END
0306 
0307 Section "un.$(SectionShellEx)"
0308         ${If} $UninstallShellExStandalone == 1
0309                 push $R0
0310                 DetailPrint "$(RemovingShellEx)"
0311                 SetDetailsPrint listonly
0312                 ExecWait "$INSTDIR\shellex\uninstall.exe /S _?=$INSTDIR\shellex" $R0
0313                 ${If} $R0 != 0
0314                         ${IfNot} ${Silent}
0315                                 MessageBox MB_OK|MB_ICONSTOP "$(RemoveShellExFailed)"
0316                         ${EndIf}
0317                         SetDetailsPrint lastused
0318                         SetDetailsPrint both
0319                         DetailPrint "$(RemoveShellExFailed)"
0320                 ${EndIf}
0321                 Delete "$INSTDIR\shellex\uninstall.exe"
0322                 RMDir /REBOOTOK "$INSTDIR\shellex"
0323                 SetDetailsPrint lastused
0324                 DetailPrint "$(RemoveShellExDone)"
0325                 pop $R0
0326         ${Else}
0327                 ${Krita_UnregisterShellExtension}
0328 
0329                 ${If} ${RunningX64}
0330                         ${Krita_UnregisterComComonents} 64
0331                 ${EndIf}
0332                 ${Krita_UnregisterComComonents} 32
0333         ${EndIf}
0334 SectionEnd
0335 
0336 Section "un.Main_associate"
0337         # TODO: Conditional, use install log
0338         ${If} $UninstallShellExStandalone != 1
0339                 ${Krita_UnregisterFileAssociation}
0340         ${EndIf}
0341 SectionEnd
0342 
0343 Section "un.Main_Shortcuts"
0344         Delete "$DESKTOP\Krita.lnk"
0345         !insertmacro MUI_STARTMENU_GETFOLDER Krita $KritaStartMenuFolder
0346         Delete "$SMPROGRAMS\$KritaStartMenuFolder\${KRITA_PRODUCTNAME}.lnk"
0347         RMDir "$SMPROGRAMS\$KritaStartMenuFolder"
0348 SectionEnd
0349 
0350 Section "un.${KRITA_PRODUCTNAME}"
0351         # TODO: Maybe switch to explicit file list or some sort of install log?
0352         RMDir /r $INSTDIR\bin
0353         RMDir /r $INSTDIR\lib
0354         RMDir /r $INSTDIR\share
0355         RMDir /r $INSTDIR\python
0356 SectionEnd
0357 
0358 Section "un.Thing"
0359         RMDir /REBOOTOK $INSTDIR\shellex
0360         DeleteRegKey HKLM "Software\Krita"
0361         DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${KRITA_UNINSTALL_REGKEY}"
0362         Delete $INSTDIR\uninstall.exe
0363         RMDir /REBOOTOK $INSTDIR
0364 SectionEnd
0365 
0366 Section "un.Main_refreshShell"
0367         ${RefreshShell}
0368 SectionEnd
0369 
0370 Function .onInit
0371         SetShellVarContext all
0372         !insertmacro SetSectionFlag ${SEC_product_main} ${SF_RO}
0373         !insertmacro SetSectionFlag ${SEC_product_main} ${SF_BOLD}
0374         !insertmacro SetSectionFlag ${SEC_remove_old_version} ${SF_RO}
0375 !ifdef HAS_FFMPEG
0376         !insertmacro SetSectionFlag ${SEC_ffmpeg} ${SF_RO}
0377 !endif
0378         StrCpy $CreateDesktopIcon 1 # Create desktop icon by default
0379         ${IfNot} ${AtLeastWin7}
0380                 ${IfNot} ${Silent}
0381                         MessageBox MB_OK|MB_ICONSTOP "$(MsgRequireWin7)"
0382                 ${EndIf}
0383                 Abort
0384         ${EndIf}
0385 
0386         ${IfNot} ${Silent}
0387                 # Language selection, seems that the order is predefined.
0388                 Push "" # This value is for languages auto count
0389                 Push ${LANG_ENGLISH}
0390                 Push English
0391                 Push ${LANG_TRADCHINESE}
0392                 Push "繁體中文"
0393                 Push ${LANG_SIMPCHINESE}
0394                 Push "简体中文"
0395                 Push A # = auto count languages
0396                 LangDLL::LangDialog "$(^SetupCaption)" "$(SetupLangPrompt)"
0397                 Pop $LANGUAGE
0398                 ${If} $LANGUAGE == "cancel"
0399                         Abort
0400                 ${Endif}
0401         ${EndIf}
0402 
0403 !ifdef KRITA_INSTALLER_64
0404         ${If} ${RunningX64}
0405                 SetRegView 64
0406         ${Else}
0407                 ${IfNot} ${Silent}
0408                         MessageBox MB_OK|MB_ICONSTOP "$(Msg64bitOn32bit)"
0409                 ${EndIf}
0410                 Abort
0411         ${Endif}
0412 !else
0413         ${If} ${RunningX64}
0414                 SetRegView 64
0415                 ${IfNot} ${Silent}
0416                         MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(Msg32bitOn64bit)" \
0417                                    /SD IDYES \
0418                                    IDYES lbl_allow32on64
0419                         Abort
0420                 ${EndIf}
0421                 lbl_allow32on64:
0422         ${Endif}
0423 !endif
0424 
0425         # Detect ancient Krita versions
0426         ${DetectKritaMsi32bit} $KritaMsiProductX86
0427         ${If} ${RunningX64}
0428                 ${DetectKritaMsi64bit} $KritaMsiProductX64
0429         ${EndIf}
0430         ${If} $KritaMsiProductX86 != ""
0431         ${OrIf} $KritaMsiProductX64 != ""
0432                 ${IfNot} ${Silent}
0433                         MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON1 "$(MsgAncientVerMustBeRemoved)" \
0434                                                 /SD IDYES \
0435                                                 IDYES lbl_removeAncientVer
0436                         Abort
0437                 ${EndIf}
0438                 lbl_removeAncientVer:
0439                 ${If} $KritaMsiProductX64 != ""
0440                         push $R0
0441                         ${MsiUninstall} $KritaMsiProductX64 $R0
0442                         ${If} $R0 != 0
0443                                 ${IfNot} ${Silent}
0444                                         ${IfKritaMsi3Alpha} $KritaMsiProductX64
0445                                                 MessageBox MB_OK|MB_ICONSTOP "$(MsgKrita3alpha1RemoveFailed)"
0446                                         ${Else}
0447                                                 MessageBox MB_OK|MB_ICONSTOP "$(MsgKrita2msi64bitRemoveFailed)"
0448                                         ${EndIf}
0449                                 ${EndIf}
0450                                 Abort
0451                         ${EndIf}
0452                         pop $R0
0453                         StrCpy $KritaMsiProductX64 ""
0454                 ${EndIf}
0455                 ${If} $KritaMsiProductX86 != ""
0456                         push $R0
0457                         ${MsiUninstall} $KritaMsiProductX86 $R0
0458                         ${If} $R0 != 0
0459                                 ${IfNot} ${Silent}
0460                                         MessageBox MB_OK|MB_ICONSTOP "$(MsgKrita2msi32bitRemoveFailed)"
0461                                 ${EndIf}
0462                                 Abort
0463                         ${EndIf}
0464                         pop $R0
0465                         StrCpy $KritaMsiProductX86 ""
0466                 ${EndIf}
0467         ${EndIf}
0468 
0469         ${DetectKritaNsis} $KritaNsisVersion $KritaNsisBitness $KritaNsisInstallLocation
0470         ${If} $KritaNsisVersion != ""
0471                 push $R0
0472                 ${VersionCompare} "${KRITA_VERSION}" "$KritaNsisVersion" $R0
0473                 ${If} $R0 == 0
0474                         # Same version installed... probably
0475                         ${If} $KritaNsisBitness == ${KRITA_INSTALLER_BITNESS}
0476                                 # Very likely the same version
0477                                 ${IfNot} ${Silent}
0478                                         MessageBox MB_OK|MB_ICONINFORMATION "$(MsgKritaSameVerReinstall)"
0479                                 ${EndIf}
0480                         ${Else}
0481                                 # Very likely the same version but different arch
0482                                 ${IfNot} ${Silent}
0483 !ifdef KRITA_INSTALLER_64
0484                                         MessageBox MB_OK|MB_ICONINFORMATION "$(MsgKrita3264bitSwap)"
0485 !else
0486                                         MessageBox MB_OK|MB_ICONEXCLAMATION "$(MsgKrita3264bitSwap)"
0487 !endif
0488                                 ${EndIf}
0489                         ${EndIf}
0490                 ${ElseIf} $R0 == 1
0491                         # Upgrade
0492                         ${If} $KritaNsisBitness == ${KRITA_INSTALLER_BITNESS}
0493                                 # Silent about upgrade
0494                         ${Else}
0495                                 # Upgrade but different arch
0496                                 ${IfNot} ${Silent}
0497 !ifdef KRITA_INSTALLER_64
0498                                         MessageBox MB_OK|MB_ICONINFORMATION "$(MsgKrita3264bitSwap)"
0499 !else
0500                                         MessageBox MB_OK|MB_ICONEXCLAMATION "$(MsgKrita3264bitSwap)"
0501 !endif
0502                                 ${EndIf}
0503                         ${EndIf}
0504                 ${ElseIf} $R0 == 2
0505                         ${IfNot} ${Silent}
0506                                 MessageBox MB_OK|MB_ICONSTOP "$(MsgKritaNewerAlreadyInstalled)"
0507                         ${EndIf}
0508                         Abort
0509                 ${Else}
0510                         ${IfNot} ${Silent}
0511                                 MessageBox MB_OK|MB_ICONSTOP "Error: Unexpected state"
0512                         ${EndIf}
0513                         Abort
0514                 ${EndIf}
0515                 !insertmacro SetSectionFlag ${SEC_remove_old_version} ${SF_SELECTED}
0516                 # Detect if Krita is running...
0517                 ${If} ${IsFileinUse} "$KritaNsisInstallLocation\bin\krita.exe"
0518                         ${IfNot} ${Silent}
0519                                 MessageBox MB_OK|MB_ICONEXCLAMATION "$(MsgKritaRunning)"
0520                         ${EndIf}
0521                         SetErrorLevel 10
0522                         Abort
0523                 ${EndIf}
0524                 pop $R0
0525         ${Else}
0526                 !insertmacro ClearSectionFlag ${SEC_remove_old_version} ${SF_SELECTED}
0527                 SectionSetText ${SEC_remove_old_version} ""
0528         ${EndIf}
0529 
0530         # Detect standalone shell extension
0531         # TODO: Would it be possible to update Krita without replacing the standalone shellex?
0532         ClearErrors
0533         ReadRegStr $PrevShellExInstallLocation HKLM "Software\Krita\ShellExtension" "InstallLocation"
0534         #ReadRegStr $PrevShellExVersion HKLM "Software\Krita\ShellExtension" "Version"
0535         ReadRegDWORD $PrevShellExStandalone HKLM "Software\Krita\ShellExtension" "Standalone"
0536         #ReadRegStr $PrevShellExKritaExePath HKLM "Software\Krita\ShellExtension" "KritaExePath"
0537         ${If} ${Errors}
0538                 # TODO: Assume no previous version installed or what?
0539         ${EndIf}
0540         ${If} $PrevShellExStandalone == 1
0541                 #!insertmacro SetSectionFlag ${SEC_remove_shellex} ${SF_SELECTED}
0542         ${Else}
0543                 #!insertmacro ClearSectionFlag ${SEC_remove_shellex} ${SF_SELECTED}
0544                 #SectionSetText ${SEC_remove_shellex} ""
0545         ${EndIf}
0546 FunctionEnd
0547 
0548 Function un.onInit
0549         SetShellVarContext all
0550 !ifdef KRITA_INSTALLER_64
0551         ${If} ${RunningX64}
0552                 SetRegView 64
0553         ${Else}
0554                 Abort
0555         ${Endif}
0556 !else
0557         ${If} ${RunningX64}
0558                 SetRegView 64
0559         ${Endif}
0560 !endif
0561 
0562         # Get and use installer language:
0563         Push $0
0564         ReadRegStr $0 HKLM "Software\Krita" "InstallerLanguage"
0565         ${If} $0 != ""
0566                 StrCpy $LANGUAGE $0
0567         ${EndIf}
0568         Pop $0
0569 
0570         ReadRegDWORD $UninstallShellExStandalone HKLM "Software\Krita\ShellExtension" "Standalone"
0571         ${If} ${Silent}
0572                 # Only check here if running in silent mode. It's otherwise checked in
0573                 # un.func_UnintallFirstpage_Init in order to display a prompt in the
0574                 # correct language.
0575                 ${If} ${IsFileinUse} "$INSTDIR\bin\krita.exe"
0576                         SetErrorLevel 10
0577                         Abort
0578                 ${EndIf}
0579         ${EndIf}
0580 FunctionEnd
0581 
0582 Function un.func_UnintallFirstpage_Init
0583         ${If} ${IsFileinUse} "$INSTDIR\bin\krita.exe"
0584                 ${IfNot} ${Silent}
0585                         MessageBox MB_OK|MB_ICONEXCLAMATION "$(MsgUninstallKritaRunning)"
0586                 ${EndIf}
0587                 SetErrorLevel 10
0588                 Quit
0589         ${EndIf}
0590 FunctionEnd
0591 
0592 Function func_ShellExLicensePage_Init
0593         ${IfNot} ${SectionIsSelected} ${SEC_shellex}
0594                 # Skip ShellEx license page if not selected
0595                 Abort
0596         ${EndIf}
0597 FunctionEnd
0598 
0599 Var hwndChkDesktopIcon
0600 
0601 Function func_DesktopShortcutPage_CheckChange
0602         ${NSD_GetState} $hwndChkDesktopIcon $CreateDesktopIcon
0603         ${If} $CreateDesktopIcon == ${BST_CHECKED}
0604                 StrCpy $CreateDesktopIcon 1
0605         ${Else}
0606                 StrCpy $CreateDesktopIcon 0
0607         ${EndIf}
0608 FunctionEnd
0609 
0610 Function func_BeforeInstallPage_Init
0611         push $R0
0612 
0613         nsDialogs::Create 1018
0614         pop $R0
0615         ${If} $R0 == error
0616                 Abort
0617         ${EndIf}
0618         !insertmacro MUI_HEADER_TEXT "$(ConfirmInstallPageHeader)" "$(ConfirmInstallPageDesc)"
0619 
0620         ${NSD_CreateLabel} 0u 0u 300u 20u "$(DesktopIconPageDesc2)"
0621         pop $R0
0622 
0623         ${NSD_CreateCheckbox} 0u 20u 300u 10u "$(DesktopIconPageCheckbox)"
0624         pop $hwndChkDesktopIcon
0625         ${If} $CreateDesktopIcon == 1
0626                 ${NSD_Check} $hwndChkDesktopIcon
0627         ${Else}
0628                 ${NSD_Uncheck} $hwndChkDesktopIcon
0629         ${EndIf}
0630         ${NSD_OnClick} $hwndChkDesktopIcon func_DesktopShortcutPage_CheckChange
0631 
0632         ${NSD_CreateLabel} 0u 40u 300u 140u "$(ConfirmInstallPageDesc2)"
0633         pop $R0
0634 
0635         # TODO: Add install option summary for review?
0636 
0637         nsDialogs::Show
0638 
0639         pop $R0
0640 FunctionEnd
0641 
0642 
0643 # Strings
0644 !include "translations\English.nsh"
0645 !include "translations\TradChinese.nsh"
0646 !include "translations\SimpChinese.nsh"