examples/QtQuick/telephonyexampleqml/qml/telephonyexampleqml/VKeyboard.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 import Qt 4.7
00041 import com.nokia.symbian 1.1
00042 
00043 /*
00044  * Keypad for dialing a number. When a number is pressed it is displayed on the screen.
00045  */
00046 Rectangle {
00047     id: vkeyboard        
00048     width: parent.width;    
00049     height: parent.height/3     
00050     radius: 10
00051     smooth: true
00052     color: "black"
00053     opacity: 1
00054     visible: true    
00055     property string numberText : ""
00056     signal send( string phonenumber)    
00057     
00058     // The number is displayed as it is except "+" that is added in the
00059     // beggining nad "c" erases the last number pressed 
00060     function keyPressed(operation) {
00061         if ( operation == "+" ) {
00062             numberText = "+" + numberText            
00063         }
00064         else if ( operation == "C" ) {
00065             numberText = numberText.toString().slice(0, -1)
00066         }
00067         else {
00068             numberText = numberText + operation.toString()            
00069         }        
00070         vkeyboard.send(numberText)
00071     }
00072 
00073         
00074         // The grid displays the buttons for the characters of the keypad.       
00075     Grid {
00076         id: grid; rows: 4; columns: 3; spacing: 6
00077         property real w: (vkeyboard.width / columns) - ((spacing * (columns - 1)) / columns)
00078         property real h: (vkeyboard.height / rows) - ((spacing * (rows - 1)) / rows)
00079         Button { objectName: "vkb1"; width: grid.w; height: grid.h; text: "1"; onClicked: keyPressed(text); }
00080         Button { objectName: "vkb2"; width: grid.w; height: grid.h; text: "2"; onClicked: keyPressed(text); }
00081         Button { objectName: "vkb3"; width: grid.w; height: grid.h; text: "3"; onClicked: keyPressed(text); }
00082         Button { objectName: "vkb4"; width: grid.w; height: grid.h; text: "4"; onClicked: keyPressed(text); }
00083         Button { objectName: "vkb5"; width: grid.w; height: grid.h; text: "5"; onClicked: keyPressed(text); }
00084         Button { objectName: "vkb6"; width: grid.w; height: grid.h; text: "6"; onClicked: keyPressed(text); }
00085         Button { objectName: "vkb7"; width: grid.w; height: grid.h; text: "7"; onClicked: keyPressed(text); }
00086         Button { objectName: "vkb8"; width: grid.w; height: grid.h; text: "8"; onClicked: keyPressed(text); }
00087         Button { objectName: "vkb9"; width: grid.w; height: grid.h; text: "9"; onClicked: keyPressed(text); }        
00088         Button { objectName: "vkb0"; width: grid.w; height: grid.h; text: "+"; onClicked: keyPressed(text); }
00089         Button { objectName: "vkb0"; width: grid.w; height: grid.h; text: "0"; onClicked: keyPressed(text); }
00090         Button { objectName: "vkbC"; width: grid.w; height: grid.h; text: "C"; onClicked: keyPressed(text); }
00091     }
00092 }

Generated by  doxygen 1.6.2