Commit b18e084f authored by Alessandro Portale's avatar Alessandro Portale

Qt Quick App Wizard: Add virtual keyboard for Boot2Qt

If the Boot2Qt plugin is installed, the wizard generates the required
code to instantiate the virtual keyboard and to slide it in & out.

Change-Id: I700a00d60de2936972713bf383570629c8bf678f
Reviewed-by: Mitch Curtis's avatarMitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Rainer Keller's avatarRainer Keller <Rainer.Keller@qt.io>
parent 4c26c897
......@@ -2,6 +2,7 @@ import QtQuick %{QtQuickVersion}
Rectangle {
property alias mouseArea: mouseArea
property alias textEdit: textEdit
width: 360
height: 360
......@@ -11,8 +12,18 @@ Rectangle {
anchors.fill: parent
}
Text {
anchors.centerIn: parent
text: "Hello World"
TextEdit {
id: textEdit
text: qsTr("Enter some text...")
verticalAlignment: Text.AlignVCenter
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 20
Rectangle {
anchors.fill: parent
anchors.margins: -10
color: "transparent"
border.width: 1
}
}
}
......@@ -2,6 +2,10 @@
%{JS: QtSupport.qtIncludes([], ["QtGui/QGuiApplication", "QtQml/QQmlApplicationEngine"])}
int main(int argc, char *argv[])
{
@if %{UseVirtualKeyboard}
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
@endif
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
......
import QtQuick %{QtQuickVersion}
import QtQuick.Window %{QtQuickWindowVersion}
@if %{UseVirtualKeyboard}
import %{QtQuickVirtualKeyboardImport}
@endif
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
@if %{UseVirtualKeyboard}
id: root
@endif
@if %{IsUiFileInUse}
MainForm {
anchors.fill: parent
mouseArea.onClicked: {
Qt.quit();
console.log(qsTr('Clicked on background. Text: "' + textEdit.text + '"'))
}
}
@else
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit();
console.log(qsTr('Clicked on background. Text: "' + textEdit.text + '"'))
}
}
Text {
text: qsTr("Hello World")
anchors.centerIn: parent
TextEdit {
id: textEdit
text: qsTr("Enter some text...")
verticalAlignment: Text.AlignVCenter
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 20
Rectangle {
anchors.fill: parent
anchors.margins: -10
color: "transparent"
border.width: 1
}
}
@endif
@if %{UseVirtualKeyboard}
InputPanel {
id: inputPanel
z: 99
x: 0
y: root.height
width: root.width
states: State {
name: "visible"
when: %{QtQuickVirtualKeyboardWhenVisible}
PropertyChanges {
target: inputPanel
y: root.height - inputPanel.height
}
}
transitions: Transition {
from: ""
to: "visible"
reversible: true
ParallelAnimation {
NumberAnimation {
properties: "y"
duration: 250
easing.type: Easing.InOutQuad
}
}
}
}
@endif
}
......@@ -16,9 +16,12 @@
{ "key": "MainCppFileName", "value": "%{JS: 'main.' + Util.preferredSuffix('text/x-c++src')}" },
{ "key": "QtQuickVersion", "value": "%{JS: %{QtVersion}.qtQuickVersion}" },
{ "key": "QtQuickWindowVersion", "value": "%{JS: %{QtVersion}.qtQuickWindowVersion}" },
{ "key": "QtQuickVirtualKeyboardImport", "value": "%{JS: %{QtVersion}.qtQuickVirtualKeyboardImport}" },
{ "key": "QtQuickVirtualKeyboardWhenVisible", "value": "%{JS: %{QtVersion}.qtQuickVirtualKeyboardWhenVisible}" },
{ "key": "QtQuickFeature", "value": "QtSupport.Wizards.FeatureQtQuick.%{QtQuickVersion}" },
{ "key": "UiSupport", "value": "%{JS: '%{QtQuickVersion}' !== '2.3' }" },
{ "key": "IsUiFileInUse", "value": "%{JS: %{UiSupport} && %{QmlUiSplit} }" }
{ "key": "IsUiFileInUse", "value": "%{JS: %{UiSupport} && %{QmlUiSplit} }" },
{ "key": "UseVirtualKeyboard", "value": "%{JS: [ %{Plugins} ].indexOf('Boot2Qt') >= 0}" }
],
"pages":
......@@ -48,7 +51,9 @@
"value":
"{
'qtQuickVersion': '2.7',
'qtQuickWindowVersion': '2.2'
'qtQuickWindowVersion': '2.2',
'qtQuickVirtualKeyboardImport': 'QtQuick.VirtualKeyboard 2.1',
'qtQuickVirtualKeyboardWhenVisible': 'inputPanel.active'
}"
},
{
......@@ -56,7 +61,9 @@
"value":
"{
'qtQuickVersion': '2.6',
'qtQuickWindowVersion': '2.2'
'qtQuickWindowVersion': '2.2',
'qtQuickVirtualKeyboardImport': 'QtQuick.Enterprise.VirtualKeyboard 2.0',
'qtQuickVirtualKeyboardWhenVisible': 'inputPanel.active'
}"
},
{
......@@ -64,7 +71,9 @@
"value":
"{
'qtQuickVersion': '2.5',
'qtQuickWindowVersion': '2.2'
'qtQuickWindowVersion': '2.2',
'qtQuickVirtualKeyboardImport': 'QtQuick.Enterprise.VirtualKeyboard 1.3',
'qtQuickVirtualKeyboardWhenVisible': 'Qt.inputMethod.visible'
}"
},
{
......@@ -72,7 +81,9 @@
"value":
"{
'qtQuickVersion': '2.4',
'qtQuickWindowVersion': '2.2'
'qtQuickWindowVersion': '2.2',
'qtQuickVirtualKeyboardImport': 'QtQuick.Enterprise.VirtualKeyboard 1.0',
'qtQuickVirtualKeyboardWhenVisible': 'Qt.inputMethod.visible'
}"
},
{
......@@ -80,7 +91,9 @@
"value":
"{
'qtQuickVersion': '2.3',
'qtQuickWindowVersion': '2.2'
'qtQuickWindowVersion': '2.2',
'qtQuickVirtualKeyboardImport': 'QtQuick.Enterprise.VirtualKeyboard 1.0',
'qtQuickVirtualKeyboardWhenVisible': 'Qt.inputMethod.visible'
}"
}
]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment