| 1 |
/**************************************************************************** |
| 2 |
** |
| 3 |
** Copyright (C) 2017 The Qt Company Ltd and/or its subsidiary(-ies). |
| 4 |
** Contact: http://www.qt-project.org/legal |
| 5 |
** |
| 6 |
** This file is part of the examples of the Qt Mobility Components. |
| 7 |
** |
| 8 |
** $QT_BEGIN_LICENSE:BSD$ |
| 9 |
** Commercial License Usage |
| 10 |
** Licensees holding valid commercial Qt licenses may use this file in |
| 11 |
** accordance with the commercial license agreement provided with the |
| 12 |
** Software or, alternatively, in accordance with the terms contained in |
| 13 |
** a written agreement between you and The Qt Company. For licensing terms |
| 14 |
** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 |
** information use the contact form at https://www.qt.io/contact-us. |
| 16 |
** |
| 17 |
** BSD License Usage |
| 18 |
** Alternatively, you may use this file under the terms of the BSD license |
| 19 |
** as follows: |
| 20 |
** |
| 21 |
** "Redistribution and use in source and binary forms, with or without |
| 22 |
** modification, are permitted provided that the following conditions are |
| 23 |
** met: |
| 24 |
** * Redistributions of source code must retain the above copyright |
| 25 |
** notice, this list of conditions and the following disclaimer. |
| 26 |
** * Redistributions in binary form must reproduce the above copyright |
| 27 |
** notice, this list of conditions and the following disclaimer in |
| 28 |
** the documentation and/or other materials provided with the |
| 29 |
** distribution. |
| 30 |
** * Neither the name of The Qt Company Ltd nor the names of its |
| 31 |
** contributors may be used to endorse or promote products derived |
| 32 |
** from this software without specific prior written permission. |
| 33 |
** |
| 34 |
** |
| 35 |
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 36 |
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 37 |
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 38 |
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 39 |
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 40 |
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 41 |
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 42 |
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 43 |
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 44 |
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 45 |
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." |
| 46 |
** |
| 47 |
** $QT_END_LICENSE$ |
| 48 |
** |
| 49 |
****************************************************************************/ |
| 50 |
|
| 51 |
import QtQuick 2.0 |
| 52 |
|
| 53 |
//Layout of the DialScreen control |
| 54 |
//------------------------------------ |
| 55 |
//|DialScreen | |
| 56 |
//| --------------------- ____ numberPad |
| 57 |
//| |dialNumber | / | |
| 58 |
//| ---------------------/ _| hangUpButton |
| 59 |
//| --------------------/- ------- / | |
| 60 |
//| | | | | | |/ | |
| 61 |
//| | 1 | 2 | 3 | | | | |
| 62 |
//| | | | | | | | |
| 63 |
//| ---------------------- | | | |
| 64 |
//| | | | | | | | |
| 65 |
//| | 4 | 5 | 6 | | | | |
| 66 |
//| | | | | ------- | |
| 67 |
//| ---------------------- _| callButton |
| 68 |
//| | | | | ------- / | |
| 69 |
//| | 7 | 8 | 9 | | |/ | |
| 70 |
//| | | | | | | | |
| 71 |
//| ---------------------- | | | |
| 72 |
//| | | | | | | | |
| 73 |
//| | * | 0 | # | | | | |
| 74 |
//| | | | | | | | |
| 75 |
//| ---------------------- ------- | |
| 76 |
//| | |
| 77 |
//------------------------------------ |
| 78 |
|
| 79 |
//! [0] |
| 80 |
Item { |
| 81 |
width: childrenRect.width |
| 82 |
height: childrenRect.height |
| 83 |
property string dialString |
| 84 |
signal dial(string numberToDial) |
| 85 |
signal hangup |
| 86 |
//! [0] |
| 87 |
|
| 88 |
Rectangle { |
| 89 |
id: dialNumber |
| 90 |
height: dialText.height + 5 |
| 91 |
width: numberPad.width |
| 92 |
anchors.top: parent.top |
| 93 |
anchors.left: parent.left |
| 94 |
color: "white" |
| 95 |
radius: 5 |
| 96 |
border.width: 3 |
| 97 |
border.color: "black" |
| 98 |
|
| 99 |
Text { |
| 100 |
id: dialText |
| 101 |
text: dialString |
| 102 |
anchors.centerIn: parent |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
Grid { |
| 107 |
id: numberPad |
| 108 |
width: childrenRect.width |
| 109 |
height: childrenRect.height |
| 110 |
anchors.top: dialNumber.bottom |
| 111 |
anchors.left: parent.left |
| 112 |
anchors.topMargin: 5 |
| 113 |
columns: 3 |
| 114 |
spacing: 5 |
| 115 |
|
| 116 |
DialButton { buttonText: "1"; onClicked: { dialString += "1";} } |
| 117 |
DialButton { buttonText: "2"; onClicked: { dialString += "2";} } |
| 118 |
DialButton { buttonText: "3"; onClicked: { dialString += "3";} } |
| 119 |
DialButton { buttonText: "4"; onClicked: { dialString += "4";} } |
| 120 |
DialButton { buttonText: "5"; onClicked: { dialString += "5";} } |
| 121 |
DialButton { buttonText: "6"; onClicked: { dialString += "6";} } |
| 122 |
DialButton { buttonText: "7"; onClicked: { dialString += "7";} } |
| 123 |
DialButton { buttonText: "8"; onClicked: { dialString += "8";} } |
| 124 |
DialButton { buttonText: "9"; onClicked: { dialString += "9";} } |
| 125 |
DialButton { buttonText: "*"; onClicked: { dialString += "*";} } |
| 126 |
DialButton { buttonText: "0"; onClicked: { dialString += "0";} } |
| 127 |
DialButton { buttonText: "#"; onClicked: { dialString += "#";} } |
| 128 |
} |
| 129 |
|
| 130 |
//! [1] |
| 131 |
DialButton { |
| 132 |
id: hangUpButton |
| 133 |
height: { (numberPad.height / 2) - 2 } |
| 134 |
width: 50 |
| 135 |
anchors.top: numberPad.top |
| 136 |
anchors.left: numberPad.right |
| 137 |
anchors.leftMargin: 5 |
| 138 |
color: "crimson" |
| 139 |
onClicked: { |
| 140 |
dialString = "" |
| 141 |
hangup() |
| 142 |
} |
| 143 |
//! [1] |
| 144 |
Image { |
| 145 |
anchors.centerIn: parent |
| 146 |
source: "hangup.png" |
| 147 |
transformOrigin: "Center" |
| 148 |
} |
| 149 |
} |
| 150 |
|
| 151 |
//! [2] |
| 152 |
DialButton { |
| 153 |
id: callButton |
| 154 |
width: 50 |
| 155 |
height: {(numberPad.height/2) -2} |
| 156 |
anchors.top: hangUpButton.bottom |
| 157 |
anchors.left: numberPad.right |
| 158 |
anchors.leftMargin: 5 |
| 159 |
anchors.topMargin: 4 |
| 160 |
color: "mediumseagreen" |
| 161 |
onClicked: { |
| 162 |
if (dialString != "") { |
| 163 |
dial(dialString) |
| 164 |
dialString = "" |
| 165 |
} |
| 166 |
} |
| 167 |
//! [2] |
| 168 |
|
| 169 |
Image { |
| 170 |
anchors.centerIn: parent |
| 171 |
source: "call.png" |
| 172 |
transformOrigin: "Center" |
| 173 |
} |
| 174 |
} |
| 175 |
} |