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: {
mouse.accepted = true;
webEntity.synthesizeKeyPress(glyph);
webEntity.synthesizeKeyPress(glyph, mirrorText);
if (toggle) {
toggled = !toggled;
}

View file

@ -9,6 +9,7 @@
//
import QtQuick 2.0
import "."
Item {
id: keyboardBase
@ -16,9 +17,15 @@ Item {
property bool raised: 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
height: enabled && raised ? raisedHeight : 0
height: enabled && raised ? raisedHeight + (showMirrorText ? keyboardRowHeight : 0) : 0
visible: enabled && raised
property bool shiftMode: false
@ -93,24 +100,35 @@ Item {
}
Rectangle {
id: leftRect
y: 0
height: 200
x: 0
height: showMirrorText ? mirrorTextHeight : 0
width: keyboardWidth
color: "#252525"
anchors.right: keyboardRect.left
anchors.rightMargin: 0
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
TextEdit {
id: mirrorText
visible: showMirrorText
size: 13.5
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 {
id: keyboardRect
x: 206
y: 0
width: 480
height: 200
x: 0
y: showMirrorText ? mirrorTextHeight : 0
width: keyboardWidth
height: raisedHeight
color: "#252525"
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
@ -118,13 +136,13 @@ Item {
Column {
id: columnAlpha
width: 480
height: 200
width: keyboardWidth
height: raisedHeight
visible: !numeric
Row {
width: 480
height: 50
width: keyboardWidth
height: keyboardRowHeight
anchors.left: parent.left
anchors.leftMargin: 4
@ -142,8 +160,8 @@ Item {
}
Row {
width: 480
height: 50
width: keyboardWidth
height: keyboardRowHeight
anchors.left: parent.left
anchors.leftMargin: 20
@ -160,8 +178,8 @@ Item {
}
Row {
width: 480
height: 50
width: keyboardWidth
height: keyboardRowHeight
anchors.left: parent.left
anchors.leftMargin: 4
@ -185,8 +203,8 @@ Item {
}
Row {
width: 480
height: 50
width: keyboardWidth
height: keyboardRowHeight
anchors.left: parent.left
anchors.leftMargin: 4
@ -205,13 +223,13 @@ Item {
Column {
id: columnNumeric
width: 480
height: 200
width: keyboardWidth
height: raisedHeight
visible: numeric
Row {
width: 480
height: 50
width: keyboardWidth
height: keyboardRowHeight
anchors.left: parent.left
anchors.leftMargin: 4
@ -229,8 +247,8 @@ Item {
}
Row {
width: 480
height: 50
width: keyboardWidth
height: keyboardRowHeight
anchors.left: parent.left
anchors.leftMargin: 4
@ -248,8 +266,8 @@ Item {
}
Row {
width: 480
height: 50
width: keyboardWidth
height: keyboardRowHeight
anchors.left: parent.left
anchors.leftMargin: 4
@ -273,8 +291,8 @@ Item {
}
Row {
width: 480
height: 50
width: keyboardWidth
height: keyboardRowHeight
anchors.left: parent.left
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;
}
void OffscreenQmlSurface::synthesizeKeyPress(QString key) {
auto eventHandler = getEventHandler();
void OffscreenQmlSurface::synthesizeKeyPress(QString key, QObject* target) {
auto eventHandler = target ? target : getEventHandler();
if (eventHandler) {
auto utf8Key = key.toUtf8();

View file

@ -79,7 +79,7 @@ public:
bool eventFilter(QObject* originalDestination, QEvent* event) override;
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*>;
// Checks to see if a new texture is available. If one is, the function returns true and