aboutsummaryrefslogtreecommitdiffstats
path: root/src/virtualkeyboard/content
diff options
context:
space:
mode:
authorJarkko Koivikko <jarkko.koivikko@code-q.fi>2015-10-28 13:33:07 +0200
committerJarkko Koivikko <jarkko.koivikko@code-q.fi>2015-10-29 08:59:26 +0000
commit287efcc93d1db7eff3d43f2ebff4268754842921 (patch)
treea93f3f6ed396b338ddfe8ffbe5ba72a1c6f05a67 /src/virtualkeyboard/content
parentc51d8c4f27115f5efa2d58c64a5af4bda037a21e (diff)
Flip the word candidate popup above the cursor if it does not fit below
Previously the word candidate popup was always located below the cursor. Now it flips above the cursor if there is more room. Change-Id: I90f539703b001de5565d7d96c2b39df6185cde1a Reviewed-by: Rainer Keller <rainer.keller@theqtcompany.com> Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src/virtualkeyboard/content')
-rw-r--r--src/virtualkeyboard/content/components/WordCandidatePopupList.qml16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/virtualkeyboard/content/components/WordCandidatePopupList.qml b/src/virtualkeyboard/content/components/WordCandidatePopupList.qml
index aee69092..41f47e35 100644
--- a/src/virtualkeyboard/content/components/WordCandidatePopupList.qml
+++ b/src/virtualkeyboard/content/components/WordCandidatePopupList.qml
@@ -26,11 +26,23 @@ ListView {
id: wordCandidatePopupList
property int maxVisibleItems: 5
+ readonly property int preferredVisibleItems: {
+ if (!currentItem)
+ return 0
+ var maxHeight = flipVertical ? Qt.inputMethod.cursorRectangle.y : parent.height - Qt.inputMethod.cursorRectangle.height - Qt.inputMethod.cursorRectangle.y
+ var result = Math.min(count, maxVisibleItems)
+ while (result > 2 && result * currentItem.height > maxHeight)
+ --result
+ return result
+ }
readonly property real contentWidth: contentItem.childrenRect.width
+ readonly property bool flipVertical: currentItem &&
+ Qt.inputMethod.cursorRectangle.y + (Qt.inputMethod.cursorRectangle.height / 2) > (parent.height / 2) &&
+ Qt.inputMethod.cursorRectangle.y + Qt.inputMethod.cursorRectangle.height + (currentItem.height * 2) > parent.height
clip: true
visible: enabled && count > 0
- height: currentItem ? currentItem.height * Math.min(maxVisibleItems, count) + (spacing * Math.min(maxVisibleItems, count) - 1) : 0
+ height: currentItem ? currentItem.height * preferredVisibleItems + (spacing * preferredVisibleItems - 1) : 0
Binding {
target: wordCandidatePopupList
property: "x"
@@ -43,7 +55,7 @@ ListView {
Binding {
target: wordCandidatePopupList
property: "y"
- value: Qt.inputMethod.cursorRectangle.y + Qt.inputMethod.cursorRectangle.height
+ value: wordCandidatePopupList.flipVertical ? Qt.inputMethod.cursorRectangle.y - wordCandidatePopupList.height : Qt.inputMethod.cursorRectangle.y + Qt.inputMethod.cursorRectangle.height
when: wordCandidatePopupList.visible
}
orientation: ListView.Vertical