src/hbcore/inputfw/hbinputmodecache.cpp
changeset 7 923ff622b8b9
parent 6 c3690ec91ef8
child 21 4633027730f5
child 34 ed14f46c0e55
equal deleted inserted replaced
6:c3690ec91ef8 7:923ff622b8b9
    31 #include <QPluginLoader>
    31 #include <QPluginLoader>
    32 #include <QDir>
    32 #include <QDir>
    33 
    33 
    34 #include "hbinpututils.h"
    34 #include "hbinpututils.h"
    35 #include "hbinputmethod.h"
    35 #include "hbinputmethod.h"
       
    36 #include "hbinputcontextplugin.h"
    36 #include "hbinputsettingproxy.h"
    37 #include "hbinputsettingproxy.h"
    37 #include "hbinputmodeproperties.h"
    38 #include "hbinputmodeproperties.h"
    38 #include "hbinputkeymapfactory.h"
    39 #include "hbinputkeymapfactory.h"
    39 #include "hbinputmethod_p.h"
    40 #include "hbinputmethod_p.h"
    40 #include "hbinputmethodnull_p.h"
    41 #include "hbinputmethodnull_p.h"
   148                 // If not, then add one.
   149                 // If not, then add one.
   149                 QStringList contextKeys = inputContextPlugin->keys();
   150                 QStringList contextKeys = inputContextPlugin->keys();
   150                 foreach(const QString &key, contextKeys) {
   151                 foreach(const QString &key, contextKeys) {
   151                     listItem.descriptor.setKey(key);
   152                     listItem.descriptor.setKey(key);
   152                     listItem.descriptor.setDisplayName(inputContextPlugin->displayName(key));
   153                     listItem.descriptor.setDisplayName(inputContextPlugin->displayName(key));
       
   154 
       
   155                     HbInputContextPlugin *extension = qobject_cast<HbInputContextPlugin *>(inputContextPlugin);
       
   156                     if (extension) {
       
   157                         listItem.descriptor.setDisplayNames(extension->displayNames(key));
       
   158                         listItem.descriptor.setIcon(extension->icon(key));
       
   159                         listItem.descriptor.setIcons(extension->icons(key));
       
   160                     }
   153 
   161 
   154                     int index = mMethods.indexOf(listItem);
   162                     int index = mMethods.indexOf(listItem);
   155                     if (index >= 0) {
   163                     if (index >= 0) {
   156                         // The method is already in the list, the situation hasn't changed.
   164                         // The method is already in the list, the situation hasn't changed.
   157                         // just tag it not to be removed.
   165                         // just tag it not to be removed.
   362     return 0;
   370     return 0;
   363 }
   371 }
   364 
   372 
   365 /*!
   373 /*!
   366 \internal
   374 \internal
   367 Lists custom input methods.
   375 Lists all custom input methods.
   368 */
   376 */
   369 QList<HbInputMethodDescriptor> HbInputModeCache::listCustomInputMethods()
   377 QList<HbInputMethodDescriptor> HbInputModeCache::listCustomInputMethods()
   370 {
   378 {
   371     Q_D(HbInputModeCache);
   379     Q_D(HbInputModeCache);
   372 
   380 
   375     foreach(const HbInputMethodListItem &item, d->mMethods) {
   383     foreach(const HbInputMethodListItem &item, d->mMethods) {
   376         foreach(const QString &language, item.languages) {
   384         foreach(const QString &language, item.languages) {
   377             HbInputModeProperties properties = d->propertiesFromString(language);
   385             HbInputModeProperties properties = d->propertiesFromString(language);
   378             if (properties.inputMode() == HbInputModeCustom) {
   386             if (properties.inputMode() == HbInputModeCustom) {
   379                 result.append(item.descriptor);
   387                 result.append(item.descriptor);
       
   388                 break;
       
   389             }
       
   390         }
       
   391     }
       
   392 
       
   393     return result;
       
   394 }
       
   395 
       
   396 /*!
       
   397 \internal
       
   398 Lists custom input methods for given parameters.
       
   399 */
       
   400 QList<HbInputMethodDescriptor> HbInputModeCache::listCustomInputMethods(Qt::Orientation orientation, const HbInputLanguage &language)
       
   401 {
       
   402     Q_D(HbInputModeCache);
       
   403 
       
   404     QList<HbInputMethodDescriptor> result;
       
   405 
       
   406     foreach (const HbInputMethodListItem &item, d->mMethods) {
       
   407         foreach (const QString &lang, item.languages) {
       
   408             HbInputModeProperties properties = d->propertiesFromString(lang);
       
   409             
       
   410             // Find custom methods that supports given language or any language and
       
   411             // supports given orientation
       
   412             if (properties.inputMode() == HbInputModeCustom &&
       
   413                 (properties.language() == language || properties.language() == HbInputLanguage()) &&
       
   414                 ((orientation == Qt::Vertical && properties.keyboard() == HbKeyboardTouchPortrait) ||
       
   415                 (orientation == Qt::Horizontal && properties.keyboard() == HbKeyboardTouchLandscape))) {
       
   416                 result.append(item.descriptor);
       
   417                 break;
       
   418             }
       
   419         }
       
   420     }
       
   421 
       
   422     return result;
       
   423 }
       
   424 
       
   425 /*!
       
   426 \internal
       
   427 Returns default input method for given orientation.
       
   428 */
       
   429 HbInputMethodDescriptor HbInputModeCache::defaultInputMethod(Qt::Orientation orientation)
       
   430 {
       
   431     Q_D(HbInputModeCache);
       
   432 
       
   433     HbInputMethodDescriptor result;
       
   434     foreach (const HbInputMethodListItem &item, d->mMethods) {
       
   435         foreach (const QString &language, item.languages) {
       
   436             HbInputModeProperties properties = d->propertiesFromString(language);
       
   437 
       
   438             // Find default method that supports given orientation
       
   439             if (properties.inputMode() == HbInputModeDefault &&
       
   440                 ((orientation == Qt::Vertical && properties.keyboard() == HbKeyboardTouchPortrait) ||
       
   441                 (orientation == Qt::Horizontal && properties.keyboard() == HbKeyboardTouchLandscape))) {
       
   442                 result = item.descriptor;
   380                 break;
   443                 break;
   381             }
   444             }
   382         }
   445         }
   383     }
   446     }
   384 
   447