From 8e5b6aca31d8558ded261920ec50fc32367e4bb0 Mon Sep 17 00:00:00 2001 From: axis Date: Mon, 4 May 2009 13:21:10 +0200 Subject: Make sure to update input context after switching input method hints. RevBy: denis --- src/gui/kernel/qwidget.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 64aeab5..ea59589 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -8498,6 +8498,10 @@ void QWidget::setInputMethodHints(Qt::InputMethodHints hints) { Q_D(QWidget); d->imHints = hints; + if (testAttribute(Qt::WA_InputMethodEnabled)) { + Q_ASSERT(inputContext()); + inputContext()->update(); + } } -- cgit v0.12 From 41f5a37bed62619a67259f2dfe37e3c57e2bf9f7 Mon Sep 17 00:00:00 2001 From: axis Date: Mon, 4 May 2009 13:25:50 +0200 Subject: Updated to slightly better docs. RevBy: denis --- src/gui/kernel/qwidget.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index ea59589..cfe02d6 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -8482,7 +8482,10 @@ QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const set, the input method may change its visual components to reflect that only numbers can be entered. - The effect may vary between input method implementations. + \note The flags are only hints, so the particular input method + implementation is free to ignore them. If you want to be + sure that for instance only uppercase letters are entered, + you should also set a QValidator on the widget. \since 4.6 -- cgit v0.12 From 8731f4ca737d032ffdf12fa9f2dfb2fa550931dd Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 5 May 2009 09:05:04 +0200 Subject: Small optimization to input context update. Only update the input context if it has already been created. RevBy: denis --- src/gui/kernel/qwidget.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index cfe02d6..d8d7be7 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -8501,9 +8501,11 @@ void QWidget::setInputMethodHints(Qt::InputMethodHints hints) { Q_D(QWidget); d->imHints = hints; - if (testAttribute(Qt::WA_InputMethodEnabled)) { - Q_ASSERT(inputContext()); - inputContext()->update(); + // Optimisation to update input context only it has already been created. + if (d->ic || qApp->d_func()->inputContext) { + QInputContext *ic = inputContext(); + if (ic) + ic->update(); } } -- cgit v0.12 From 54a61942de75faf2d7f8d1a58ec15f36505e1d38 Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 5 May 2009 15:55:44 +0200 Subject: Split ImhNumbersOnly into DigitsOnly and FormattedNumbersOnly. This was discussed with denis, and we found out that PIN codes on phones are a use case where it would be an advantage to have digits only. S60 already supports this mode of operation in their VK. --- doc/src/qnamespace.qdoc | 7 +++++-- src/corelib/global/qnamespace.h | 19 ++++++++++--------- src/gui/kernel/qwidget.cpp | 4 ++-- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/doc/src/qnamespace.qdoc b/doc/src/qnamespace.qdoc index 5ffae83..346c425 100644 --- a/doc/src/qnamespace.qdoc +++ b/doc/src/qnamespace.qdoc @@ -2397,12 +2397,15 @@ \value ImhNone No hints. \value ImhHiddenText Characters should be hidden, as is typically used when entering passwords. This is automatically set when setting QLineEdit::echoMode to \c Password. - \value ImhNumbersOnly Only number input is allowed. + \value ImhDigitsOnly Only digit input is allowed. + \value ImhFormattedNumbersOnly Only number input (including integers and real numbers) is allowed. \value ImhUppercaseOnly Only upper case letter input is allowed. \value ImhLowercaseOnly Only lower case letter input is allowed. \value ImhNoAutoUppercase The input method should not try to automatically switch to upper case when a sentence ends. - \value ImhPreferNumbers Numbers are preferred (but not required). + \value ImhPreferNumbers Numbers are preferred (but not required). This can include only digits, + or all numbers, depending on which one of the \c ImhDigitsOnly and + \c ImhFormattedNumbersOnly flags is given. \value ImhPreferUppercase Upper case letters are preferred (but not required). \value ImhPreferLowercase Lower case letters are preferred (but not required). \value ImhNoPredictiveText Do not use predictive text (i.e. dictionary lookup) while typing. diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 1475b2e..e0ca27c 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1401,15 +1401,16 @@ public: enum InputMethodHint { ImhNone = 0x0, ImhHiddenText = 0x1, - ImhNumbersOnly = 0x2, - ImhUppercaseOnly = 0x4, - ImhLowercaseOnly = 0x8, - ImhNoAutoUppercase = 0x10, - ImhPreferNumbers = 0x20, - ImhPreferUppercase = 0x40, - ImhPreferLowercase = 0x80, - ImhNoPredictiveText = 0x100, - ImhDialableCharactersOnly = 0x200 + ImhDigitsOnly = 0x2, + ImhFormattedNumbersOnly = 0x4, + ImhUppercaseOnly = 0x8, + ImhLowercaseOnly = 0x10, + ImhNoAutoUppercase = 0x20, + ImhPreferNumbers = 0x40, + ImhPreferUppercase = 0x80, + ImhPreferLowercase = 0x100, + ImhNoPredictiveText = 0x200, + ImhDialableCharactersOnly = 0x400 }; Q_DECLARE_FLAGS(InputMethodHints, InputMethodHint) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index d8d7be7..639d964 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -8478,8 +8478,8 @@ QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const This is only relevant for input widgets. It is used by the input method to retrieve hints as to how the input method - should operate. For example, if the Qt::ImhNumbersOnly flag is - set, the input method may change its visual components to reflect + should operate. For example, if the Qt::ImhFormattedNumbersOnly flag + is set, the input method may change its visual components to reflect that only numbers can be entered. \note The flags are only hints, so the particular input method -- cgit v0.12 From 7e6dd153858710282ddcb526e413226c3b7db833 Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 5 May 2009 15:57:59 +0200 Subject: Clarified the docs a bit. --- src/gui/kernel/qwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 639d964..19fdfbf 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -8484,7 +8484,7 @@ QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const \note The flags are only hints, so the particular input method implementation is free to ignore them. If you want to be - sure that for instance only uppercase letters are entered, + sure that a certain type of characters are entered, you should also set a QValidator on the widget. \since 4.6 -- cgit v0.12