Commit 809257ca authored by Alessandro Portale's avatar Alessandro Portale
Browse files

Qt Quick Controls 2 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: I1610575729b1a2bd570ef7d7b6870f579f5e34f0
Reviewed-by: Mitch Curtis's avatarMitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Rainer Keller's avatarRainer Keller <Rainer.Keller@qt.io>
parent b18e084f
...@@ -2,9 +2,6 @@ import QtQuick %{QtQuickVersion} ...@@ -2,9 +2,6 @@ import QtQuick %{QtQuickVersion}
Page1Form { Page1Form {
button1.onClicked: { button1.onClicked: {
console.log("Button 1 clicked."); console.log("Button Pressed. Entered text: " + textField1.text);
}
button2.onClicked: {
console.log("Button 2 clicked.");
} }
} }
...@@ -3,20 +3,22 @@ import QtQuick.Controls %{QtQuickControls2Version} ...@@ -3,20 +3,22 @@ import QtQuick.Controls %{QtQuickControls2Version}
import QtQuick.Layouts %{QtQuickLayoutsVersion} import QtQuick.Layouts %{QtQuickLayoutsVersion}
Item { Item {
property alias textField1: textField1
property alias button1: button1 property alias button1: button1
property alias button2: button2
RowLayout { RowLayout {
anchors.centerIn: parent anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 20
anchors.top: parent.top
Button { TextField {
id: button1 id: textField1
text: qsTr("Press Me 1") placeholderText: qsTr("Text Field")
} }
Button { Button {
id: button2 id: button1
text: qsTr("Press Me 2") text: qsTr("Press Me")
} }
} }
} }
...@@ -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
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv); QGuiApplication app(argc, argv);
......
import QtQuick %{QtQuickVersion} import QtQuick %{QtQuickVersion}
import QtQuick.Controls %{QtQuickControls2Version} import QtQuick.Controls %{QtQuickControls2Version}
import QtQuick.Layouts %{QtQuickLayoutsVersion} import QtQuick.Layouts %{QtQuickLayoutsVersion}
@if %{UseVirtualKeyboard}
import QtQuick.VirtualKeyboard %{QtQuickVirtualKeyboardVersion}
@endif
ApplicationWindow { ApplicationWindow {
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
SwipeView { SwipeView {
id: swipeView id: swipeView
...@@ -34,4 +40,35 @@ ApplicationWindow { ...@@ -34,4 +40,35 @@ ApplicationWindow {
text: qsTr("Second") text: qsTr("Second")
} }
} }
@if %{UseVirtualKeyboard}
InputPanel {
id: inputPanel
z: 99
x: 0
y: root.height
width: root.width
states: State {
name: "visible"
when: inputPanel.active
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
} }
...@@ -17,7 +17,9 @@ ...@@ -17,7 +17,9 @@
{ "key": "QtQuickVersion", "value": "2.7" }, { "key": "QtQuickVersion", "value": "2.7" },
{ "key": "QtQuickControls2Version", "value": "2.0" }, { "key": "QtQuickControls2Version", "value": "2.0" },
{ "key": "QtQuickDialogsVersion", "value": "1.0" }, { "key": "QtQuickDialogsVersion", "value": "1.0" },
{ "key": "QtQuickLayoutsVersion", "value": "1.0" } { "key": "QtQuickLayoutsVersion", "value": "1.0" },
{ "key": "QtQuickVirtualKeyboardVersion", "value": "2.1" },
{ "key": "UseVirtualKeyboard", "value": "%{JS: [ %{Plugins} ].indexOf('Boot2Qt') >= 0}" }
], ],
"pages": "pages":
......
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