Skip to content

Commit

Permalink
Fix TextInput and TextEdit openInputPanel autotests
Browse files Browse the repository at this point in the history
Task-number: QTBUG-21691

The change also removes showInputPanelOnClick code from the TextInput and
TextEdit, which was done to support Symbian^1 and ^3 fullscreen keyboards.
Now by default the keyboard always follows editor focus.

Change-Id: Id60a17fe51b3aa49ba9ea81b985e608e91c26145
Reviewed-on: http://codereview.qt-project.org/5733
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
  • Loading branch information
Joona Petrell authored and Qt by Nokia committed Sep 29, 2011
1 parent 8120e8c commit 65f07f3
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 440 deletions.
5 changes: 4 additions & 1 deletion src/declarative/items/qsgcanvas.cpp
Expand Up @@ -722,7 +722,10 @@ void QSGCanvasPrivate::notifyFocusChangesRecur(QSGItem **items, int remaining)

void QSGCanvasPrivate::updateInputMethodData()
{
qApp->inputPanel()->setInputItem(activeFocusItem);
QSGItem *inputItem = 0;
if (activeFocusItem && activeFocusItem->flags() & QSGItem::ItemAcceptsInputMethod)
inputItem = activeFocusItem;
qApp->inputPanel()->setInputItem(inputItem);
}

QVariant QSGCanvas::inputMethodQuery(Qt::InputMethodQuery query) const
Expand Down
30 changes: 5 additions & 25 deletions src/declarative/items/qsgtextedit.cpp
Expand Up @@ -1332,16 +1332,9 @@ void QSGTextEdit::mousePressEvent(QMouseEvent *event)
if (d->focusOnPress){
bool hadActiveFocus = hasActiveFocus();
forceActiveFocus();
if (d->showInputPanelOnFocus) {
if (hasActiveFocus() && hadActiveFocus && !isReadOnly()) {
// re-open input panel on press if already focused
openSoftwareInputPanel();
}
} else { // show input panel on click
if (hasActiveFocus() && !hadActiveFocus) {
d->clickCausedFocus = true;
}
}
// re-open input panel on press if already focused
if (hasActiveFocus() && hadActiveFocus && !isReadOnly())
openSoftwareInputPanel();
}
d->control->processEvent(event, QPointF(0, -d->yoff));
if (!event->isAccepted())
Expand All @@ -1356,16 +1349,6 @@ void QSGTextEdit::mouseReleaseEvent(QMouseEvent *event)
{
Q_D(QSGTextEdit);
d->control->processEvent(event, QPointF(0, -d->yoff));
if (!d->showInputPanelOnFocus) { // input panel on click
if (d->focusOnPress && !isReadOnly() && boundingRect().contains(event->localPos())) {
// ### refactor: port properly
qDebug("QSGTextEdit: virtual keyboard handling not implemented");
// if (canvas() && canvas() == qApp->focusWidget()) {
// qt_widget_private(canvas())->handleSoftwareInputPanel(event->button(), d->clickCausedFocus);
// }
}
}
d->clickCausedFocus = false;

if (!event->isAccepted())
QSGImplicitSizeItem::mouseReleaseEvent(event);
Expand Down Expand Up @@ -1972,11 +1955,8 @@ void QSGTextEdit::closeSoftwareInputPanel()
void QSGTextEdit::focusInEvent(QFocusEvent *event)
{
Q_D(const QSGTextEdit);
if (d->showInputPanelOnFocus) {
if (d->focusOnPress && !isReadOnly()) {
openSoftwareInputPanel();
}
}
if (d->focusOnPress && !isReadOnly())
openSoftwareInputPanel();
QSGImplicitSizeItem::focusInEvent(event);
}

Expand Down
10 changes: 1 addition & 9 deletions src/declarative/items/qsgtextedit_p_p.h
Expand Up @@ -72,19 +72,13 @@ class QSGTextEditPrivate : public QSGImplicitSizeItemPrivate
QSGTextEditPrivate()
: color("black"), hAlign(QSGTextEdit::AlignLeft), vAlign(QSGTextEdit::AlignTop),
documentDirty(true), dirty(false), richText(false), cursorVisible(false), focusOnPress(true),
showInputPanelOnFocus(true), clickCausedFocus(false), persistentSelection(true),
requireImplicitWidth(false), selectByMouse(false), canPaste(false),
persistentSelection(true), requireImplicitWidth(false), selectByMouse(false), canPaste(false),
hAlignImplicit(true), rightToLeftText(false), isComplexRichText(false),
textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0), cursorComponent(0), cursor(0),
format(QSGTextEdit::AutoText), document(0), wrapMode(QSGTextEdit::NoWrap),
mouseSelectionMode(QSGTextEdit::SelectCharacters),
lineCount(0), yoff(0), nodeType(NodeIsNull), texture(0)
{
#ifdef Q_OS_SYMBIAN
if (QSysInfo::symbianVersion() == QSysInfo::SV_SF_1 || QSysInfo::symbianVersion() == QSysInfo::SV_SF_3) {
showInputPanelOnFocus = false;
}
#endif
}

void init();
Expand Down Expand Up @@ -113,8 +107,6 @@ class QSGTextEditPrivate : public QSGImplicitSizeItemPrivate
bool richText : 1;
bool cursorVisible : 1;
bool focusOnPress : 1;
bool showInputPanelOnFocus : 1;
bool clickCausedFocus : 1;
bool persistentSelection : 1;
bool requireImplicitWidth:1;
bool selectByMouse:1;
Expand Down
30 changes: 5 additions & 25 deletions src/declarative/items/qsgtextinput.cpp
Expand Up @@ -1105,16 +1105,9 @@ void QSGTextInput::mousePressEvent(QMouseEvent *event)
if(d->focusOnPress){
bool hadActiveFocus = hasActiveFocus();
forceActiveFocus();
if (d->showInputPanelOnFocus) {
if (hasActiveFocus() && hadActiveFocus && !isReadOnly()) {
// re-open input panel on press if already focused
openSoftwareInputPanel();
}
} else { // show input panel on click
if (hasActiveFocus() && !hadActiveFocus) {
d->clickCausedFocus = true;
}
}
// re-open input panel on press if already focused
if (hasActiveFocus() && hadActiveFocus && !isReadOnly())
openSoftwareInputPanel();
}
if (d->selectByMouse) {
setKeepMouseGrab(false);
Expand Down Expand Up @@ -1158,16 +1151,6 @@ void QSGTextInput::mouseReleaseEvent(QMouseEvent *event)
d->selectPressed = false;
setKeepMouseGrab(false);
}
if (!d->showInputPanelOnFocus) { // input panel on click
if (d->focusOnPress && !isReadOnly() && boundingRect().contains(event->localPos())) {
if (canvas() && canvas() == QGuiApplication::activeWindow()) {
// ### refactor: implement virtual keyboard properly..
qDebug("QSGTextInput: virtual keyboard no implemented...");
// qt_widget_private(canvas())->handleSoftwareInputPanel(event->button(), d->clickCausedFocus);
}
}
}
d->clickCausedFocus = false;
d->control->processEvent(event);
if (!event->isAccepted())
QSGImplicitSizeItem::mouseReleaseEvent(event);
Expand Down Expand Up @@ -1797,11 +1780,8 @@ void QSGTextInput::closeSoftwareInputPanel()
void QSGTextInput::focusInEvent(QFocusEvent *event)
{
Q_D(const QSGTextInput);
if (d->showInputPanelOnFocus) {
if (d->focusOnPress && !isReadOnly()) {
openSoftwareInputPanel();
}
}
if (d->focusOnPress && !isReadOnly())
openSoftwareInputPanel();
QSGImplicitSizeItem::focusInEvent(event);
}

Expand Down
9 changes: 0 additions & 9 deletions src/declarative/items/qsgtextinput_p_p.h
Expand Up @@ -88,8 +88,6 @@ class Q_AUTOTEST_EXPORT QSGTextInputPrivate : public QSGImplicitSizeItemPrivate
, oldValidity(false)
, focused(false)
, focusOnPress(true)
, showInputPanelOnFocus(true)
, clickCausedFocus(false)
, cursorVisible(false)
, autoScroll(true)
, selectByMouse(false)
Expand All @@ -98,11 +96,6 @@ class Q_AUTOTEST_EXPORT QSGTextInputPrivate : public QSGImplicitSizeItemPrivate
, selectPressed(false)
, textLayoutDirty(true)
{
#ifdef Q_OS_SYMBIAN
if (QSysInfo::symbianVersion() == QSysInfo::SV_SF_1 || QSysInfo::symbianVersion() == QSysInfo::SV_SF_3) {
showInputPanelOnFocus = false;
}
#endif
}

~QSGTextInputPrivate()
Expand Down Expand Up @@ -158,8 +151,6 @@ class Q_AUTOTEST_EXPORT QSGTextInputPrivate : public QSGImplicitSizeItemPrivate
bool oldValidity:1;
bool focused:1;
bool focusOnPress:1;
bool showInputPanelOnFocus:1;
bool clickCausedFocus:1;
bool cursorVisible:1;
bool autoScroll:1;
bool selectByMouse:1;
Expand Down
1 change: 1 addition & 0 deletions tests/auto/declarative/qsgtextedit/data/openInputPanel.qml
@@ -1,6 +1,7 @@
import QtQuick 2.0

TextEdit {
width: 100; height: 100
text: "Hello world"
focus: false
}

0 comments on commit 65f07f3

Please sign in to comment.