1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the test suite of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
45 height: 360; width: 640
47 Connections { target: pointvalue; onReset: { textinputelement.font.pointSize = 12 } }
53 MouseArea { anchors.fill: parent; onClicked: textinputelement.focus = false }
56 height: 50; width: parent.width - 20
57 anchors.centerIn: parent
59 property int validatorval
60 validatorval: { validvalue.model.get(validvalue.currentIndex).value }
61 text: { textvalue.model.get(textvalue.currentIndex).value }
62 autoScroll: { autoscrollvalue.model.get(autoscrollvalue.currentIndex).value }
63 color: { colorvalue.model.get(colorvalue.currentIndex).value }
64 font.bold: { boldvalue.model.get(boldvalue.currentIndex).value }
65 font.italic: { italicsvalue.model.get(italicsvalue.currentIndex).value }
66 font.capitalization: { capsvalue.model.get(capsvalue.currentIndex).value }
67 font.family: { familyvalue.model.get(familyvalue.currentIndex).value }
68 font.strikeout: strikeoutvalue.currentIndex
69 font.underline: underlinevalue.currentIndex
70 font.letterSpacing: { lspacingvalue.model.get(lspacingvalue.currentIndex).value }
71 font.wordSpacing: { wspacingvalue.model.get(wspacingvalue.currentIndex).value }
72 font.weight: { weightvalue.model.get(weightvalue.currentIndex).value }
73 font.pointSize: { pointvalue.model.get(pointvalue.currentIndex).value }
74 font.pixelSize: { pixelvalue.model.get(pixelvalue.currentIndex).value }
75 horizontalAlignment: { halignvalue.model.get(halignvalue.currentIndex).value }
76 verticalAlignment: { valignvalue.model.get(valignvalue.currentIndex).value }
77 wrapMode: { wrapvalue.model.get(wrapvalue.currentIndex).value }
78 smooth: { smoothvalue.model.get(smoothvalue.currentIndex).value }
79 selectByMouse: { mousevalue.model.get(mousevalue.currentIndex).value }
80 echoMode: { echovalue.model.get(echovalue.currentIndex).value }
81 cursorVisible: { cursorvisiblevalue.model.get(cursorvisiblevalue.currentIndex).value }
82 cursorDelegate: cursordelegate
83 onValidatorvalChanged: {
84 //console.log(validatorval);
85 if (validatorval == 0)
87 else if (validatorval == 1)
89 else if (validatorval == 2)
94 IntValidator { id: intval; top: 30; bottom: 12 }
95 DoubleValidator { id: dubval; top: 30; bottom: 12 }
96 RegExpValidator { id: regval; regExp: /Qt/ }
97 RegExpValidator { id: noval; regExp: /.*/ }
98 Rectangle{ color: "transparent"; border.color: "green"; anchors.fill: parent }
104 width: parent.width - 20
105 anchors.left: textinputelement.left
106 anchors.bottom: buttonrow2.top; anchors.bottomMargin: 2
107 Button { buttontext: "Select Word"; onClicked: { textinputelement.selectWord() } }
108 Button { buttontext: "Select All"; onClicked: { textinputelement.selectAll() } }
109 Button { buttontext: "Select to 5"; onClicked: { textinputelement.moveCursorSelection(5) } }
110 Button { buttontext: "Select None"; onClicked: { textinputelement.deselect() } }
115 width: parent.width - 20
116 anchors.left: textinputelement.left
117 anchors.bottom: buttonrow3.top; anchors.bottomMargin: 2
118 Button { buttontext: "Cut"; onClicked: { textinputelement.cut() } }
119 Button { buttontext: "Copy"; onClicked: { textinputelement.copy() } }
120 Button { buttontext: "Paste"; onClicked: { textinputelement.paste() } }
125 width: parent.width - 20
126 anchors.left: textinputelement.left
127 anchors.bottom: textinputelement.top; anchors.bottomMargin: 2
128 Button { buttontext: "Position 12px"; onClicked: { textinputelement.cursorPosition = textinputelement.positionAt(12) } }
129 Button { buttontext: "Select 3-6"; onClicked: { textinputelement.select(3,6) } }
130 Button { buttontext: "Position End"; onClicked: { textinputelement.cursorPosition = textinputelement.text.length } }
135 id: cursordelegaterect
136 height: 48; width: 3; color: "red"; visible: parent.cursorVisible
137 SequentialAnimation on opacity { running: true; loops: Animation.Infinite
138 NumberAnimation { to: 0; duration: 1000 }
139 NumberAnimation { to: 1; duration: 1000 }
146 anchors { left: parent.left; leftMargin: 10; bottom: parent.bottom }
147 height: 150; color: "black"; width: 150
149 "\nPointSize: "+textinputelement.font.pointSize+
150 "\nPixelSize: "+textinputelement.font.pixelSize+
151 "\nAcceptable Input: "+textinputelement.acceptableInput+
152 "\nCan Paste: "+textinputelement.canPaste+
153 "\nCursor Position: "+textinputelement.cursorPosition+
154 "\nRight to Left: "+textinputelement.isRightToLeft(0,textinputelement.text.length);
160 width: 200; height: parent.height
161 anchors.right: parent.right
162 Rectangle { anchors.fill: parent; color: "transparent"; border.color: "black" }
163 ListView { id: controls; model: controlsmodel; anchors.fill: parent; clip: true; cacheBuffer: 500 }
170 ListModel { id: textmodel }
171 Component.onCompleted: {
172 textmodel.append({ "name": "Basic", "value": "The TextInput item displays an editable line of text."});
173 textmodel.append({ "name": "Short", "value": "Hello World"});
174 textmodel.append({ "name": "Long",
175 "value": "Qt Quick is a collection of technologies that are designed to help developers create the kind of intuitive, "+
176 "modern, fluid user interfaces that are increasingly used on mobile phones, media players, set-top boxes and other "+
177 "portable devices. "+
178 "Qt Quick consists of a rich set of user interface elements, a declarative language for describing user interfaces "+
179 "and a language runtime. "+
180 "A collection of C++ APIs is used to integrate these high level features with classic Qt applications."});
185 controlname: "AutoScroll"
186 model: ListModel { ListElement { name: "On"; value: true } ListElement { name: "Off"; value: false } }
191 model: ListModel { ListElement { name: "Red"; value: "red" }
192 ListElement { name: "Green"; value: "green" } ListElement { name: "Blue"; value: "blue" } }
197 model: ListModel { ListElement { name: "None"; value: Text.ElideNone } ListElement { name: "Left"; value: Text.ElideLeft }
198 ListElement { name: "Middle"; value: Text.ElideMiddle } ListElement { name: "Right"; value: Text.ElideRight } }
203 model: ListModel { ListElement { name: "Off"; value: false } ListElement { name: "On"; value: true } }
207 controlname: "Italic"
208 model: ListModel { ListElement { name: "Off"; value: false } ListElement { name: "On"; value: true } }
212 controlname: "Cap10n"
214 ListElement { name: "Mixed"; value: Font.MixedCase } ListElement { name: "Upper"; value: Font.AllUppercase }
215 ListElement { name: "Lower"; value: Font.AllLowercase } ListElement { name: "SmallCaps"; value: Font.SmallCaps }
216 ListElement { name: "Capitals"; value: Font.Capitalize }
220 id: cursorvisiblevalue
221 controlname: "Cursor"
222 model: ListModel { ListElement { name: "On"; value: true } ListElement { name: "Off"; value: false } }
227 model: ListModel { ListElement { name: "Normal"; value: TextInput.Normal } ListElement { name: "Password"; value: TextInput.Password }
228 ListElement { name: "None"; value: TextInput.NoEcho } ListElement { name: "OnEdit"; value: TextInput.PasswordEchoOnEdit } } }
232 property variant fontfamilies
233 function setModel() {
234 familiesmodel.clear();
235 for (var i = 0; i < fontfamilies.length; ++i) {
236 familiesmodel.append({ "name": fontfamilies[i], "value": fontfamilies[i] });
238 familyvalue.currentIndex = 0;
241 ListModel { id: familiesmodel }
242 Component.onCompleted: { fontfamilies = Qt.fontFamilies(); setModel(); }
246 controlname: "LSpacing"
247 model: ListModel { ListElement { name: "0"; value: 0 } ListElement { name: "1"; value: 1 } ListElement { name: "2.5"; value: 2.5 } } }
250 controlname: "WSpacing"
251 model: ListModel { ListElement { name: "-1"; value: -1 } ListElement { name: "8"; value: 8 } ListElement { name: "20"; value: 20 } } }
255 model: ListModel { ListElement { name: "-1"; value: -1 } ListElement { name: "8"; value: 8 } ListElement { name: "20"; value: 20 } } }
259 model: ListModel { ListElement { name: "-1"; value: -1 } ListElement { name: "8"; value: 8 } ListElement { name: "20"; value: 20 } } }
262 controlname: "Strike"
263 model: ListModel { ListElement { name: "Off"; value: false } ListElement { name: "On"; value: true } } }
266 controlname: "U_line"
267 model: ListModel { ListElement { name: "Off"; value: false } ListElement { name: "On"; value: true } } }
270 controlname: "Weight"
271 model: ListModel { ListElement { name: "Light"; value: Font.Light } ListElement { name: "Normal"; value: Font.Normal }
272 ListElement { name: "DemiBold"; value: Font.DemiBold } ListElement { name: "Bold"; value: Font.Bold }
273 ListElement { name: "Black"; value: Font.Black } }
274 Component.onCompleted: { currentIndex = 1 } // set to default
278 controlname: "HAlign"
279 model: ListModel { ListElement { name: "Left"; value: Text.AlignLeft } ListElement { name: "Right"; value: Text.AlignRight }
280 ListElement { name: "Center"; value: Text.AlignHCenter } ListElement { name: "Justify"; value: Text.AlignJustify } } }
283 controlname: "VAlign"
284 model: ListModel { ListElement { name: "Top"; value: Text.AlignTop } ListElement { name: "Bottom"; value: Text.AlignBottom }
285 ListElement { name: "Center"; value: Text.AlignVCenter } } }
289 model: ListModel { ListElement { name: "Unset"; value: 1 } ListElement { name: "2"; value: 2 } ListElement { name: "10"; value: 10 }} }
292 controlname: "LHeight"
293 model: ListModel { ListElement { name: "1"; value: 1.0 } ListElement { name: "2"; value: 2.0 } ListElement { name: "30"; value: 30.0 }} }
295 id: lineheightmodevalue
296 controlname: "LHMode"
298 ListElement { name: "Multiply"; value: Text.ProportionalHeight } ListElement { name: "Fixed"; value: Text.FixedHeight } } }
302 model: ListModel { ListElement { name: "Off"; value: false } ListElement { name: "On"; value: true } } }
305 controlname: "Smooth"
306 model: ListModel { ListElement { name: "Off"; value: false } ListElement { name: "On"; value: true } } }
310 model: ListModel { ListElement { name: "Normal"; value: Text.Normal } ListElement { name: "Outline"; value: Text.Outline }
311 ListElement { name: "Raised"; value: Text.Raised } ListElement { name: "Sunken"; value: Text.Sunken } } }
314 controlname: "SColor"
315 model: ListModel { ListElement { name: "Green"; value: "green" } ListElement { name: "Blue"; value: "blue" } } }
319 model: ListModel { ListElement { name: "None"; value: Text.NoWrap } ListElement { name: "Word"; value: Text.WordWrap }
320 ListElement { name: "Anywhere"; value: Text.WrapAnywhere } ListElement { name: "Wrap"; value: Text.Wrap } } }
324 model: ListModel { ListElement { name: "None"; value: -1 } ListElement { name: "Int"; value: 0 }
325 ListElement { name: "Double"; value: 1 } ListElement { name: "RegExp"; value: 2 } } }