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} ...@@ -2,6 +2,7 @@ import QtQuick %{QtQuickVersion}
Rectangle { Rectangle {
property alias mouseArea: mouseArea property alias mouseArea: mouseArea
property alias textEdit: textEdit
width: 360 width: 360
height: 360 height: 360
...@@ -11,8 +12,18 @@ Rectangle { ...@@ -11,8 +12,18 @@ Rectangle {
anchors.fill: parent anchors.fill: parent
} }
Text { TextEdit {
anchors.centerIn: parent id: textEdit
text: "Hello World" 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 @@ ...@@ -2,6 +2,10 @@
%{JS: QtSupport.qtIncludes([], ["QtGui/QGuiApplication", "QtQml/QQmlApplicationEngine"])} %{JS: QtSupport.qtIncludes([], ["QtGui/QGuiApplication", "QtQml/QQmlApplicationEngine"])}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
@if %{UseVirtualKeyboard}
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
@endif
QGuiApplication app(argc, argv); QGuiApplication app(argc, argv);
QQmlApplicationEngine engine; QQmlApplicationEngine engine;
......
import QtQuick %{QtQuickVersion} import QtQuick %{QtQuickVersion}
import QtQuick.Window %{QtQuickWindowVersion} import QtQuick.Window %{QtQuickWindowVersion}
@if %{UseVirtualKeyboard}
import %{QtQuickVirtualKeyboardImport}
@endif
Window { Window {
visible: true visible: true
width: 640 width: 640
height: 480 height: 480
title: qsTr("Hello World") title: qsTr("Hello World")
@if %{UseVirtualKeyboard}
id: root
@endif
@if %{IsUiFileInUse} @if %{IsUiFileInUse}
MainForm { MainForm {
anchors.fill: parent anchors.fill: parent
mouseArea.onClicked: { mouseArea.onClicked: {
Qt.quit(); console.log(qsTr('Clicked on background. Text: "' + textEdit.text + '"'))
} }
} }
@else @else
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
Qt.quit(); console.log(qsTr('Clicked on background. Text: "' + textEdit.text + '"'))
} }
} }
Text { TextEdit {
text: qsTr("Hello World") id: textEdit
anchors.centerIn: parent 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 @endif
} }
...@@ -16,9 +16,12 @@ ...@@ -16,9 +16,12 @@
{ "key": "MainCppFileName", "value": "%{JS: 'main.' + Util.preferredSuffix('text/x-c++src')}" }, { "key": "MainCppFileName", "value": "%{JS: 'main.' + Util.preferredSuffix('text/x-c++src')}" },
{ "key": "QtQuickVersion", "value": "%{JS: %{QtVersion}.qtQuickVersion}" }, { "key": "QtQuickVersion", "value": "%{JS: %{QtVersion}.qtQuickVersion}" },
{ "key": "QtQuickWindowVersion", "value": "%{JS: %{QtVersion}.qtQuickWindowVersion}" }, { "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": "QtQuickFeature", "value": "QtSupport.Wizards.FeatureQtQuick.%{QtQuickVersion}" },
{ "key": "UiSupport", "value": "%{JS: '%{QtQuickVersion}' !== '2.3' }" }, { "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": "pages":
...@@ -48,7 +51,9 @@ ...@@ -48,7 +51,9 @@
"value": "value":
"{ "{
'qtQuickVersion': '2.7', 'qtQuickVersion': '2.7',
'qtQuickWindowVersion': '2.2' 'qtQuickWindowVersion': '2.2',
'qtQuickVirtualKeyboardImport': 'QtQuick.VirtualKeyboard 2.1',
'qtQuickVirtualKeyboardWhenVisible': 'inputPanel.active'
}" }"
}, },
{ {
...@@ -56,7 +61,9 @@ ...@@ -56,7 +61,9 @@
"value": "value":
"{ "{
'qtQuickVersion': '2.6', 'qtQuickVersion': '2.6',
'qtQuickWindowVersion': '2.2' 'qtQuickWindowVersion': '2.2',
'qtQuickVirtualKeyboardImport': 'QtQuick.Enterprise.VirtualKeyboard 2.0',
'qtQuickVirtualKeyboardWhenVisible': 'inputPanel.active'
}" }"
}, },
{ {
...@@ -64,7 +71,9 @@ ...@@ -64,7 +71,9 @@
"value": "value":
"{ "{
'qtQuickVersion': '2.5', 'qtQuickVersion': '2.5',
'qtQuickWindowVersion': '2.2' 'qtQuickWindowVersion': '2.2',
'qtQuickVirtualKeyboardImport': 'QtQuick.Enterprise.VirtualKeyboard 1.3',
'qtQuickVirtualKeyboardWhenVisible': 'Qt.inputMethod.visible'
}" }"
}, },
{ {
...@@ -72,7 +81,9 @@ ...@@ -72,7 +81,9 @@
"value": "value":
"{ "{
'qtQuickVersion': '2.4', 'qtQuickVersion': '2.4',
'qtQuickWindowVersion': '2.2' 'qtQuickWindowVersion': '2.2',
'qtQuickVirtualKeyboardImport': 'QtQuick.Enterprise.VirtualKeyboard 1.0',
'qtQuickVirtualKeyboardWhenVisible': 'Qt.inputMethod.visible'
}" }"
}, },
{ {
...@@ -80,7 +91,9 @@ ...@@ -80,7 +91,9 @@
"value": "value":
"{ "{
'qtQuickVersion': '2.3', '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