examples/QtQuick/phoneutil/qml/phoneutil/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 **
00038 ****************************************************************************/
00039 
00040 
00041 //import Qt 4.7
00042 
00043 
00044 import QtQuick 1.0
00045 import com.nokia.symbian 1.0
00046 
00047 //main application window
00048 ApplicationWindow {
00049     id: window
00050 
00051     function setStateIfFound(target, name) {
00052         for (var i = 0; i < target.states.length; i++) {
00053             var curState = target.states[i];
00054             if(curState.name == name) {
00055                 target.state = name
00056                 break
00057             }
00058         }
00059     }
00060 
00061 
00062     ToolBarLayout {
00063         id: commonTools
00064 
00065         ToolButton {
00066             flat: true
00067             iconSource: "qrc:/qtg_toolbar_back.svg"
00068             onClicked: pageStack.depth <= 1 ? Qt.quit() : pageStack.pop()
00069         }
00070 
00071         ToolButton {
00072             flat: true
00073             iconSource: "qrc:/qtg_toolbar_options.svg"
00074             onClicked:
00075             {
00076                  viewMenu.open()
00077             }
00078         }
00079     }
00080 
00081     Page {
00082         id: page
00083         anchors.fill: parent
00084 
00085         tools: commonTools
00086         Component.onCompleted: {
00087             if(screen.currentOrientation == Screen.Portrait) {
00088                 setStateIfFound(page, "PortraitState")
00089             } else if(screen.currentOrientation == Screen.Landscape) {
00090                 setStateIfFound(page, "LandscapeState")
00091             }
00092         }
00093 
00094         Rectangle{
00095             id:rect
00096             anchors.fill: parent
00097             color:"grey"
00098         }
00099         PageHeading{
00100             id: heading
00101             anchors.top: parent.top
00102             width: parent.width
00103             text: qsTr("Phone Utility")
00104             fontItalic:true
00105         }
00106 
00107         Text {// Label; is centralized horizontally
00108             id: textLabel
00109             width: 80
00110             height: 20
00111             color: "#845717"
00112             text: ""
00113             anchors.horizontalCenter: parent.horizontalCenter
00114             visible: false
00115             horizontalAlignment: Text.AlignHCenter
00116             opacity: 0.9
00117             styleColor: "#e00e0e"
00118             font.pixelSize: 24
00119             }
00120 
00121         Text {//the text used to display information as per the states
00122             id: textDisplay
00123             width: page.width
00124             height: 35
00125             color: "#c62626"
00126             text: ""
00127             visible: false
00128             font.bold: true
00129             horizontalAlignment: TextInput.AlignHCenter
00130             font.pixelSize: 20
00131             anchors.horizontalCenter: page.horizontalCenter
00132             }
00133 
00134         Text { // phone model display text.
00135             id: textModel
00136             width: page.width
00137             height: 35
00138             color: "#c62626"
00139             text: ""
00140             font.pixelSize: 20
00141             anchors.horizontalCenter: page.horizontalCenter
00142             visible: false
00143             font.bold: true
00144             horizontalAlignment: TextInput.AlignHCenter
00145             }
00146 
00147         Text { // phone IMEI number display text.
00148             id: textIMEI
00149             width: page.width
00150             height: 35
00151             color: "#c62626"
00152             text: ""
00153             font.pixelSize: 20
00154             anchors.horizontalCenter: page.horizontalCenter
00155             visible: false
00156             font.bold: true
00157             horizontalAlignment: TextInput.AlignHCenter
00158             }
00159 
00160 
00161         ProgressBar {
00162             id: batteryStrength
00163             width: page.width - 100
00164             x: 60
00165             visible:  false
00166         }
00167 
00168 
00169 
00170         Menu{
00171             id: viewMenu
00172 
00173                 content:
00174                 Column{
00175                 MenuItem {
00176                     text: "BatteryInfo"
00177 
00178                     onClicked:
00179                     {
00180                         page.state = "BatteryInfo";
00181                         batteryStrength.value = systemModel.returnMessage();
00182                         viewMenu.close()
00183                     }
00184                 }
00185                 MenuItem { text: "Indicator"
00186                     onClicked:
00187                     {
00188                         page.state = "Indicator";
00189                         textDisplay.text = systemModel1.returnMessage();
00190                         viewMenu.close()
00191                     }
00192                 }
00193                 MenuItem { text: "PhoneInfo"
00194                     onClicked:
00195                     {
00196                         page.state = "PhoneInfo"
00197                         textDisplay.text = systemModel2.returnMessagePhone();
00198                         textModel.text = systemModel2.returnMessageModel();
00199                         textIMEI.text = systemModel2.returnMessageSerialNumber();
00200                         viewMenu.close()
00201                     }
00202                 }
00203 
00204             }
00205 
00206         }
00207 
00208 
00209         // set of states defined to cover the use cases.
00210         // showing BatteryInfo, Indicator and PhoneInfo.
00211             states: [
00212                 State {
00213                     name: "BatteryInfo"
00214                     PropertyChanges {
00215                         target: textLabel
00216                         text: "Battery Strength"
00217                         visible: true
00218                         y: ((window.height /2) - 50)
00219                     }
00220 
00221 
00222                     PropertyChanges {
00223                         target: textDisplay
00224                         y: ((window.height /2) + 10)
00225                         color: "#2638c6"
00226                         visible: false
00227                     }
00228                     PropertyChanges {
00229                         target: textModel
00230                         visible: false
00231                     }
00232                     PropertyChanges {
00233                         target: textIMEI
00234                         visible: false
00235                     }
00236 
00237                     PropertyChanges {
00238                         target: batteryStrength
00239                         visible:  true
00240                         //value: systemModel.returnMessage();
00241                         y: ((window.height /2) + 10)
00242                         NumberAnimation on value { from: 0; to: systemModel.returnMessage(); loops: Animation.Infinite }
00243                     }
00244                 },
00245                 State {
00246                     name: "Indicator"
00247                     PropertyChanges {
00248                         target: textLabel
00249                         text: "Indicator Status"
00250                         visible: true
00251                         y: ((window.height /2) - 50)
00252                     }
00253 
00254                     PropertyChanges {
00255                         target: textDisplay
00256                         y: ((window.height /2) + 10)
00257                         color: "#2638c6"
00258                         visible: true
00259                     }
00260                     PropertyChanges {
00261                         target: textModel
00262                         visible: false
00263                     }
00264                     PropertyChanges {
00265                         target: textIMEI
00266                         visible: false
00267                     }
00268 
00269                     PropertyChanges {
00270                         target: batteryStrength
00271                         visible: false
00272                     }
00273 
00274                 },
00275                 State {
00276                     name: "PhoneInfo"
00277                     PropertyChanges {
00278                         target: textLabel
00279                         text: "Phone Info"
00280                         visible: true
00281                         y: ((window.height /2) - 110)
00282                     }
00283 
00284                     PropertyChanges {
00285                         target: textDisplay
00286                         y: ((window.height /2) - 70)
00287                         color: "#2638c6"
00288                         visible: true
00289                     }
00290                     PropertyChanges {
00291                         target: textModel
00292                         visible: true
00293                         y: ((window.height /2) - 20)
00294                         color: "#2638c6"
00295                     }
00296                     PropertyChanges {
00297                         target: textIMEI
00298                         visible: true
00299                         y: ((window.height /2) + 30)
00300                         color: "#2638c6"
00301                     }
00302 
00303                     PropertyChanges {
00304                         target: batteryStrength
00305                         visible: false
00306                     }
00307                 }
00308             ]
00309 
00310 
00311 
00312     }
00313 
00314     Component.onCompleted: pageStack.push(page)
00315 }
00316 

Generated by  doxygen 1.6.2