diff options
author | Tim Jenssen <tim.jenssen@theqtcompany.com> | 2015-01-05 13:18:42 +0100 |
---|---|---|
committer | Leena Miettinen <riitta-leena.miettinen@theqtcompany.com> | 2015-01-08 17:01:38 +0100 |
commit | fb25c949f8e50bbd6ff6db3a4b59762d1d22c951 (patch) | |
tree | c4e1f9fc13f130d32a1eae96958308c9a1d94112 /examples | |
parent | 4b63ef5f75f729b02a0f5d9cb178052e04cd8b44 (diff) |
Doc: update the Register File Extension example
And the docs.
Change-Id: I35f5edc1ad95df29d033e4220af003bac480d6e3
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/doc/images/qtifw-examples-registerfileextension.png | bin | 0 -> 24599 bytes | |||
-rw-r--r-- | examples/doc/registerfileextension.qdoc | 70 | ||||
-rw-r--r-- | examples/registerfileextension/config/config.xml | 4 | ||||
-rw-r--r-- | examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/installscript.qs | 55 | ||||
-rw-r--r-- | examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/openfilecheckboxform.ui (renamed from examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/openfilecheckboxesform.ui) | 4 | ||||
-rw-r--r-- | examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/package.xml | 8 | ||||
-rw-r--r-- | examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/registerfilecheckboxform.ui (renamed from examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/registerfilecheckboxesform.ui) | 4 |
7 files changed, 103 insertions, 42 deletions
diff --git a/examples/doc/images/qtifw-examples-registerfileextension.png b/examples/doc/images/qtifw-examples-registerfileextension.png Binary files differnew file mode 100644 index 000000000..467c6f603 --- /dev/null +++ b/examples/doc/images/qtifw-examples-registerfileextension.png diff --git a/examples/doc/registerfileextension.qdoc b/examples/doc/registerfileextension.qdoc index 6b9c41e68..17bed5f45 100644 --- a/examples/doc/registerfileextension.qdoc +++ b/examples/doc/registerfileextension.qdoc @@ -32,9 +32,79 @@ \brief Registering a filename extension on Windows. + \image qtifw-examples-registerfileextension.png + + \e{Register File Extension} illustrates how to register a file type on + Windows. We use the \c component.addOperation() function with the + \c RegisterFileType operation to register a randomly generated file type to + be opened with Notepad. + \include installerfw-examples-configuring.qdocinc \quotefile registerfileextension/config/config.xml + \include installerfw-examples-packaging.qdocinc + + \list + \li The \c <Default> section is set to \c true to preselect the + component in the installer. + \li The \c <Script> section specifies the file name of the JavaScript + file that is loaded to perform operations. + \li The \c <UserInterfaces> section specifies the file names of the + installer pages (.ui files) to use. + \endlist + + \quotefile registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/package.xml + + \section1 Registering File Extensions + + In installscript.qs, we call the \c Component() function to connect to the + \c addRegisterFileCheckBox signal as soon as all components have been + loaded: + + \quotefromfile registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/installscript.qs + \skipto Component() + \printuntil addRegisterFileCheckBox + + We use the \c addRegisterFileCheckBox() function to display a check box for + registering the generated file type on the last page of the installer. + We hide the page when updating and uninstalling: + + \skipto addRegisterFileCheckBox + \printuntil ) + \skipto isInstaller() + \printuntil /^\}/ + + We connect to the \c openRegisteredFileIfChecked signal when end users + select \uicontrol Finish on the last installer page: + + \quotefromfile registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/installscript.qs + \skipto openRegisteredFileIfChecked + \printuntil ; + + We call the \c openRegisteredFileIfChecked function to check that the + file type was successfully registered: + + \skipto openRegisteredFileIfChecked + \printuntil /^\}/ + + We bind the \c unusualFileType variable to the \c generateUnusualFileType() + function that randomly generates a file type with the specified length: + + \quotefromfile registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/installscript.qs + \skipto generateUnusualFileType + \printuntil randomString + \printuntil } + + We use the \c RegisterFileType operation to create a file of the + specified type and to specify the application to open the file with: + + \quotefromfile registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/installscript.qs + \skipto component.createOperations() + \printuntil /^\}/ + \include installerfw-examples-generating.qdocinc + + After running the installer, double-click the installed file, + \c registeredfile.<extension>, to open it in Notepad. */ diff --git a/examples/registerfileextension/config/config.xml b/examples/registerfileextension/config/config.xml index fbc5e3b79..f7bff22f7 100644 --- a/examples/registerfileextension/config/config.xml +++ b/examples/registerfileextension/config/config.xml @@ -4,6 +4,6 @@ <Version>1.0.0</Version> <Title>Register File Extension Example</Title> <Publisher>Qt-Project</Publisher> - <StartMenuDir>Register File Extension Example</StartMenuDir> - <TargetDir>@HomeDir@/IFWRegisterFileExtensionExample</TargetDir> + <StartMenuDir>Qt IFW Examples</StartMenuDir> + <TargetDir>@HomeDir@/IfwExample</TargetDir> </Installer> diff --git a/examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/installscript.qs b/examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/installscript.qs index cd45bd548..c4724e509 100644 --- a/examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/installscript.qs +++ b/examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/installscript.qs @@ -34,10 +34,10 @@ function Component() { - component.loaded.connect(this, my_componentLoaded); - installer.finishButtonClicked.connect(this, my_installationFinished); - installer.installationFinished.connect(this, my_installationFinishedPageIsShown); - component.unusalFileType = generateUnusualFileType(5) + component.loaded.connect(this, addRegisterFileCheckBox); + installer.installationFinished.connect(this, addOpenFileCheckBoxToFinishPage); + installer.finishButtonClicked.connect(this, openRegisteredFileIfChecked); + component.unusualFileType = generateUnusualFileType(5) } generateUnusualFileType = function(length) @@ -51,65 +51,56 @@ generateUnusualFileType = function(length) } // called as soon as the component was loaded -my_componentLoaded = function() +addRegisterFileCheckBox = function() { - // don't show when updating / de-installing + // don't show when updating or uninstalling if (installer.isInstaller()) { - installer.addWizardPageItem(component, "RegisterFileCheckBoxesForm", QInstaller.TargetDirectory); - component.userInterface("RegisterFileCheckBoxesForm").RegisterFileCheckBox.text = - component.userInterface("RegisterFileCheckBoxesForm").RegisterFileCheckBox.text + component.unusalFileType; + installer.addWizardPageItem(component, "RegisterFileCheckBoxForm", QInstaller.TargetDirectory); + component.userInterface("RegisterFileCheckBoxForm").RegisterFileCheckBox.text = + component.userInterface("RegisterFileCheckBoxForm").RegisterFileCheckBox.text + component.unusualFileType; } } -// called after everything is set up, but before any fie is written -Component.prototype.beginInstallation = function() -{ - // call default implementation which is necessary for most hooks - // in beginInstallation case it makes nothing - component.beginInstallation(); - - component.registeredFile = installer.value("TargetDir") + "/registeredfile." + component.unusalFileType; -} - // here we are creating the operation chain which will be processed at the real installation part later Component.prototype.createOperations = function() { // call default implementation to actually install the registeredfile component.createOperations(); - var iconId = 0; - var notepadPath = installer.environmentVariable("SystemRoot") + "\\notepad.exe"; - var isRegisterFileChecked = component.userInterface("RegisterFileCheckBoxesForm").RegisterFileCheckBox.checked; + var isRegisterFileChecked = component.userInterface("RegisterFileCheckBoxForm").RegisterFileCheckBox.checked; if (installer.value("os") === "win") { + var iconId = 0; + var notepadPath = installer.environmentVariable("SystemRoot") + "\\notepad.exe"; component.addOperation("RegisterFileType", - component.unusalFileType, + component.unusualFileType, notepadPath + " '%1'", "QInstaller Framework example file type", "text/plain", notepadPath + "," + iconId, - "ProgId=QtProject.QtInstallerFramework." + component.unusalFileType); + "ProgId=QtProject.QtInstallerFramework." + component.unusualFileType); } - component.addOperation("Move", "@TargetDir@/registeredfile", component.registeredFile); + component.fileWithRegisteredType = installer.value("TargetDir") + "/registeredfile." + component.unusualFileType + component.addOperation("Move", "@TargetDir@/registeredfile", component.fileWithRegisteredType); } -my_installationFinished = function() +openRegisteredFileIfChecked = function() { if (!component.installed) return; if (installer.value("os") == "win" && installer.isInstaller() && installer.status == QInstaller.Success) { - var isOpenRegisteredFileChecked = component.userInterface("OpenFileCheckBoxesForm").OpenRegisteredFileCheckBox.checked; + var isOpenRegisteredFileChecked = component.userInterface("OpenFileCheckBoxForm").OpenRegisteredFileCheckBox.checked; if (isOpenRegisteredFileChecked) { - QDesktopServices.openUrl("file:///" + component.registeredFile); + QDesktopServices.openUrl("file:///" + component.fileWithRegisteredType); } } } -my_installationFinishedPageIsShown = function() +addOpenFileCheckBoxToFinishPage = function() { if (installer.isInstaller() && installer.status == QInstaller.Success) { - installer.addWizardPageItem(component, "OpenFileCheckBoxesForm", QInstaller.InstallationFinished); - component.userInterface("OpenFileCheckBoxesForm").OpenRegisteredFileCheckBox.text = - component.userInterface("OpenFileCheckBoxesForm").OpenRegisteredFileCheckBox.text + component.unusalFileType; + installer.addWizardPageItem(component, "OpenFileCheckBoxForm", QInstaller.InstallationFinished); + component.userInterface("OpenFileCheckBoxForm").OpenRegisteredFileCheckBox.text = + component.userInterface("OpenFileCheckBoxForm").OpenRegisteredFileCheckBox.text + component.unusualFileType; } } diff --git a/examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/openfilecheckboxesform.ui b/examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/openfilecheckboxform.ui index b9bcd24da..84b097685 100644 --- a/examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/openfilecheckboxesform.ui +++ b/examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/openfilecheckboxform.ui @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <class>OpenFileCheckBoxesForm</class> - <widget class="QWidget" name="OpenFileCheckBoxesForm"> + <class>OpenFileCheckBoxForm</class> + <widget class="QWidget" name="OpenFileCheckBoxForm"> <property name="geometry"> <rect> <x>0</x> diff --git a/examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/package.xml b/examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/package.xml index daa47c10c..4ac1ea897 100644 --- a/examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/package.xml +++ b/examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/package.xml @@ -1,13 +1,13 @@ <?xml version="1.0" encoding="UTF-8"?> <Package> - <DisplayName>register a file extension</DisplayName> - <Description>Register a random generated file extension to open with notepad.exe</Description> + <DisplayName>Register a file extension</DisplayName> + <Description>Register a randomly generated file extension to open with notepad.exe</Description> <Version>1.0.0-1</Version> <ReleaseDate>2013-01-01</ReleaseDate> <Default>true</Default> <Script>installscript.qs</Script> <UserInterfaces> - <UserInterface>registerfilecheckboxesform.ui</UserInterface> - <UserInterface>openfilecheckboxesform.ui</UserInterface> + <UserInterface>registerfilecheckboxform.ui</UserInterface> + <UserInterface>openfilecheckboxform.ui</UserInterface> </UserInterfaces> </Package> diff --git a/examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/registerfilecheckboxesform.ui b/examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/registerfilecheckboxform.ui index ccddacda2..4db8f0daf 100644 --- a/examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/registerfilecheckboxesform.ui +++ b/examples/registerfileextension/packages/org.qtproject.ifw.example.registerfileextension/meta/registerfilecheckboxform.ui @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <class>RegisterFileCheckBoxesForm</class> - <widget class="QWidget" name="RegisterFileCheckBoxesForm"> + <class>RegisterFileCheckBoxForm</class> + <widget class="QWidget" name="RegisterFileCheckBoxForm"> <property name="geometry"> <rect> <x>0</x> |