6618 [Worklist] Add Input Field On Top of Keyboard

This commit is contained in:
beholder 2017-09-16 16:17:36 +03:00
parent 10494cf3e0
commit 871b169128
4 changed files with 57 additions and 63 deletions

View file

@ -34,7 +34,10 @@ Item {
onClicked: { onClicked: {
mouse.accepted = true; mouse.accepted = true;
webEntity.synthesizeKeyPress(glyph); webEntity.synthesizeKeyPress(glyph);
webEntity.synthesizeKeyPress(glyph, mirrorText);
if (toggle) { if (toggle) {
toggled = !toggled; toggled = !toggled;
} }

View file

@ -9,6 +9,7 @@
// //
import QtQuick 2.0 import QtQuick 2.0
import "."
Item { Item {
id: keyboardBase id: keyboardBase
@ -16,9 +17,15 @@ Item {
property bool raised: false property bool raised: false
property bool numeric: false property bool numeric: false
readonly property int keyboardRowHeight: 50
readonly property int keyboardWidth: 480
readonly property int mirrorTextHeight: keyboardRowHeight
property bool showMirrorText: true
readonly property int raisedHeight: 200 readonly property int raisedHeight: 200
height: enabled && raised ? raisedHeight : 0 height: enabled && raised ? raisedHeight + (showMirrorText ? keyboardRowHeight : 0) : 0
visible: enabled && raised visible: enabled && raised
property bool shiftMode: false property bool shiftMode: false
@ -93,24 +100,35 @@ Item {
} }
Rectangle { Rectangle {
id: leftRect
y: 0 y: 0
height: 200 x: 0
height: showMirrorText ? mirrorTextHeight : 0
width: keyboardWidth
color: "#252525" color: "#252525"
anchors.right: keyboardRect.left
anchors.rightMargin: 0 TextEdit {
anchors.bottom: parent.bottom id: mirrorText
anchors.bottomMargin: 0 visible: showMirrorText
anchors.left: parent.left size: 13.5
anchors.leftMargin: 0 horizontalAlignment: Text.AlignHCenter
color: "#FFFFFF";
anchors.fill: parent
wrapMode: Text.WordWrap
readOnly: false // we need to leave this property read-only to allow control to accept QKeyEvent
selectByMouse: false
}
MouseArea { // ... and we need this mouse area to prevent mirrorText from getting mouse events to ensure it will never get focus
anchors.fill: parent
}
} }
Rectangle { Rectangle {
id: keyboardRect id: keyboardRect
x: 206 x: 0
y: 0 y: showMirrorText ? mirrorTextHeight : 0
width: 480 width: keyboardWidth
height: 200 height: raisedHeight
color: "#252525" color: "#252525"
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
@ -118,13 +136,13 @@ Item {
Column { Column {
id: columnAlpha id: columnAlpha
width: 480 width: keyboardWidth
height: 200 height: raisedHeight
visible: !numeric visible: !numeric
Row { Row {
width: 480 width: keyboardWidth
height: 50 height: keyboardRowHeight
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 4 anchors.leftMargin: 4
@ -142,8 +160,8 @@ Item {
} }
Row { Row {
width: 480 width: keyboardWidth
height: 50 height: keyboardRowHeight
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 20 anchors.leftMargin: 20
@ -160,8 +178,8 @@ Item {
} }
Row { Row {
width: 480 width: keyboardWidth
height: 50 height: keyboardRowHeight
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 4 anchors.leftMargin: 4
@ -185,8 +203,8 @@ Item {
} }
Row { Row {
width: 480 width: keyboardWidth
height: 50 height: keyboardRowHeight
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 4 anchors.leftMargin: 4
@ -205,13 +223,13 @@ Item {
Column { Column {
id: columnNumeric id: columnNumeric
width: 480 width: keyboardWidth
height: 200 height: raisedHeight
visible: numeric visible: numeric
Row { Row {
width: 480 width: keyboardWidth
height: 50 height: keyboardRowHeight
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 4 anchors.leftMargin: 4
@ -229,8 +247,8 @@ Item {
} }
Row { Row {
width: 480 width: keyboardWidth
height: 50 height: keyboardRowHeight
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 4 anchors.leftMargin: 4
@ -248,8 +266,8 @@ Item {
} }
Row { Row {
width: 480 width: keyboardWidth
height: 50 height: keyboardRowHeight
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 4 anchors.leftMargin: 4
@ -273,8 +291,8 @@ Item {
} }
Row { Row {
width: 480 width: keyboardWidth
height: 50 height: keyboardRowHeight
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 4 anchors.leftMargin: 4
@ -291,31 +309,4 @@ Item {
} }
} }
} }
Rectangle {
id: rightRect
y: 280
height: 200
color: "#252525"
border.width: 0
anchors.left: keyboardRect.right
anchors.leftMargin: 0
anchors.right: parent.right
anchors.rightMargin: 0
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
}
Rectangle {
id: rectangle1
color: "#ffffff"
anchors.bottom: keyboardRect.top
anchors.bottomMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
anchors.right: parent.right
anchors.rightMargin: 0
anchors.top: parent.top
anchors.topMargin: 0
}
} }

View file

@ -987,8 +987,8 @@ static bool equals(const QByteArray& byteArray, const uint8_t* ptr) {
return ptr[i] == 0x00; return ptr[i] == 0x00;
} }
void OffscreenQmlSurface::synthesizeKeyPress(QString key) { void OffscreenQmlSurface::synthesizeKeyPress(QString key, QObject* target) {
auto eventHandler = getEventHandler(); auto eventHandler = target ? target : getEventHandler();
if (eventHandler) { if (eventHandler) {
auto utf8Key = key.toUtf8(); auto utf8Key = key.toUtf8();

View file

@ -79,7 +79,7 @@ public:
bool eventFilter(QObject* originalDestination, QEvent* event) override; bool eventFilter(QObject* originalDestination, QEvent* event) override;
void setKeyboardRaised(QObject* object, bool raised, bool numeric = false); void setKeyboardRaised(QObject* object, bool raised, bool numeric = false);
Q_INVOKABLE void synthesizeKeyPress(QString key); Q_INVOKABLE void synthesizeKeyPress(QString key, QObject* target = nullptr);
using TextureAndFence = std::pair<uint32_t, void*>; using TextureAndFence = std::pair<uint32_t, void*>;
// Checks to see if a new texture is available. If one is, the function returns true and // Checks to see if a new texture is available. If one is, the function returns true and