add basic support for the Qt virtual keyboard
This commit is contained in:
parent
0dff85210d
commit
025850b409
@ -35,6 +35,7 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QGuiApplication application(argc, argv);
|
||||
application.setApplicationName("nymea-app");
|
||||
@ -82,6 +83,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
engine->rootContext()->setContextProperty("systemProductType", QSysInfo::productType());
|
||||
|
||||
engine->rootContext()->setContextProperty("useVirtualKeyboard", qgetenv("QT_IM_MODULE") == "qtvirtualkeyboard");
|
||||
|
||||
application.setWindowIcon(QIcon(QString(":/styles/%1/logo.svg").arg(styleController.currentStyle())));
|
||||
|
||||
engine->load(QUrl(QLatin1String("qrc:/ui/Nymea.qml")));
|
||||
|
||||
@ -238,5 +238,6 @@
|
||||
<file>ui/components/MainPageTile.qml</file>
|
||||
<file>ui/images/configure.svg</file>
|
||||
<file>ui/images/network-wifi-symbolic.svg</file>
|
||||
<file>ui/KeyboardLoader.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
24
nymea-app/ui/KeyboardLoader.qml
Normal file
24
nymea-app/ui/KeyboardLoader.qml
Normal file
@ -0,0 +1,24 @@
|
||||
import QtQuick 2.0
|
||||
|
||||
Item {
|
||||
id: root
|
||||
implicitHeight: childrenRect.height
|
||||
|
||||
property string virtualKeyboardString:
|
||||
'
|
||||
import QtQuick 2.8;
|
||||
import QtQuick.VirtualKeyboard 2.1
|
||||
InputPanel {
|
||||
id: inputPanel
|
||||
y: Qt.inputMethod.visible ? parent.height - inputPanel.height : parent.height
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
}
|
||||
'
|
||||
|
||||
Component.onCompleted: {
|
||||
if (useVirtualKeyboard) {
|
||||
var kbd = Qt.createQmlObject(virtualKeyboardString, root);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -366,4 +366,9 @@ ApplicationWindow {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
KeyboardLoader {
|
||||
anchors { left: parent.left; bottom: parent.bottom; right: parent.right }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user