examples/QtQuick/statusnotificationqmlexample/qml/statusnotificationqmlexample/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.1
00040 import com.nokia.symbian.StatusNotification 1.0
00041 import com.nokia.symbian 1.1
00042 
00043 
00048 PageStackWindow {
00049     id: window
00050         showStatusBar: true
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     //tool bar for exiting the application
00062     ToolBarLayout {
00063         id: commonTools
00064         ToolButton {
00065             flat: true
00066             iconSource: "qtg_toolbar_back.svg"
00067             onClicked: pageStack.depth <= 1 ? Qt.quit() : pageStack.pop()
00068         }
00069 
00070     }
00071 
00072     Page {
00073         id: page
00074         anchors.fill: parent
00075         tools: commonTools
00076 
00077         Component.onCompleted: {
00078             if(screen.currentOrientation == Screen.Portrait) {
00079                 setStateIfFound(page, "PortraitState")
00080             } else if(screen.currentOrientation == Screen.Landscape) {
00081                 setStateIfFound(page, "LandscapeState")
00082             }
00083         }
00084 
00085         //Image that contains the display image
00086         Image {
00087             id: imagePoster
00088             y: parent.topLeft
00089             x: parent.topLeft
00090             height: parent.height
00091             width:  parent.width
00092             source: "water.jpg"
00093             }
00094             
00095         //Printing the heading
00096         Rectangle {
00097             id: heading
00098             anchors.right: parent.right
00099             anchors.left: parent.left
00100             anchors.top: parent.top
00101             width: parent.width
00102             height: 40
00103             anchors.margins: 0
00104             gradient: Gradient {
00105                 GradientStop { position: 0.0; color: "#B5B5B5" }
00106                 GradientStop { position: 1.0; color: "#4F4F4F" }
00107             }
00108 
00109             Text {
00110                 id: txtHead
00111                 anchors.left: parent.left
00112                 text: "Status Notification"
00113                 font.italic: true
00114                 color: "white"
00115                 font.pointSize: 11
00116             }
00117         }
00118         
00119         // Status notification element
00120         StatusNotification {
00121             id: statusnotification
00122             title: ""
00123             description: ""
00124             onSelected: {
00125                 statustext.text = "Notification selected and removed"
00126             }
00127         }
00128         
00129         //text element to input title
00130         TextField {
00131             id: titleTextInput
00132             text: "Title"
00133             anchors.top: parent.top
00134             anchors.topMargin: 59
00135             anchors.left: parent.left
00136             anchors.leftMargin: 22
00137             anchors.right: parent.right
00138             anchors.rightMargin: 62
00139         }
00140         
00141         //text element to input Description
00142         TextField {
00143             id: descriptionTextInput
00144             text: "Description"
00145             anchors.top: titleTextInput.bottom
00146             anchors.topMargin: 12
00147             anchors.left: parent.left
00148             anchors.leftMargin: 22
00149             anchors.right: parent.right
00150             anchors.rightMargin: 62
00151         }
00152         
00153         //Button to show notification
00154         Button {
00155             id: addNotification1Button
00156             text: qsTrId("Show notification")
00157             width: 289
00158             height: 50
00159             anchors.left: parent.left
00160             anchors.leftMargin: 22
00161             anchors.right: parent.right
00162             anchors.rightMargin: 56
00163             anchors.top: descriptionTextInput.bottom
00164             anchors.topMargin: 41
00165             property bool iconToggle : true
00166             onClicked: {
00167                 statusnotification.title = titleTextInput.text
00168                 statusnotification.description = descriptionTextInput.text
00169                 statusnotification.icon = iconToggle ? "pics/icon1.svg" : "pics/icon1_2.svg";
00170 
00171                 if (statusnotification.visible == false)
00172                     statustext.text = iconToggle ? "Notification added (icon 1)" : "Notification added (icon 2)";
00173                 else
00174                     statustext.text = iconToggle ? "Notification modified (icon 1)" : "Notification modified (icon 2)";
00175 
00176                 statusnotification.visible = true;
00177                 iconToggle = !iconToggle;
00178 
00179             }
00180         }
00181         
00182         //Button to remove notification
00183         Button {
00184             id: removeNotification1Button
00185 
00186             text: qsTrId("Hide notification")
00187             height: 52
00188             anchors.top: addNotification1Button.bottom
00189             anchors.topMargin: 21
00190             anchors.left: parent.left
00191             anchors.leftMargin: 22
00192             anchors.right: parent.right
00193             anchors.rightMargin: 56
00194             onClicked: {
00195                 statusnotification.visible = false;
00196                 statustext.text = "Notification removed"
00197 
00198             }
00199         }
00200         
00201         //Check box to turn on and off the notification
00202         CheckBox {
00203             id: checkbox
00204             anchors.left: parent.left
00205             anchors.leftMargin: 22
00206             text: qsTrId("Autohide off")
00207             anchors.right: parent.right
00208             anchors.rightMargin: 62
00209             anchors.top: removeNotification1Button.bottom
00210             anchors.topMargin: 30
00211 
00212             onClicked: {
00213 
00214                 statusnotification.autoHide = checkbox.checked
00215                 if (checkbox.checked ) {
00216                     statustext.text = "AutoHide enable"
00217                     checkbox.text = "AutoHide on"
00218                 }
00219                 else {
00220                     statustext.text = "AutoHide disabled"
00221                     checkbox.text = "Autohide off"
00222                 }
00223             }
00224         }
00225         
00226         //Text element to display the status of notification
00227         Text {
00228             id: statustext
00229             text: ""
00230             font.family: "Nokia Sans"
00231             font.pointSize: 7
00232             color: "white"
00233             anchors.top: checkbox.bottom
00234             anchors.topMargin: 41
00235             anchors.left: parent.left
00236             anchors.leftMargin: 5
00237         }
00238     }
00239     Component.onCompleted: pageStack.push(page)
00240 }
00241 

Generated by  doxygen 1.6.2