diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-08-06 16:18:54 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-08-06 16:18:54 (GMT) |
commit | e12448b0e00a70377591fbe9b3180dcb5f37e533 (patch) | |
tree | 349f5651c19350221bdfbbb2a46b38207e8086e2 | |
parent | c17c9b4c0a62ca63d7c7647e7c8ef8a4c719da2f (diff) | |
parent | 6eb7a210eed1b392431fc913d13d205b8ccc1933 (diff) | |
download | Qt-e12448b0e00a70377591fbe9b3180dcb5f37e533.zip Qt-e12448b0e00a70377591fbe9b3180dcb5f37e533.tar.gz Qt-e12448b0e00a70377591fbe9b3180dcb5f37e533.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt-s60-public into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/qt-s60-public:
Fixes for combining multiple Qt::ImhXXXOnly with S60 FEP
fix compile error
Test code for input method hints
Make input methods work correctly with Symbian^3 FEP in numeric mode
-rw-r--r-- | src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 49 | ||||
-rw-r--r-- | tests/manual/inputmethodhints/inputmethodhints.cpp | 99 | ||||
-rw-r--r-- | tests/manual/inputmethodhints/inputmethodhints.h | 63 | ||||
-rw-r--r-- | tests/manual/inputmethodhints/inputmethodhints.pro | 13 | ||||
-rw-r--r-- | tests/manual/inputmethodhints/inputmethodhints.ui | 138 | ||||
-rw-r--r-- | tests/manual/inputmethodhints/main.cpp | 53 |
6 files changed, 398 insertions, 17 deletions
diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index 999edda..44fe7da 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -359,10 +359,10 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) commitTemporaryPreeditString(); - bool numbersOnly = hints & ImhDigitsOnly || hints & ImhFormattedNumbersOnly - || hints & ImhDialableCharactersOnly; - bool noOnlys = !(numbersOnly || hints & ImhUppercaseOnly - || hints & ImhLowercaseOnly); + const bool anynumbermodes = hints & (ImhDigitsOnly | ImhFormattedNumbersOnly | ImhDialableCharactersOnly); + const bool anytextmodes = hints & (ImhUppercaseOnly | ImhLowercaseOnly | ImhEmailCharactersOnly | ImhUrlCharactersOnly); + const bool numbersOnly = anynumbermodes && !anytextmodes; + const bool noOnlys = !(hints & ImhExclusiveInputMask); TInt flags; Qt::InputMethodHints oldHints = hints; @@ -374,8 +374,7 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) } if (!noOnlys) { // Make sure that the preference is within the permitted set. - if (hints & ImhPreferNumbers && !(hints & ImhDigitsOnly || hints & ImhFormattedNumbersOnly - || hints & ImhDialableCharactersOnly)) { + if (hints & ImhPreferNumbers && !anynumbermodes) { hints &= ~ImhPreferNumbers; } else if (hints & ImhPreferUppercase && !(hints & ImhUppercaseOnly)) { hints &= ~ImhPreferUppercase; @@ -388,8 +387,7 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) hints |= ImhPreferLowercase; } else if (hints & ImhUppercaseOnly) { hints |= ImhPreferUppercase; - } else if (hints & ImhDigitsOnly || hints & ImhFormattedNumbersOnly - || hints & ImhDialableCharactersOnly) { + } else if (numbersOnly) { hints |= ImhPreferNumbers; } } @@ -403,13 +401,21 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) m_fepState->SetCurrentInputMode(EAknEditorTextInputMode); } flags = 0; - if (numbersOnly) { + if (noOnlys || (anynumbermodes && anytextmodes)) { + flags = EAknEditorAllInputModes; + } + else if (anynumbermodes) { flags |= EAknEditorNumericInputMode; + if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0 + && ((hints & ImhFormattedNumbersOnly) || (hints & ImhDialableCharactersOnly))) { + //workaround - the * key does not launch the symbols menu, making it impossible to use these modes unless text mode is enabled. + flags |= EAknEditorTextInputMode; + } } - if (hints & ImhUppercaseOnly || hints & ImhLowercaseOnly) { + else if (anytextmodes) { flags |= EAknEditorTextInputMode; } - if (flags == 0) { + else { flags = EAknEditorAllInputModes; } m_fepState->SetPermittedInputModes(flags); @@ -456,24 +462,33 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) if (hints & ImhNoPredictiveText || hints & ImhHiddenText) { flags |= EAknEditorFlagNoT9; } + // if alphanumeric input, or if multiple incompatible number modes are selected; + // then make all symbols available in numeric mode too. + if (!numbersOnly || ((hints & ImhFormattedNumbersOnly) && (hints & ImhDialableCharactersOnly))) + flags |= EAknEditorFlagUseSCTNumericCharmap; m_fepState->SetFlags(flags); ReportAknEdStateEvent(MAknEdStateObserver::EAknEdwinStateFlagsUpdate); - if (hints & ImhFormattedNumbersOnly) { + if (hints & ImhDialableCharactersOnly) { + // This is first, because if (ImhDialableCharactersOnly | ImhFormattedNumbersOnly) + // is specified, this one is more natural (# key enters a #) + flags = EAknEditorStandardNumberModeKeymap; + } else if (hints & ImhFormattedNumbersOnly) { + // # key enters decimal point flags = EAknEditorCalculatorNumberModeKeymap; } else if (hints & ImhDigitsOnly) { + // This is last, because it is most restrictive (# key is inactive) flags = EAknEditorPlainNumberModeKeymap; } else { - // ImhDialableCharactersOnly is the fallback as well, so we don't need to check for - // that flag. flags = EAknEditorStandardNumberModeKeymap; } m_fepState->SetNumericKeymap(static_cast<TAknEditorNumericKeymap>(flags)); - if (hints & ImhEmailCharactersOnly) { - m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_EMAIL_ADDR_SPECIAL_CHARACTER_TABLE_DIALOG); - } else if (hints & ImhUrlCharactersOnly) { + if (hints & ImhUrlCharactersOnly) { + // URL characters is everything except space, so a superset of the other restrictions m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_URL_SPECIAL_CHARACTER_TABLE_DIALOG); + } else if (hints & ImhEmailCharactersOnly) { + m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_EMAIL_ADDR_SPECIAL_CHARACTER_TABLE_DIALOG); } else { m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG); } diff --git a/tests/manual/inputmethodhints/inputmethodhints.cpp b/tests/manual/inputmethodhints/inputmethodhints.cpp new file mode 100644 index 0000000..0c00b8d --- /dev/null +++ b/tests/manual/inputmethodhints/inputmethodhints.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "inputmethodhints.h" + +inputmethodhints::inputmethodhints(QWidget *parent) + : QMainWindow(parent) +{ + ui.setupUi(this); + connect(ui.cbDialableOnly, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbDigitsOnly, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbEmailOnly, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbFormattedNumbersOnly, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbHiddenText, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbLowercaseOnly, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbNoAutoUppercase, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbNoPredictiveText, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbPreferLowercase, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbPreferNumbers, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbPreferUpperCase, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbUppercaseOnly, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbUrlOnly, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); +} + +inputmethodhints::~inputmethodhints() +{ + +} + +void inputmethodhints::checkboxChanged(int) +{ + int flags = 0; + if (ui.cbDialableOnly->isChecked()) + flags |= Qt::ImhDialableCharactersOnly; + if (ui.cbDigitsOnly->isChecked()) + flags |= Qt::ImhDigitsOnly; + if (ui.cbEmailOnly->isChecked()) + flags |= Qt::ImhEmailCharactersOnly; + if (ui.cbFormattedNumbersOnly->isChecked()) + flags |= Qt::ImhFormattedNumbersOnly; + if (ui.cbHiddenText->isChecked()) + flags |= Qt::ImhHiddenText; + if (ui.cbLowercaseOnly->isChecked()) + flags |= Qt::ImhLowercaseOnly; + if (ui.cbNoAutoUppercase->isChecked()) + flags |= Qt::ImhNoAutoUppercase; + if (ui.cbNoPredictiveText->isChecked()) + flags |= Qt::ImhNoPredictiveText; + if (ui.cbPreferLowercase->isChecked()) + flags |= Qt::ImhPreferLowercase; + if (ui.cbPreferNumbers->isChecked()) + flags |= Qt::ImhPreferNumbers; + if (ui.cbPreferUpperCase->isChecked()) + flags |= Qt::ImhPreferUppercase; + if (ui.cbUppercaseOnly->isChecked()) + flags |= Qt::ImhUppercaseOnly; + if (ui.cbUrlOnly->isChecked()) + flags |= Qt::ImhUrlCharactersOnly; + ui.lineEdit->clear(); + ui.lineEdit->setInputMethodHints(Qt::InputMethodHints(flags)); +} diff --git a/tests/manual/inputmethodhints/inputmethodhints.h b/tests/manual/inputmethodhints/inputmethodhints.h new file mode 100644 index 0000000..988a4be --- /dev/null +++ b/tests/manual/inputmethodhints/inputmethodhints.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef INPUTMETHODHINTS_H +#define INPUTMETHODHINTS_H + +#include <QtGui/QMainWindow> +#include "ui_tst_inputmethodhints.h" + +class inputmethodhints : public QMainWindow +{ + Q_OBJECT + +public: + inputmethodhints(QWidget *parent = 0); + ~inputmethodhints(); + +public slots: + void checkboxChanged(int); + +private: + Ui::MainWindow ui; +}; + +#endif // INPUTMETHODHINTS_H diff --git a/tests/manual/inputmethodhints/inputmethodhints.pro b/tests/manual/inputmethodhints/inputmethodhints.pro new file mode 100644 index 0000000..7298ec6 --- /dev/null +++ b/tests/manual/inputmethodhints/inputmethodhints.pro @@ -0,0 +1,13 @@ +TEMPLATE = app +TARGET = tst_inputmethodhints + +QT += core \ + gui + +HEADERS += inputmethodhints.h +SOURCES += main.cpp \ + inputmethodhints.cpp +FORMS += inputmethodhints.ui +RESOURCES += + +symbian:TARGET.UID3 = 0xE4938ABC diff --git a/tests/manual/inputmethodhints/inputmethodhints.ui b/tests/manual/inputmethodhints/inputmethodhints.ui new file mode 100644 index 0000000..d0dc01d --- /dev/null +++ b/tests/manual/inputmethodhints/inputmethodhints.ui @@ -0,0 +1,138 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>360</width> + <height>640</height> + </rect> + </property> + <property name="windowTitle"> + <string>MainWindow</string> + </property> + <widget class="QWidget" name="centralwidget"> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="QTabWidget" name="tabWidget"> + <property name="currentIndex"> + <number>1</number> + </property> + <widget class="QWidget" name="tab"> + <attribute name="title"> + <string>behaviour</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QCheckBox" name="cbHiddenText"> + <property name="text"> + <string>ImhHiddenText</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbNoAutoUppercase"> + <property name="text"> + <string>ImhNoAutoUppercase</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbPreferNumbers"> + <property name="text"> + <string>ImhPreferNumbers</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbPreferUpperCase"> + <property name="text"> + <string>ImhPreferUppercase</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbPreferLowercase"> + <property name="text"> + <string>ImhPreferLowercase</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbNoPredictiveText"> + <property name="text"> + <string>ImhNoPredictiveText</string> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab_2"> + <attribute name="title"> + <string>restrictions</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QCheckBox" name="cbDigitsOnly"> + <property name="text"> + <string>ImhDigitsOnly</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbFormattedNumbersOnly"> + <property name="text"> + <string>ImhFormattedNumbersOnly</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbUppercaseOnly"> + <property name="text"> + <string>ImhUppercaseOnly</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbLowercaseOnly"> + <property name="text"> + <string>ImhLowercaseOnly</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbDialableOnly"> + <property name="text"> + <string>ImhDialableCharactersOnly</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbEmailOnly"> + <property name="text"> + <string>ImhEmailCharactersOnly</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbUrlOnly"> + <property name="text"> + <string>ImhUrlCharactersOnly</string> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit"/> + </item> + </layout> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/tests/manual/inputmethodhints/main.cpp b/tests/manual/inputmethodhints/main.cpp new file mode 100644 index 0000000..022bf3f --- /dev/null +++ b/tests/manual/inputmethodhints/main.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "inputmethodhints.h" + +#include <QtGui> +#include <QApplication> + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + inputmethodhints w; + w.showMaximized(); + return a.exec(); +} |