src/hbinput/inputwidgets/hbinputmodeindicator.cpp
changeset 6 c3690ec91ef8
parent 2 06ff229162e9
child 30 80e4d18b72f5
equal deleted inserted replaced
5:627c4a0fd0e7 6:c3690ec91ef8
    20 **
    20 **
    21 ** If you have questions regarding the use of this file, please contact
    21 ** If you have questions regarding the use of this file, please contact
    22 ** Nokia at developer.feedback@nokia.com.
    22 ** Nokia at developer.feedback@nokia.com.
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
       
    25 #include <hbinputmodeindicator.h>
    25 
    26 
    26 #include <QPainter>
    27 #include <QPainter>
    27 #include <QPointer>
    28 #include <QPointer>
    28 #include <hbicon.h>
    29 #include <hbicon.h>
    29 #include <hbinputmethod.h>
    30 #include <hbinputmethod.h>
    30 #include <hbinputeditorinterface.h>
    31 #include <hbinputeditorinterface.h>
    31 #include <hbinputmodeindicator.h>
       
    32 #include <hbinputfocusobject.h>
    32 #include <hbinputfocusobject.h>
    33 #include <hbinputsettingproxy.h>
    33 #include <hbinputsettingproxy.h>
    34 
    34 
    35 /// @cond
    35 /// @cond
    36 
    36 
    37 class HbInputModeIndicatorPrivate
    37 class HbInputModeIndicatorPrivate
    38 {
    38 {
    39 public:   
    39 public:
    40     HbInputModeIndicatorPrivate(HbInputButton *button);
    40     HbInputModeIndicatorPrivate(HbInputButton *button);
    41     ~HbInputModeIndicatorPrivate();
    41     ~HbInputModeIndicatorPrivate();
    42 
    42 
    43     void updatePrediction();
    43     void updatePrediction();
    44 
    44 
    45 public:  
    45 public:
    46     HbInputButton *mButtonItem;
    46     HbInputButton *mButtonItem;
    47     QPointer<HbInputFocusObject> mFocusObject;
    47     QPointer<HbInputFocusObject> mFocusObject;
    48 };
    48 };
    49 
    49 
    50 HbInputModeIndicatorPrivate::HbInputModeIndicatorPrivate(HbInputButton *button)
    50 HbInputModeIndicatorPrivate::HbInputModeIndicatorPrivate(HbInputButton *button)
    51  : mButtonItem(button), mFocusObject(0)
    51     : mButtonItem(button), mFocusObject(0)
    52 {
    52 {
    53     if (HbInputMethod::activeInputMethod()) {
    53     if (HbInputMethod::activeInputMethod()) {
    54         mFocusObject = HbInputMethod::activeInputMethod()->focusObject();
    54         mFocusObject = HbInputMethod::activeInputMethod()->focusObject();
    55     }
    55     }
    56 }
    56 }
    70     }
    70     }
    71     HbIcon icon;
    71     HbIcon icon;
    72     if (HbInputSettingProxy::instance()->predictiveInputStatusForActiveKeyboard() &&
    72     if (HbInputSettingProxy::instance()->predictiveInputStatusForActiveKeyboard() &&
    73         mFocusObject && mFocusObject->editorInterface().isPredictionAllowed()) {
    73         mFocusObject && mFocusObject->editorInterface().isPredictionAllowed()) {
    74         icon = HbIcon(predictionOnIcon);
    74         icon = HbIcon(predictionOnIcon);
    75      } else {
    75     } else {
    76         icon = HbIcon(predictionOffIcon);
    76         icon = HbIcon(predictionOffIcon);
    77     }
    77     }
    78     icon.setColor(color);
    78     icon.setColor(color);
    79     if (mButtonItem) {
    79     if (mButtonItem) {
    80         mButtonItem->setIcon(icon, HbInputButton::ButtonIconIndexPrimary);
    80         mButtonItem->setIcon(icon, HbInputButton::ButtonIconIndexPrimary);
    97 HbInputModeIndicator::HbInputModeIndicator(HbInputButton *button, QGraphicsWidget *parent)
    97 HbInputModeIndicator::HbInputModeIndicator(HbInputButton *button, QGraphicsWidget *parent)
    98     : QObject(parent)
    98     : QObject(parent)
    99 {
    99 {
   100     mPrivate = new HbInputModeIndicatorPrivate(button);
   100     mPrivate = new HbInputModeIndicatorPrivate(button);
   101     if (mPrivate->mFocusObject) {
   101     if (mPrivate->mFocusObject) {
   102         connect (&mPrivate->mFocusObject->editorInterface(), SIGNAL(modified()), this, SLOT(updateIndicator()));
   102         connect(&mPrivate->mFocusObject->editorInterface(), SIGNAL(modified()), this, SLOT(updateIndicator()));
   103     }
   103     }
   104     connect(HbInputSettingProxy::instance(), SIGNAL(predictiveInputStateChanged(HbKeyboardSettingFlags, bool)),
   104     connect(HbInputSettingProxy::instance(), SIGNAL(predictiveInputStateChanged(HbKeyboardSettingFlags, bool)),
   105             this, SLOT(updatePredictionStatus(HbKeyboardSettingFlags, bool)));
   105             this, SLOT(updatePredictionStatus(HbKeyboardSettingFlags, bool)));
   106     updateIndicator(); // check mode of current editor
   106     updateIndicator(); // check mode of current editor
   107 }
   107 }
   121 {
   121 {
   122     if (!mPrivate->mFocusObject) {
   122     if (!mPrivate->mFocusObject) {
   123         if (HbInputMethod::activeInputMethod()) {
   123         if (HbInputMethod::activeInputMethod()) {
   124             mPrivate->mFocusObject = HbInputMethod::activeInputMethod()->focusObject();
   124             mPrivate->mFocusObject = HbInputMethod::activeInputMethod()->focusObject();
   125             if (mPrivate->mFocusObject) {
   125             if (mPrivate->mFocusObject) {
   126                 connect( &mPrivate->mFocusObject->editorInterface(), SIGNAL(modified()), this, SLOT(updateIndicator()));
   126                 connect(&mPrivate->mFocusObject->editorInterface(), SIGNAL(modified()), this, SLOT(updateIndicator()));
   127             } else {
   127             } else {
   128                 return;
   128                 return;
   129             }
   129             }
   130         } else {
   130         } else {
   131             return;
   131             return;