examples/QtQuick/contentlauncherexample/qml/contentlauncherexample/main.qml

00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation
00006 **
00007 **
00008 ** $QT_BEGIN_LICENSE:BSD$
00009 ** You may use this file under the terms of the BSD license as follows:
00010 **
00011 ** "Redistribution and use in source and binary forms, with or without
00012 ** modification, are permitted provided that the following conditions are
00013 ** met:
00014 **   * Redistributions of source code must retain the above copyright
00015 **     notice, this list of conditions and the following disclaimer.
00016 **   * Redistributions in binary form must reproduce the above copyright
00017 **     notice, this list of conditions and the following disclaimer in
00018 **     the documentation and/or other materials provided with the
00019 **     distribution.
00020 **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
00021 **     the names of its contributors may be used to endorse or promote
00022 **     products derived from this software without specific prior written
00023 **     permission.
00024 **
00025 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00026 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00027 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00028 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00029 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00030 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00031 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00032 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00033 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00034 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00035 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
00036 ** $QT_END_LICENSE$
00037 ** Description:
00038 ****************************************************************************/
00039 
00040 import QtQuick 1.1
00041 import com.nokia.symbian 1.1
00042 import com.nokia.symbian.ContentLauncher 1.0
00043 
00044 // Main window of the example.
00045 PageStackWindow {
00046     id: mainWindow
00047     showStatusBar: true 
00048     ToolBarLayout {
00049         id: commonTools
00050         ToolButton {
00051             flat: true
00052             iconSource: "toolbar_back.svg"           
00053             onClicked: pageStack.depth <= 1 ? Qt.quit() : pageStack.pop()
00054         }
00055         ToolButton {
00056             flat: true
00057             iconSource: "toolbar_options.svg"
00058             onClicked: pageStack.depth <= 1 ? pageMenu.open() : pageStack.pop()
00059         }
00060     }
00061     
00062     // Help page for the example
00063     Page {
00064          id: helppage
00065          tools: commonTools
00066         
00067          // Page heading
00068          PageHeading {
00069                 id: help
00070             anchors.top: parent.top
00071             width: parent.width
00072             text: qsTr("Help")
00073          }
00074         
00075         // Help information is displayed here.  
00076         TextArea {
00077             anchors.top: help.bottom
00078             width: parent.width
00079             height: parent.height - 5
00080             anchors.topMargin: 5
00081             anchors.bottomMargin: 5
00082                 text: "This example demonstrates, how to "  +
00083                       "use content launcher API.\n\n" +
00084                       "Different types of content like http link," +
00085                       " mp3, jpeg file etc are displayed in a grid view.\n\n" +
00086                       "Select the content by clicking on it," +
00087                       " It will update the following details on the screen :\n" +
00088                       " - Is it a valid content.\n" + 
00089                       " - Name of the application, which can be" +
00090                       " used to launch the content.\n" +
00091                       "Click the launch button to open the content using" +
00092                       " the supported application."
00093             readOnly: true  
00094             wrapMode: Text.WordWrap
00095         }
00096     }
00097     
00098     // About page.
00099     Page {
00100         id: aboutpage
00101         tools: commonTools
00102         
00103         // Page heading
00104         PageHeading {
00105                 id: about
00106             anchors.top: parent.top
00107             width: parent.width
00108             text: qsTr("About")
00109         }
00110         
00111         // About text.
00112         Text {
00113             anchors.top: about.bottom
00114             width: parent.width
00115             height: parent.height
00116                 text: " Content Launcher example, Ver 1.0" + 
00117             "\n\n Copyright (c) 2011 Nokia.\n All rights reserved"  
00118             color: "white"          
00119         }
00120     }
00121     
00122     Page {
00123         id: mainpage
00124         tools: commonTools
00125         
00126         // Page heading
00127         PageHeading {
00128                 id: heading
00129             anchors.top: parent.top
00130             width: parent.width
00131             text: qsTr("Content launcher")
00132         }
00133         
00134         // Content Launcher QML plugin.
00135         ContentLauncher {
00136                         id: contentlauncher
00137                         onSourceChanged: {
00138                 infoText.text = "Content source : " + source + "\n\n" + 
00139                                                 "Is it a valid source : " + valid + 
00140                                                 "\n\n" + "Application name : " + 
00141                                                 applicationName 
00142                 launcherIcon.source = "image://mifprovider/" + applicationIcon
00143                 }
00144                 }
00145        
00146        // Content launcher information displayed here.
00147         Text {
00148                 id: infoText
00149                 text: "text"
00150                 anchors.top: heading.bottom
00151                 anchors.left: parent.left
00152                 anchors.margins: 10
00153                 width: parent.width * 0.6
00154                 wrapMode: Text.Wrap
00155                 font.pointSize: 6
00156                 color: "white"
00157                 }
00158 
00159         // Application icon is displayed here.
00160         Image {
00161                 id: launcherIcon
00162                 anchors.top: heading.bottom
00163                 anchors.left: infoText.right
00164                 anchors.right: parent.right
00165                 anchors.margins: 10
00166                 height: width
00167                 source: ""
00168                 sourceSize.width: width
00169                 sourceSize.height: height
00170         }
00171         
00172         // Launch the content using this button.
00173         Button{
00174                 id: launchButton
00175                 anchors.top: infoText.bottom
00176                 width: parent.width
00177                 height: 50
00178                 anchors.margins: 10
00179                 text: "Launch the content"
00180                 onClicked: contentlauncher.open()
00181         
00182         }
00183         
00184         // Choose the content from available options.
00185         Text {
00186                 id: selectOptions
00187                 anchors.top: launchButton.bottom
00188                 anchors.topMargin: 10
00189                 anchors.left: parent.left
00190                 font.bold: true
00191                 font.pointSize: 7
00192                 text: "Select content type from below \noptions " +
00193                       "(scroll from left to right) : "
00194                 wrapMode: Text.Wrap
00195                 color: "white"
00196         }
00197         
00198         // Grid View of different types of content.
00199         GridView {
00200                 id: itemsList
00201                 model: listModel
00202                 anchors.top: selectOptions.bottom
00203                 anchors.topMargin: 15
00204                 anchors.bottom: parent.bottom
00205             width: parent.width
00206             flow: GridView.TopToBottom
00207             cellWidth: 170
00208             cellHeight: height
00209                 ListModel {
00210                         id: listModel
00211                         
00212                         ListElement {
00213                                 contentItem: "http link"
00214                     contentUrl: "http://www.nokia.com"
00215                         }
00216                         
00217                         ListElement{
00218                                 contentItem: "mp3 file"
00219                                 contentUrl: "c:/contentlaunchertest/test.mp3"
00220                         }
00221                         
00222                         ListElement {
00223                                 contentItem: "new"
00224                                 contentUrl: "c:/contentlaunchertest/test.new"
00225                         }
00226                         
00227                         ListElement {
00228                                 contentItem: "phone number"
00229                                 contentUrl: "tel:+3584544263741"
00230                         }
00231                         
00232                         ListElement {
00233                                 contentItem: "email address"
00234                                 contentUrl: "mailto:hdd@df.com"
00235                         }
00236                         
00237                         ListElement {
00238                                 contentItem: "jpg file"
00239                                 contentUrl: "c:/contentlaunchertest/test.jpg"
00240                         }
00241                         
00242                         ListElement {
00243                                 contentItem: "mms video"
00244                                 contentUrl: "mms://online.ntdtvcast.com/Stream-Live"
00245                         }
00246                         
00247                         ListElement {
00248                                 contentItem: "rtsp video"
00249                                 contentUrl: "rtsp://video2.multicasttech.com/AFTVHorror3GPP296.sdp"
00250                         }
00251                         
00252                         ListElement {
00253                                 contentItem: "wtai call"
00254                                 contentUrl: "wtai://wp/mc/+3584544263741"
00255                         }
00256                         
00257                         ListElement {
00258                                 contentItem: "cti call"
00259                                 contentUrl: "cti:+3584544263741"
00260                         }
00261                         
00262                         ListElement {
00263                                 contentItem: "sip call"
00264                                 contentUrl: "sip:+3584544263741"
00265                         }
00266                         
00267                 }
00268                 
00269                 delegate: 
00270                         Button { 
00271                                    id: optionButton
00272                                    width: parent.cellWidth
00273                                    height: parent.cellHeight
00274                                    text: contentItem
00275                                    
00276                                    // Update the content launcher source.
00277                                    onClicked: contentlauncher.source = contentUrl
00278                         }       
00279         }
00280         
00281         // Menu for the example.
00282         Menu {
00283             id: pageMenu
00284 
00285             content:
00286             Column {
00287                 width: pageMenu.width
00288                 
00289                 MenuItem {
00290                     id: menu1
00291                     text: qsTr("Help")
00292                     onClicked:{
00293                         pageStack.push(helppage)
00294                         pageMenu.close();
00295                     }
00296                 }
00297                 
00298                 MenuItem {
00299                     id: menu2
00300                     text: qsTr("About")
00301                     onClicked:{
00302                         pageStack.push(aboutpage);
00303                         pageMenu.close();
00304                     }
00305                 }
00306 
00307                 }
00308         }
00309     }
00310      
00311     Component.onCompleted: {
00316         contentlauncher.source = listModel.get(0).contentUrl
00317         pageStack.push(mainpage)
00318     }
00319 
00320 }
00321 

Generated by  doxygen 1.6.2