summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Merila <sami.merila@nokia.com>2011-06-23 07:38:02 (GMT)
committerSami Merila <sami.merila@nokia.com>2011-06-23 07:38:02 (GMT)
commit18da8a264f9a155332940c9e7b416db0b0b5058d (patch)
tree22ee8050c90c453ac483b65170233bc8d0a8be26
parent17487a4d11146d0c501b0b13695c3d4d18aa580a (diff)
downloadQt-18da8a264f9a155332940c9e7b416db0b0b5058d.zip
Qt-18da8a264f9a155332940c9e7b416db0b0b5058d.tar.gz
Qt-18da8a264f9a155332940c9e7b416db0b0b5058d.tar.bz2
Splitview - Auto-translation rules changed
When using "splitview" (virtual keyboard with non-fullscreen editing mode), it is currently auto-translating the cursor to the center of the screen if possible. It would be preferable, if the translation would only be minimal, just enough for cursor to be visible. This makes scrolling of input widget (i.e. large editor) easier to use, as text flows naturally (row-by-row) and not in "jumps" like it used to do. Additionally, limit the translation to the end of input widget boundary. Task-number: QTBUG-20034 Reviewed-by: Miikka Heikkinen
-rw-r--r--src/gui/inputmethod/qcoefepinputcontext_s60.cpp33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
index fcb809c..07d68a4 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
+++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
@@ -901,20 +901,35 @@ void QCoeFepInputContext::translateInputWidget()
m_transformation = (rootItem->transform().isTranslating()) ? QRectF(0,0, gv->width(), rootItem->transform().dy()) : QRectF();
- // Do nothing if the cursor is visible in the splitview area.
- if (splitViewRect.contains(cursorP.boundingRect()))
+ // Adjust cursor bounding rect to be lower, so that view translates if the cursor gets near
+ // the splitview border.
+ QRect cursorRect = cursorP.boundingRect().adjusted(0, cursor.height(), 0, cursor.height());
+ if (splitViewRect.contains(cursorRect))
return;
- // New Y position should be ideally at the center of the splitview area.
- // If that would expose unpainted canvas, limit the tranformation to the visible scene bottom.
+ // New Y position should be ideally just above the keyboard.
+ // If that would expose unpainted canvas, limit the tranformation to the visible scene rect or
+ // to the focus item's shape/clip path.
- const qreal maxY = gv->sceneRect().bottom() - splitViewRect.bottom() + m_transformation.height();
- qreal dy = -(qMin(maxY, (cursor.bottom() - vkbRect.top() / 2)));
+ const QPainterPath path = gv->scene()->focusItem()->isClipped() ?
+ gv->scene()->focusItem()->clipPath() : gv->scene()->focusItem()->shape();
+ const qreal itemHeight = path.boundingRect().height();
- // Do not allow transform above screen top.
- if (m_transformation.height() + dy > 0) {
+ // Limit the maximum translation so that underlaying window content is not exposed.
+ qreal maxY = gv->sceneRect().bottom() - splitViewRect.bottom();
+ maxY = m_transformation.height() ? (qMin(itemHeight, maxY) + m_transformation.height()) : maxY;
+ if (maxY < 0)
+ maxY = 0;
+
+ // Translation should happen row-by-row, but initially it needs to ensure that cursor is visible.
+ const qreal translation = m_transformation.height() ?
+ cursor.height() : (cursorRect.bottom() - vkbRect.top());
+ const qreal dy = -(qMin(maxY, translation));
+
+ // Do not allow transform above screen top, nor beyond scenerect
+ if (m_transformation.height() + dy > 0 || gv->sceneRect().bottom() + m_transformation.height() < 0) {
// If we already have some transformation, remove it.
- if (m_transformation.height() < 0) {
+ if (m_transformation.height() < 0 || gv->sceneRect().bottom() + m_transformation.height() < 0) {
rootItem->resetTransform();
translateInputWidget();
}