Skip to content

Commit 18f500f

Browse files
Initial checkin
1 parent ec8d488 commit 18f500f

29 files changed

+2365
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

examples/qmlapp/DejaVuSans.ttf

724 KB
Binary file not shown.

examples/qmlapp/Main.qml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/****************************************************************************
2+
**
3+
** Copyright (C) 2014 Digia Plc
4+
** All rights reserved.
5+
** For any questions to Digia, please use contact form at http://www.qt.io
6+
**
7+
** This file is part of the Qt Virtual Keyboard add-on for Qt Enterprise.
8+
**
9+
** Licensees holding valid Qt Enterprise licenses may use this file in
10+
** accordance with the Qt Enterprise License Agreement provided with the
11+
** Software or, alternatively, in accordance with the terms contained in
12+
** a written agreement between you and Digia.
13+
**
14+
** If you have questions regarding the use of this file, please use
15+
** contact form at http://www.qt.io
16+
**
17+
****************************************************************************/
18+
19+
import QtQuick 2.0
20+
import "content"
21+
22+
Rectangle {
23+
width: parent.width
24+
height: parent.height
25+
color: "#005F3F"
26+
27+
Flickable {
28+
id: flickable
29+
30+
property real scrollMarginVertical: 20
31+
32+
anchors.fill: parent
33+
contentWidth: content.width
34+
contentHeight: content.height
35+
interactive: contentHeight > height
36+
flickableDirection: Flickable.VerticalFlick
37+
children: ScrollBar {}
38+
39+
MouseArea {
40+
id: content
41+
42+
width: flickable.width
43+
height: textEditors.height + 24
44+
45+
onClicked: focus = true
46+
47+
Column {
48+
id: textEditors
49+
spacing: 15
50+
x: 12; y: 12
51+
width: parent.width - 26
52+
53+
Text {
54+
color: "#EEEEEE"
55+
text: "Tap fields to enter text"
56+
anchors.horizontalCenter: parent.horizontalCenter
57+
font.pixelSize: 22
58+
}
59+
TextField {
60+
width: parent.width
61+
previewText: "One line field"
62+
//enterKeyAction: EnterKeyAction.Next
63+
onEnterKeyClicked: passwordField.focus = true
64+
objectName: "One line field"
65+
}
66+
TextField {
67+
id: passwordField
68+
69+
width: parent.width
70+
echoMode: TextInput.Password
71+
previewText: "Password field"
72+
inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhPreferLowercase | Qt.ImhSensitiveData | Qt.ImhNoPredictiveText
73+
//enterKeyAction: EnterKeyAction.Next
74+
onEnterKeyClicked: upperCaseField.focus = true
75+
}
76+
TextField {
77+
id: upperCaseField
78+
79+
width: parent.width
80+
previewText: "Upper case field"
81+
inputMethodHints: Qt.ImhUppercaseOnly
82+
//enterKeyAction: EnterKeyAction.Next
83+
onEnterKeyClicked: lowerCaseField.focus = true
84+
}
85+
TextField {
86+
id: lowerCaseField
87+
88+
width: parent.width
89+
previewText: "Lower case field"
90+
inputMethodHints: Qt.ImhLowercaseOnly
91+
//enterKeyAction: EnterKeyAction.Next
92+
onEnterKeyClicked: phoneNumberField.focus = true
93+
}
94+
TextField {
95+
id: phoneNumberField
96+
97+
validator: RegExpValidator { regExp: /^[0-9\+\-\#\*\ ]{6,}$/ }
98+
width: parent.width
99+
previewText: "Phone number field"
100+
inputMethodHints: Qt.ImhDialableCharactersOnly
101+
//enterKeyAction: EnterKeyAction.Next
102+
onEnterKeyClicked: formattedNumberField.focus = true
103+
}
104+
TextField {
105+
id: formattedNumberField
106+
107+
width: parent.width
108+
previewText: "Formatted number field"
109+
inputMethodHints: Qt.ImhFormattedNumbersOnly
110+
//enterKeyAction: EnterKeyAction.Next
111+
onEnterKeyClicked: digitsField.focus = true
112+
}
113+
TextField {
114+
id: digitsField
115+
116+
width: parent.width
117+
previewText: "Digits only field"
118+
inputMethodHints: Qt.ImhDigitsOnly
119+
//enterKeyAction: EnterKeyAction.Next
120+
onEnterKeyClicked: textArea.focus = true
121+
}
122+
TextArea {
123+
id: textArea
124+
125+
width: parent.width
126+
previewText: "Multiple lines field"
127+
height: Math.max(206, implicitHeight)
128+
}
129+
}
130+
}
131+
}
132+
}

examples/qmlapp/MainContainer.qml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/****************************************************************************
2+
**
3+
** Copyright (C) 2014 Digia Plc
4+
** All rights reserved.
5+
** For any questions to Digia, please use contact form at http://www.qt.io
6+
**
7+
** This file is part of the Qt Virtual Keyboard add-on for Qt Enterprise.
8+
**
9+
** Licensees holding valid Qt Enterprise licenses may use this file in
10+
** accordance with the Qt Enterprise License Agreement provided with the
11+
** Software or, alternatively, in accordance with the terms contained in
12+
** a written agreement between you and Digia.
13+
**
14+
** If you have questions regarding the use of this file, please use
15+
** contact form at http://www.qt.io
16+
**
17+
****************************************************************************/
18+
19+
import QtQuick 2.0
20+
import QtQuick.VirtualKeyboard 1.0
21+
import QtQuick.Window 2.0
22+
23+
24+
Rectangle {
25+
id: root
26+
color: "black"
27+
implicitWidth: mainQml.implicitWidth
28+
implicitHeight: mainQml.implicitHeight
29+
onWidthChanged: console.log("3 Root item size: " + height + " " + width)
30+
onHeightChanged: console.log("3 Root item size: " + height + " " + width)
31+
Item {
32+
clip: true
33+
id: appContainer
34+
width: parent.width
35+
height: parent.height
36+
anchors.centerIn: parent
37+
//anchors.horizontalCenterOffset: 5
38+
Main {
39+
id: mainQml
40+
anchors.left: parent.left
41+
anchors.top: parent.top
42+
anchors.right: parent.right
43+
anchors.bottom: inputPanel.top
44+
}
45+
InputPanel {
46+
id: inputPanel
47+
z: 99
48+
y: appContainer.height
49+
anchors.left: parent.left
50+
anchors.right: parent.right
51+
states: State {
52+
name: "visible"
53+
when: Qt.inputMethod.visible
54+
PropertyChanges {
55+
target: inputPanel
56+
y: appContainer.height - inputPanel.height
57+
}
58+
}
59+
transitions: Transition {
60+
from: ""
61+
to: "visible"
62+
reversible: true
63+
ParallelAnimation {
64+
NumberAnimation {
65+
properties: "y"
66+
duration: 150
67+
easing.type: Easing.InOutQuad
68+
}
69+
}
70+
}
71+
}
72+
}
73+
}

examples/qmlapp/content/ScrollBar.qml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/****************************************************************************
2+
**
3+
** Copyright (C) 2014 Digia Plc
4+
** All rights reserved.
5+
** For any questions to Digia, please use contact form at http://www.qt.io
6+
**
7+
** This file is part of the Qt Virtual Keyboard add-on for Qt Enterprise.
8+
**
9+
** Licensees holding valid Qt Enterprise licenses may use this file in
10+
** accordance with the Qt Enterprise License Agreement provided with the
11+
** Software or, alternatively, in accordance with the terms contained in
12+
** a written agreement between you and Digia.
13+
**
14+
** If you have questions regarding the use of this file, please use
15+
** contact form at http://www.qt.io
16+
**
17+
****************************************************************************/
18+
19+
import QtQuick 2.0
20+
21+
Item {
22+
property var scrollArea: parent
23+
24+
width: 6
25+
opacity: scrollArea && scrollArea.movingVertically ? 1.0 : 0.0
26+
visible: scrollArea && scrollArea.contentHeight >= scrollArea.height
27+
anchors { right: parent.right; top: parent.top; bottom: parent.bottom; margins: 2 }
28+
29+
Behavior on opacity { NumberAnimation { properties: "opacity"; duration: 600 } }
30+
31+
function size() {
32+
var nh = scrollArea.visibleArea.heightRatio * height
33+
var ny = scrollArea.visibleArea.yPosition * height
34+
return ny > 3 ? Math.min(nh, Math.ceil(height - 3 - ny)) : nh + ny
35+
}
36+
Rectangle {
37+
x: 1
38+
y: scrollArea ? Math.max(2, scrollArea.visibleArea.yPosition * parent.height) : 0
39+
height: scrollArea ? size() : 0
40+
width: parent.width - 2
41+
color: Qt.rgba(1.0, 1.0, 1.0, 0.5)
42+
radius: 1
43+
}
44+
}

examples/qmlapp/content/TextArea.qml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/****************************************************************************
2+
**
3+
** Copyright (C) 2014 Digia Plc
4+
** All rights reserved.
5+
** For any questions to Digia, please use contact form at http://www.qt.io
6+
**
7+
** This file is part of the Qt Virtual Keyboard add-on for Qt Enterprise.
8+
**
9+
** Licensees holding valid Qt Enterprise licenses may use this file in
10+
** accordance with the Qt Enterprise License Agreement provided with the
11+
** Software or, alternatively, in accordance with the terms contained in
12+
** a written agreement between you and Digia.
13+
**
14+
** If you have questions regarding the use of this file, please use
15+
** contact form at http://www.qt.io
16+
**
17+
****************************************************************************/
18+
19+
import QtQuick 2.0
20+
21+
TextBase {
22+
id: textArea
23+
24+
property alias color: textEdit.color
25+
property alias text: textEdit.text
26+
property alias textWidth: textEdit.width
27+
property alias readOnly: textEdit.readOnly
28+
property alias inputMethodHints: textEdit.inputMethodHints
29+
30+
editor: textEdit
31+
32+
Repeater {
33+
model: Math.floor((parent.height - 30) / editor.cursorRectangle.height)
34+
Rectangle {
35+
x: 8
36+
y: (index+1)*editor.cursorRectangle.height+6
37+
height: 1; width: textArea.width-24
38+
color: Qt.rgba(1.0, 1.0, 1.0, 0.5)
39+
}
40+
}
41+
TextEdit {
42+
id: textEdit
43+
44+
/*EnterKeyAction.actionId: textArea.enterKeyAction
45+
EnterKeyAction.label: textArea.enterKeyText
46+
EnterKeyAction.enabled: textArea.enterKeyEnabled*/
47+
48+
y: 6
49+
focus: true
50+
color: "#EEEEEE"
51+
wrapMode: TextEdit.Wrap
52+
cursorVisible: activeFocus
53+
height: Math.max(implicitHeight, 60)
54+
font.pixelSize: textArea.fontPixelSize
55+
selectionColor: Qt.rgba(1.0, 1.0, 1.0, 0.5)
56+
selectedTextColor: Qt.rgba(0.0, 0.0, 0.0, 0.8)
57+
anchors { left: parent.left; right: parent.right; margins: 12 }
58+
onActiveFocusChanged: if (!activeFocus) deselect()
59+
}
60+
}

examples/qmlapp/content/TextBase.qml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/****************************************************************************
2+
**
3+
** Copyright (C) 2014 Digia Plc
4+
** All rights reserved.
5+
** For any questions to Digia, please use contact form at http://www.qt.io
6+
**
7+
** This file is part of the Qt Virtual Keyboard add-on for Qt Enterprise.
8+
**
9+
** Licensees holding valid Qt Enterprise licenses may use this file in
10+
** accordance with the Qt Enterprise License Agreement provided with the
11+
** Software or, alternatively, in accordance with the terms contained in
12+
** a written agreement between you and Digia.
13+
**
14+
** If you have questions regarding the use of this file, please use
15+
** contact form at http://www.qt.io
16+
**
17+
****************************************************************************/
18+
import QtQuick 2.0
19+
20+
FocusScope {
21+
id: textBase
22+
23+
property var editor
24+
property bool previewTextActive: !editor.activeFocus && text.length === 0
25+
property int fontPixelSize: 32
26+
property string previewText
27+
//property int enterKeyAction: EnterKeyAction.None
28+
property int enterKeyAction
29+
property string enterKeyText
30+
//property bool enterKeyEnabled: enterKeyAction === EnterKeyAction.None || editor.text.length > 0 || editor.inputMethodComposing
31+
property bool enterKeyEnabled
32+
property alias mouseParent: mouseArea.parent
33+
34+
implicitHeight: editor.height + 12
35+
36+
signal enterKeyClicked
37+
38+
Keys.onReleased: {
39+
if (event.key === Qt.Key_Return)
40+
enterKeyClicked()
41+
}
42+
43+
Rectangle {
44+
// background
45+
radius: 5.0
46+
anchors.fill: parent
47+
color: Qt.rgba(1.0, 1.0, 1.0, 0.2)
48+
border { width: editor.activeFocus ? 2 : 0; color: "#CCCCCC" }
49+
}
50+
Text {
51+
id: previewText
52+
53+
y: 8
54+
color: "#CCCCCC"
55+
visible: previewTextActive
56+
text: textBase.previewText
57+
font.pixelSize: 28
58+
anchors { left: parent.left; right: parent.right; margins: 12 }
59+
60+
}
61+
MouseArea {
62+
id: mouseArea
63+
64+
z: 1
65+
parent: textBase
66+
anchors.fill: parent
67+
onClicked: {
68+
if (editor.inputMethodComposing) {
69+
if (!Qt.inputMethod.visible) {
70+
Qt.inputMethod.show()
71+
return
72+
}
73+
Qt.inputMethod.commit()
74+
}
75+
var positionInEditor = mapToItem(editor, mouseX, mouseY)
76+
var cursorPosition = editor.positionAt(positionInEditor.x, positionInEditor.y)
77+
editor.cursorPosition = cursorPosition
78+
editor.forceActiveFocus()
79+
Qt.inputMethod.show()
80+
}
81+
}
82+
}

0 commit comments

Comments
 (0)