examples/QtQuick/LightExample/qml/LightExample/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 import QtQuick 1.0
00040 import com.nokia.symbian 1.0
00041 
00042 
00043 ApplicationWindow {
00044     id: window
00045 
00046     function setStateIfFound(target, name) {
00047         for (var i = 0; i < target.states.length; i++) {
00048             var curState = target.states[i];
00049             if(curState.name == name) {
00050                 target.state = name
00051                 break
00052             }
00053         }
00054     }
00055 
00056 
00057 
00058 
00059 
00060 
00061 
00062     ToolBarLayout {
00063         id: commonTools
00064         ToolButton {
00065             flat: true
00066             iconSource: "qrc:/qtg_toolbar_back.svg"
00067             onClicked: pageStack.depth <= 1 ? Qt.quit() : pageStack.pop()
00068         }
00069         ToolButton {
00070             flat: true
00071             iconSource: "qrc:/qtg_toolbar_options.svg"
00072             onClicked:
00073             {
00074                 viewMenu.open()
00075             }
00076         }
00077     }
00078 
00079     Page {
00080         id: page
00081         anchors.fill: parent
00082         tools: commonTools
00083 
00084         Component.onCompleted: {
00085             if(screen.currentOrientation == Screen.Portrait) {
00086                 setStateIfFound(page, "PortraitState")
00087             } else if(screen.currentOrientation == Screen.Landscape) {
00088                 setStateIfFound(page, "LandscapeState")
00089             }
00090         }
00091 
00092         //Image that contains the display image on the mainRect.
00093         Image {
00094             id: imagePoster
00095             y:window.TopLeft
00096             x:window.TopLeft
00097             height: window.height
00098             width:  window.width
00099             source: "qrc:/rectbackground.jpg"
00100 
00101             }
00102 
00103         // Text to display the application name.
00104         PageHeading{
00105             id: heading
00106             anchors.top: parent.top
00107             width: parent.width
00108             text: "Light API Example"
00109             fontItalic: true
00110         }
00111 
00112         //Text to display the status of the primary display.
00113         Text {
00114                 id:displayStatus
00115                 text: "Display Status = On"
00116                 font.family: "Helvetica"
00117                 font.pointSize: 10
00118                 color: "grey"
00119                 font.italic :true
00120                 width: 100
00121                 height: 40
00122                 y:(window.height/2- 100)
00123                 anchors.rightMargin: parent.right
00124                }
00125         // Text to display the button pressed.
00126         Text {
00127                 id:menuPress
00128                 text: ""
00129                 font.family: "Helvetica"
00130                 font.pointSize: 10
00131                 color: "grey"
00132                 font.italic :true
00133                 width: 100
00134                 height: 40
00135                 y:(window.height/2)
00136                 anchors.rightMargin: parent.right
00137                }
00138 
00139             Menu{
00140                 id: viewMenu
00141 
00142                     content:
00143                     Column{
00144                     MenuItem {
00145                         text: "Maximum"
00146 
00147                         onClicked:
00148                         {
00149                             menuPress.text = "Display at Max intensity \nfor 8 Sec"
00150                             lightWrapper.lightOn();
00151                             lightWrapper.lightMax();
00152                             viewMenu.close()
00153                         }
00154                     }
00155                     MenuItem { text: "Minimum"
00156                         onClicked:
00157                         {
00158                             menuPress.text = "Display at Min intensity \nfor 8 Sec"
00159                             lightWrapper.lightOn();
00160                             lightWrapper.lightMin();
00161                             viewMenu.close()
00162                         }
00163                     }
00164                     MenuItem { text: "Blink"
00165                         onClicked:
00166                         {
00167                             menuPress.text = "Display blinking for 8 Sec"
00168                             lightWrapper.lightOn();
00169                             lightWrapper.lightBlink();
00170                             viewMenu.close()
00171                         }
00172                     }
00173                     MenuItem { text: "Off"
00174                         onClicked:
00175                         {
00176                             menuPress.text = "Display off for 8 Sec"
00177                             lightWrapper.lightOn();
00178                             lightWrapper.lightOff();
00179                             viewMenu.close()
00180                         }
00181                     }
00182                 }
00183 
00184             }
00185 
00186     }
00187     Component.onCompleted: pageStack.push(page)
00188 
00189     //Connections to attach the QT signal to QML slot.
00190     Connections {
00191            target: lightWrapper
00192            onPrintStatus: {
00193                displayStatus.text = "Display Status = "+status
00194        }
00195     }
00196 
00197 
00198 }

Generated by  doxygen 1.6.2