summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorPekka Vuorela <pekka.ta.vuorela@nokia.com>2011-11-08 18:12:02 +0200
committerQt by Nokia <qt-info@nokia.com>2011-11-10 13:07:38 +0100
commitdc2a1aff9bc6bf18f594f96924f767165bf4581f (patch)
treed670384b73ab6e2e063d4862644754058a053ee5 /src/widgets
parentb5c37d9e137dee2754335e83b8437dfd0e6cc7e7 (diff)
QWidget text editors to commit text on their own on losing focus
Change-Id: I3b907661e8a24a6dbdaabf607c5c528b1b471c98 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp4
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp2
-rw-r--r--src/widgets/kernel/qapplication.cpp2
-rw-r--r--src/widgets/kernel/qwidget.cpp6
-rw-r--r--src/widgets/widgets/qlineedit.cpp1
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp1
6 files changed, 8 insertions, 8 deletions
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index 060a3da05f..b30d29e704 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -10214,10 +10214,8 @@ bool QGraphicsTextItem::sceneEvent(QEvent *event)
case QEvent::KeyRelease:
// Reset the focus widget's input context, regardless
// of how this item gained or lost focus.
- if (event->type() == QEvent::FocusIn) {
+ if (event->type() == QEvent::FocusIn || event->type() == QEvent::FocusOut) {
qApp->inputPanel()->reset();
- } else if (event->type() == QEvent::FocusOut) {
- qApp->inputPanel()->commit();
} else {
qApp->inputPanel()->update(Qt::ImQueryInput);
}
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index 8e9c095f8c..f99b72ffd0 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -822,7 +822,7 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item,
// the views, but if we are changing focus, we have to
// do it ourselves.
if (qApp)
- qApp->inputPanel()->commit();
+ qApp->inputPanel()->reset();
}
focusItem = 0;
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 07d2632b52..bc663c839b 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -1989,7 +1989,7 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason)
// or it is not created fully yet.
|| (focus_widget && (!focus_widget->testAttribute(Qt::WA_InputMethodEnabled)
|| !focus_widget->testAttribute(Qt::WA_WState_Created))))) {
- qApp->inputPanel()->commit();
+ qApp->inputPanel()->reset();
qApp->inputPanel()->setInputItem(0);
}
#endif //QT_NO_IM
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 91a4036001..584e4406ac 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -3132,7 +3132,7 @@ void QWidgetPrivate::setEnabled_helper(bool enable)
if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled))
qApp->inputPanel()->setInputItem(focusWidget);
} else {
- qApp->inputPanel()->commit();
+ qApp->inputPanel()->reset();
qApp->inputPanel()->setInputItem(0);
}
}
@@ -10191,7 +10191,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
QWidget *focusWidget = d->effectiveFocusWidget();
if (on && !internalWinId() && hasFocus()
&& focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
- qApp->inputPanel()->commit();
+ qApp->inputPanel()->reset();
qApp->inputPanel()->setInputItem(0);
}
if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget()
@@ -10244,7 +10244,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
&& focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
qApp->inputPanel()->setInputItem(focusWidget);
} else if (!on && qApp->inputPanel()->inputItem() == focusWidget) {
- qApp->inputPanel()->commit();
+ qApp->inputPanel()->reset();
qApp->inputPanel()->setInputItem(0);
}
#endif //QT_NO_IM
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index 43030289ff..4dc30d6542 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -1751,6 +1751,7 @@ void QLineEdit::focusOutEvent(QFocusEvent *e)
reason != Qt::PopupFocusReason)
deselect();
+ d->control->commitPreedit();
d->setCursorVisible(false);
d->control->setCursorBlinkPeriod(0);
#ifdef QT_KEYPAD_NAVIGATION
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index 258ab1bb11..a55e001fc4 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -2046,6 +2046,7 @@ void QWidgetTextControlPrivate::focusEvent(QFocusEvent *e)
}
#endif
} else {
+ commitPreedit();
setBlinkingCursorEnabled(false);
if (cursorIsFocusIndicator