src/hbinput/inputwidgets/hbinputhwtoolcluster.cpp
changeset 2 06ff229162e9
parent 1 f7ac710697a9
child 6 c3690ec91ef8
equal deleted inserted replaced
1:f7ac710697a9 2:06ff229162e9
    35 #include <hbview.h>
    35 #include <hbview.h>
    36 #include <hbdataform.h>
    36 #include <hbdataform.h>
    37 
    37 
    38 #include "hbinputvkbwidget_p.h"
    38 #include "hbinputvkbwidget_p.h"
    39 #include "hbinputhwtoolcluster.h"
    39 #include "hbinputhwtoolcluster.h"
    40 #include "hbinputtouchkeypadbutton.h"
       
    41 #include "hbinputmodeindicator.h"
    40 #include "hbinputmodeindicator.h"
    42 
    41 
    43 const QString HbCustomButtonObjName = "Mini VKB custom button ";
    42 const QString HbCustomButtonObjName = "Mini VKB custom button ";
    44 
    43 
    45 const int HbMiniVirtualKeypadNumberOfColumn = 5;
    44 const int HbMiniVirtualKeypadNumberOfColumn = 5;
    65 
    64 
    66 public:
    65 public:
    67     HbHwToolClusterPrivate();
    66     HbHwToolClusterPrivate();
    68     ~HbHwToolClusterPrivate();
    67     ~HbHwToolClusterPrivate();
    69 public:
    68 public:
    70     HbTouchKeypadButton *mLanguageButton;
       
    71     HbTouchKeypadButton *mInputMethodButton;
       
    72     HbTouchKeypadButton *mPredictionIndicatorButton;
       
    73 };
    69 };
    74 
    70 
    75 HbHwToolClusterPrivate::HbHwToolClusterPrivate() : mLanguageButton(0),
    71 HbHwToolClusterPrivate::HbHwToolClusterPrivate()
    76                 mInputMethodButton(0),
       
    77                 mPredictionIndicatorButton(0)
       
    78 {
    72 {
    79 }
    73 }
    80 
    74 
    81 HbHwToolClusterPrivate::~HbHwToolClusterPrivate()
    75 HbHwToolClusterPrivate::~HbHwToolClusterPrivate()
    82 {
    76 {
   102 /*!
    96 /*!
   103 Creates the layout of the mini touch keypad for hardware qwerty.
    97 Creates the layout of the mini touch keypad for hardware qwerty.
   104 */
    98 */
   105 void HbHwToolCluster::createLayout()
    99 void HbHwToolCluster::createLayout()
   106 {
   100 {
   107     setupToolCluster();
       
   108 
       
   109     Q_D(HbHwToolCluster);
       
   110     // The layout is already created. So just return.
       
   111     if ( d->mButtonLayout ) {
       
   112         return;
       
   113     }
       
   114 
       
   115     d->mButtonLayout = new QGraphicsGridLayout();
       
   116     setContentsMargins(0.0, 0.0, 0.0, 0.0);
       
   117     d->mButtonLayout->setContentsMargins(0.0, 0.0, 0.0, 0.0);
       
   118     d->mButtonLayout->setHorizontalSpacing(HorizontalSpacing);
       
   119     d->mButtonLayout->setVerticalSpacing(VerticalSpacing);
       
   120     d->mButtonLayout->addItem(d->mSettingsButton, 0, 0);   // Settings key
       
   121     d->mButtonLayout->addItem(d->mLanguageButton, 0, 1);   // language selection
       
   122     d->mButtonLayout->addItem(d->mPredictionIndicatorButton, 0, 2);   // prediction indicator
       
   123     d->mButtonLayout->addItem(d->mInputMethodButton, 0, 3);   //input method selection key
       
   124     d->mButtonLayout->addItem(d->mApplicationButton, 0, 4);   // Application specific key
       
   125 
       
   126     d->mSettingsButton->setObjectName( HbCustomButtonObjName + QString::number(1));
       
   127     d->mApplicationButton->setObjectName( HbCustomButtonObjName + QString::number(2));
       
   128     d->mLanguageButton->setObjectName( HbCustomButtonObjName + QString::number(3));
       
   129     d->mInputMethodButton->setObjectName( HbCustomButtonObjName + QString::number(4));
       
   130     d->mPredictionIndicatorButton->setObjectName( HbCustomButtonObjName + QString::number(5));
       
   131 
       
   132     connect(d->mInputMethodButton, SIGNAL(clicked()), this, SLOT(showMethodDialog()));
       
   133     connect(d->mLanguageButton, SIGNAL(clicked()), this, SLOT(showLanguageDialog()));
       
   134     connect(d->mPredictionIndicatorButton, SIGNAL(clicked()), HbInputSettingProxy::instance(), SLOT(togglePrediction()));
       
   135 }
   101 }
   136 
   102 
   137 
   103 
   138 /*!
   104 /*!
   139 Creates the tools cluster for mini VKB layout.
   105 Creates the tools cluster for mini VKB layout.
   140 */
   106 */
   141 void HbHwToolCluster::setupToolCluster()
   107 void HbHwToolCluster::setupToolCluster()
   142 {
   108 {
   143     Q_D(HbHwToolCluster);
       
   144     if(!d->mOwner || !d->mOwner->focusObject()) {
       
   145         return;
       
   146     }
       
   147 
       
   148     // Create buttons if they do not exist
       
   149     if (!d->mSettingsButton) {
       
   150         d->mSettingsButton = new HbTouchKeypadButton(this, QString(""));
       
   151         d->mSettingsButton->setIcon(HbIcon(settingsIcon));
       
   152         d->mSettingsButton->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction);
       
   153         d->mSettingsButton->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased);
       
   154 
       
   155         connect(d->mSettingsButton, SIGNAL(clicked()), this, SLOT(showSettingList()));
       
   156     }
       
   157     if(!d->mLanguageButton) {
       
   158         d->mLanguageButton = new HbTouchKeypadButton(this, QString(""));
       
   159         d->mLanguageButton->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction);
       
   160         d->mLanguageButton->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased);
       
   161     }
       
   162 
       
   163     if(!d->mInputMethodButton) {
       
   164         d->mInputMethodButton = new HbTouchKeypadButton(this, QString(""));
       
   165         d->mInputMethodButton->setIcon(HbIcon(inputMethodIcon));
       
   166         d->mInputMethodButton->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction);
       
   167         d->mInputMethodButton->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased);
       
   168     }
       
   169 
       
   170     if(!d->mPredictionIndicatorButton) {
       
   171         d->mPredictionIndicatorButton = new HbTouchKeypadButton(this, QString(""));
       
   172         d->mPredictionIndicatorButton->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction);
       
   173         d->mPredictionIndicatorButton->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased);
       
   174         d->mInputModeIndicator = new HbInputModeIndicator(*d->mPredictionIndicatorButton, this);
       
   175     } else {
       
   176         d->mInputModeIndicator->updateIndicator();
       
   177     }
       
   178 
       
   179     if(d->mLanguageButton) {
       
   180         // update language button text
       
   181         QString langName = HbInputSettingProxy::instance()->globalInputLanguage().localisedName();
       
   182         langName.truncate(3);
       
   183         d->mLanguageButton->setText(langName);
       
   184     }
       
   185 
       
   186     // update prediction button status
       
   187     if (HbInputSettingProxy::instance()->predictiveInputStatusForActiveKeyboard()) {
       
   188         d->mPredictionIndicatorButton->setIcon(HbIcon(predictionOffIcon));
       
   189     } else {
       
   190         d->mPredictionIndicatorButton->setIcon(HbIcon(predictionOnIcon));
       
   191     }
       
   192 
       
   193     // If there's a application specific button defined, create new button with the properties
       
   194     // or update the existing one. Otherwise create an empty button or clean the properties of an existing one.
       
   195     if (!d->mOwner->focusObject()->editorInterface().actions().isEmpty()) {
       
   196         QList<HbAction*> actions = d->mOwner->focusObject()->editorInterface().actions();
       
   197         if (d->mApplicationButton) {
       
   198             d->mApplicationButton->setText(actions.first()->text());
       
   199             d->mApplicationButton->disconnect(SIGNAL(clicked()));
       
   200         } else {
       
   201             d->mApplicationButton = new HbTouchKeypadButton(this, actions.first()->text());
       
   202             d->mApplicationButton->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction);
       
   203             d->mApplicationButton->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased);
       
   204         }
       
   205         connect(d->mApplicationButton, SIGNAL(clicked()), actions.first(), SLOT(trigger()));
       
   206         d->mApplicationButton->setIcon(actions.first()->icon());
       
   207         d->mApplicationButton->setToolTip(actions.first()->toolTip());
       
   208     } else {
       
   209         if (d->mApplicationButton) {
       
   210             d->mApplicationButton->disconnect(SIGNAL(clicked()));
       
   211             d->mApplicationButton->setText(QString());
       
   212             d->mApplicationButton->setIcon(HbIcon());
       
   213             d->mApplicationButton->setToolTip(QString());
       
   214         } else {
       
   215             d->mApplicationButton = new HbTouchKeypadButton(this, QString());
       
   216             d->mApplicationButton->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction);
       
   217             d->mApplicationButton->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased);
       
   218         }
       
   219     }
       
   220 }
   109 }
   221 
   110 
   222 /*!
   111 /*!
   223 Returns keyboard type.
   112 Returns keyboard type.
   224 */
   113 */
   274 
   163 
   275     return ret;
   164     return ret;
   276 }
   165 }
   277 
   166 
   278 /*!
   167 /*!
   279 \deprecated HbHwToolCluster::showSettingsDialog()
       
   280     is deprecated. Use showSettingsView instead.
       
   281 
       
   282 Shows the settings dialog
       
   283 */
       
   284 void HbHwToolCluster::showSettingsDialog()
       
   285 {
       
   286 }
       
   287 
       
   288 /*!
       
   289 Shows the input method selection dialog.
   168 Shows the input method selection dialog.
   290 */
   169 */
   291 void HbHwToolCluster::showMethodDialog()
   170 void HbHwToolCluster::showMethodDialog()
   292 {
   171 {
   293     Q_D(HbHwToolCluster);
   172     Q_D(HbHwToolCluster);