src/hbcore/inputfw/hbinputmethod.cpp
changeset 7 923ff622b8b9
parent 6 c3690ec91ef8
child 21 4633027730f5
child 34 ed14f46c0e55
equal deleted inserted replaced
6:c3690ec91ef8 7:923ff622b8b9
   117 
   117 
   118 Say that we have implemented touch input methods for 12 key portrait mode and qwerty landscape mode.
   118 Say that we have implemented touch input methods for 12 key portrait mode and qwerty landscape mode.
   119 Then we have Chinese touch input method for both portrait and landscape orientations and also
   119 Then we have Chinese touch input method for both portrait and landscape orientations and also
   120 Chinese handwriting recognition input mode for portrait mode.
   120 Chinese handwriting recognition input mode for portrait mode.
   121 
   121 
   122 Touch input methods resolve to language range, which means that they will be handle all
   122 Touch input methods resolve to language range, which means that they will handle all
   123 the other languages, except Chinese, which has its own designated input method.
   123 the other languages, except Chinese, which has its own designated input method.
   124 
   124 
   125 Touch input methods also implement support for numeric mode. Because Chinese language uses
   125 Touch input methods also implement support for numeric mode. Because Chinese language uses
   126 same numeric system as "latin" based languages, we only want to implement numeric mode
   126 same numeric system as "latin" based languages, we only want to implement numeric mode
   127 handling in one input method and arrange resolving parameters so that the numeric mode
   127 handling in one input method and arrange resolving parameters so that the numeric mode
   235     // active.
   235     // active.
   236     return HbInputModeCache::instance()->activeMethod();
   236     return HbInputModeCache::instance()->activeMethod();
   237 }
   237 }
   238 
   238 
   239 /*!
   239 /*!
   240 Lists custom input methods.
   240 Lists all custom input methods.
   241 */
   241 */
   242 QList<HbInputMethodDescriptor> HbInputMethod::listCustomInputMethods()
   242 QList<HbInputMethodDescriptor> HbInputMethod::listCustomInputMethods()
   243 {
   243 {
   244     return HbInputModeCache::instance()->listCustomInputMethods();
   244     return HbInputModeCache::instance()->listCustomInputMethods();
       
   245 }
       
   246 
       
   247 /*!
       
   248 Lists custom input methods for given parameters.
       
   249 */
       
   250 QList<HbInputMethodDescriptor> HbInputMethod::listCustomInputMethods(Qt::Orientation orientation, const HbInputLanguage &language)
       
   251 {
       
   252     return HbInputModeCache::instance()->listCustomInputMethods(orientation, language);
       
   253 }
       
   254 
       
   255 /*!
       
   256 Returns default input method for given orientation.
       
   257 */
       
   258 HbInputMethodDescriptor HbInputMethod::defaultInputMethod(Qt::Orientation orientation)
       
   259 {
       
   260     return HbInputModeCache::instance()->defaultInputMethod(orientation);
   245 }
   261 }
   246 
   262 
   247 /*!
   263 /*!
   248 Activates given input method. Returns false if input method was not found
   264 Activates given input method. Returns false if input method was not found
   249 or the framework was not able to activate it.
   265 or the framework was not able to activate it.
   256         if (inputMethod.isDefault()) {
   272         if (inputMethod.isDefault()) {
   257             d->setFocusCommon();
   273             d->setFocusCommon();
   258             return true;
   274             return true;
   259         } else {
   275         } else {
   260             HbInputMethod *customMethod = HbInputModeCache::instance()->loadInputMethod(inputMethod);
   276             HbInputMethod *customMethod = HbInputModeCache::instance()->loadInputMethod(inputMethod);
   261             if (customMethod) {
   277             if (customMethod && HbInputModeCache::instance()->acceptsState(customMethod, d->mInputState)) {
   262                 d->contextSwitch(customMethod);
   278                 d->contextSwitch(customMethod);
   263                 return true;
   279                 return true;
   264             }
   280             }
   265         }
   281         }
   266     }
   282     }
   383 
   399 
   384     if (d->mFocusLocked) {
   400     if (d->mFocusLocked) {
   385         return;
   401         return;
   386     }
   402     }
   387 
   403 
   388     // attach focuswidget to prxoy inputcontext as proxy is
       
   389     // the only inputcotext known to qt framework.
       
   390     d->proxy()->QInputContext::setFocusWidget(widget);
       
   391 
       
   392     if (!widget) {
   404     if (!widget) {
       
   405         bool unfocus = true;
       
   406 
       
   407         if (d->mFocusObject) {
       
   408             // If the input focus is inside HbGraphicsScene then do not unfocus automatically.
       
   409             if (d->ignoreFrameworkFocusRelease(d->mFocusObject->object())) {
       
   410                 unfocus = false;
       
   411             }
       
   412         }
       
   413 
   393         // Losing focus.
   414         // Losing focus.
   394         if (d->mFocusObject) {
   415         if (d->mFocusObject && unfocus) {
   395             focusLost(false);
   416             focusLost(false);
   396             d->hideMainWindow();
   417             d->hideMainWindow();
   397             delete d->mFocusObject;
   418             delete d->mFocusObject;
   398             d->mFocusObject = 0;
   419             d->mFocusObject = 0;
   399         }
   420         }
       
   421 
   400         return;
   422         return;
   401     }
   423     }
       
   424 		
       
   425     // attach focuswidget to prxoy inputcontext as proxy is 
       
   426     // the only inputcotext known to qt framework.
       
   427     d->proxy()->QInputContext::setFocusWidget(widget);
   402 
   428 
   403     QGraphicsView *gView = qobject_cast<QGraphicsView *>(widget);
   429     QGraphicsView *gView = qobject_cast<QGraphicsView *>(widget);
   404     if (gView) {
   430     if (gView) {
   405         // We don't want to focus to graphics view but the items inside the scene, so just return
   431         // We don't want to focus to graphics view but the items inside the scene, so just return
   406         return;
   432         return;
   474         delete d->mFocusObject;
   500         delete d->mFocusObject;
   475         d->mFocusObject = 0;
   501         d->mFocusObject = 0;
   476         // passing to actual QInputContext which is attached to Qt framework.
   502         // passing to actual QInputContext which is attached to Qt framework.
   477         // which will internally set QInputContext::focusWidget to Null.
   503         // which will internally set QInputContext::focusWidget to Null.
   478         d->proxy()->QInputContext::widgetDestroyed(widget);
   504         d->proxy()->QInputContext::widgetDestroyed(widget);
       
   505         d->proxy()->QInputContext::setFocusWidget(0);
   479     }
   506     }
   480 }
   507 }
   481 
   508 
   482 /*!
   509 /*!
   483 Graphics item based editors (or any other object that implements
   510 Graphics item based editors (or any other object that implements
   509         return;
   536         return;
   510     }
   537     }
   511 
   538 
   512     if (d->compareWithCurrentFocusObject(focusObject)) {
   539     if (d->compareWithCurrentFocusObject(focusObject)) {
   513         // The incoming focus object is either same or points to same
   540         // The incoming focus object is either same or points to same
   514         // widget that the framework is already focused to and nothing needs to be done here.
   541         // widget that the framework is already focused to and nothing needs to be done here.      
   515         // But because the ownership of the focus object is transferred to the
       
   516         // the framework, we need to delete the the incoming focus object in case it is
       
   517         // dirrefent than current one.
       
   518         if (d->mFocusObject != focusObject) {
       
   519             delete focusObject;
       
   520         }
       
   521         return;
   542         return;
   522     }
   543     }
   523 
   544 
   524     bool refreshHost = false;
   545     bool refreshHost = false;
   525 
   546 
   741 \sa HbInputSettingProxy
   762 \sa HbInputSettingProxy
   742 */
   763 */
   743 void HbInputMethod::orientationAboutToChange()
   764 void HbInputMethod::orientationAboutToChange()
   744 {
   765 {
   745     Q_D(HbInputMethod);
   766     Q_D(HbInputMethod);
   746     reset();
   767 	if(isActiveMethod()) {
       
   768 		reset();
       
   769 	}
   747     d->inputStateToEditor(d->mInputState);
   770     d->inputStateToEditor(d->mInputState);
   748     if (d->mFocusObject) {
   771     if (d->mFocusObject) {
   749         d->mOldFocusObject = d->mFocusObject;
   772         d->mOldFocusObject = d->mFocusObject;
   750         d->mFocusObject = 0;
   773         d->mFocusObject = 0;
   751     }
   774     }
   797 /*!
   820 /*!
   798 Removes input method focus and asks active input plugin to close its active UI-components
   821 Removes input method focus and asks active input plugin to close its active UI-components
   799 (such as touch keypads). This may be needed in some special cases where the underlying
   822 (such as touch keypads). This may be needed in some special cases where the underlying
   800 application wants to make sure that there are no input related elements on the screen.
   823 application wants to make sure that there are no input related elements on the screen.
   801 
   824 
   802 This is a if-all-else fails backup method. Same can be done (more efficiently) by doing
   825 This is a if-all-else fails backup method. Same can be done by doing
   803 following.
   826 following.
   804 
   827 
   805 \code
   828 \code
   806 QInputContext* inputContext = qApp->inputContext();
   829 QInputContext* ic = qApp->inputContext();
   807 if (inputContext) {
   830 if (ic) {
   808     inputContext->setFocusWidget(0);
   831     QEvent *closeEvent = new QEvent(QEvent::CloseSoftwareInputPanel);
       
   832     ic->filterEvent(closeEvent);
       
   833     delete closeEvent;
   809 }
   834 }
   810 \endcode
   835 \endcode
   811 */
   836 */
   812 void HbInputMethod::forceUnfocus()
   837 void HbInputMethod::forceUnfocus()
   813 {
   838 {