src/hbinput/inputwidgets/hbinputsctkeyboard.cpp
changeset 23 e6ad4ef83b23
parent 21 4633027730f5
child 28 b7da29130b0e
equal deleted inserted replaced
21:4633027730f5 23:e6ad4ef83b23
    32 #include <hbinputmethod.h>
    32 #include <hbinputmethod.h>
    33 #include <hbinputkeymap.h>
    33 #include <hbinputkeymap.h>
    34 #include <hbinpututils.h>
    34 #include <hbinpututils.h>
    35 #include <hbframedrawer.h>
    35 #include <hbframedrawer.h>
    36 #include <hbinputsettingproxy.h>
    36 #include <hbinputsettingproxy.h>
       
    37 #include <hbmainwindow.h>
    37 
    38 
    38 #include "hbinputbuttongroup.h"
    39 #include "hbinputbuttongroup.h"
    39 #include "hbinputbutton.h"
    40 #include "hbinputbutton.h"
    40 
    41 
    41 const qreal HbPortraitKeyboardHeightInUnits = 45.9;
    42 const qreal HbPortraitKeyboardHeightInUnits = 45.9;
   154 {
   155 {
   155     Q_Q(HbSctKeyboard);
   156     Q_Q(HbSctKeyboard);
   156 
   157 
   157     HbInputVkbWidgetPrivate::init();
   158     HbInputVkbWidgetPrivate::init();
   158 
   159 
   159     if (HbInputSettingProxy::instance()->activeKeyboard() & HbQwertyKeyboardMask) {
   160     Qt::Orientation orientation = Qt::Horizontal;
       
   161     if (q->mainWindow()) {
       
   162         orientation = q->mainWindow()->orientation();
       
   163     }
       
   164 
       
   165     if (HbInputSettingProxy::instance()->activeKeyboard(orientation) & HbQwertyKeyboardMask) {
   160         mType = HbKeyboardSctLandscape;
   166         mType = HbKeyboardSctLandscape;
   161     } else {
   167     } else {
   162         mType = HbKeyboardSctPortrait;
   168         mType = HbKeyboardSctPortrait;
   163     }
   169     }
   164 
   170 
   191                 // Portrait SCT has different delete icon from the default one
   197                 // Portrait SCT has different delete icon from the default one
   192                 item->setIcon(HbIcon(HbInputButtonIconDelete2), HbInputButton::ButtonIconIndexPrimary);
   198                 item->setIcon(HbIcon(HbInputButtonIconDelete2), HbInputButton::ButtonIconIndexPrimary);
   193             } else if (keyCode(i) == HbInputButton::ButtonKeyCodeAlphabet) {
   199             } else if (keyCode(i) == HbInputButton::ButtonKeyCodeAlphabet) {
   194                 // Button that is used to return to normal keypad should be shown as latched
   200                 // Button that is used to return to normal keypad should be shown as latched
   195                 item->setState(HbInputButton::ButtonStateLatched);
   201                 item->setState(HbInputButton::ButtonStateLatched);
   196 				if (mType == HbKeyboardSctPortrait || mType == HbKeyboardSctEmail || mType == HbKeyboardSctUrl ) {
   202                 if (mType == HbKeyboardSctPortrait || mType == HbKeyboardSctEmail || mType == HbKeyboardSctUrl ) {
   197                     // Portrait SCT has different symbol icon from the default one
   203                     // Portrait SCT has different symbol icon from the default one
   198                     item->setIcon(HbIcon(HbInputButtonIconSymbol2), HbInputButton::ButtonIconIndexPrimary);
   204                     item->setIcon(HbIcon(HbInputButtonIconSymbol2), HbInputButton::ButtonIconIndexPrimary);
   199                 }
   205                 }
   200             }
   206             }
   201             ++key;
   207             ++key;
   273 }
   279 }
   274 
   280 
   275 void HbSctKeyboardPrivate::updateKeyCodes()
   281 void HbSctKeyboardPrivate::updateKeyCodes()
   276 {
   282 {
   277     Q_Q(HbSctKeyboard);
   283     Q_Q(HbSctKeyboard);
       
   284 
   278     HbInputFocusObject *focusedObject = mOwner->focusObject();
   285     HbInputFocusObject *focusedObject = mOwner->focusObject();
   279     if (!focusedObject) {
   286     if (!focusedObject) {
   280         return;
   287         return;
   281     }
   288     }
   282 
   289 
   283     if (HbInputSettingProxy::instance()->activeKeyboard() & HbQwertyKeyboardMask){
   290     Qt::Orientation orientation = Qt::Horizontal;
       
   291     if (q->mainWindow()) {
       
   292         orientation = q->mainWindow()->orientation();
       
   293     }
       
   294 
       
   295     if (HbInputSettingProxy::instance()->activeKeyboard(orientation) & HbQwertyKeyboardMask){
   284         mType = HbKeyboardSctLandscape;
   296         mType = HbKeyboardSctLandscape;
   285     } else if (focusedObject && focusedObject->editorInterface().editorClass() == HbInputEditorClassEmail) {
   297     } else if (focusedObject && focusedObject->editorInterface().editorClass() == HbInputEditorClassEmail &&
       
   298                mKeymap->keyboard(HbKeyboardSctEmail)) {
   286         mType = HbKeyboardSctEmail;
   299         mType = HbKeyboardSctEmail;
   287     } else if (focusedObject && focusedObject->editorInterface().editorClass() == HbInputEditorClassUrl) {
   300     } else if (focusedObject && focusedObject->editorInterface().editorClass() == HbInputEditorClassUrl &&
       
   301                mKeymap->keyboard(HbKeyboardSctUrl)) {
   288         mType = HbKeyboardSctUrl;
   302         mType = HbKeyboardSctUrl;
   289     } else {
   303     } else {
   290         mType = HbKeyboardSctPortrait;
   304         mType = HbKeyboardSctPortrait;
   291     }
   305     }
   292     
   306     
   307                 HbInputButton *item = buttons.at(i);
   321                 HbInputButton *item = buttons.at(i);
   308 
   322 
   309                 if (keyboardMap && key < keyboardMap->keys.count()) {
   323                 if (keyboardMap && key < keyboardMap->keys.count()) {
   310                     // Replace space and enter markers with correct keycodes
   324                     // Replace space and enter markers with correct keycodes
   311                     if (focusedObject->characterAllowedInEditor(keyboardMap->keys.at(key)->characters(HbModifierNone).at(0)) || mType == HbKeyboardSctLandscape){
   325                     if (focusedObject->characterAllowedInEditor(keyboardMap->keys.at(key)->characters(HbModifierNone).at(0)) || mType == HbKeyboardSctLandscape){
   312 	                    if (keyboardMap->keys.at(key)->keycode.unicode() == HbSctSpaceMarker) {
   326                         if (keyboardMap->keys.at(key)->keycode.unicode() == HbSctSpaceMarker) {
   313     	                    item->setKeyCode(HbInputButton::ButtonKeyCodeSpace);
   327                             item->setKeyCode(HbInputButton::ButtonKeyCodeSpace);
   314         	            } else if (keyboardMap->keys.at(key)->keycode.unicode() == HbSctEnterMarker) {
   328                         } else if (keyboardMap->keys.at(key)->keycode.unicode() == HbSctEnterMarker) {
   315             	            item->setKeyCode(HbInputButton::ButtonKeyCodeEnter);
   329                             item->setKeyCode(HbInputButton::ButtonKeyCodeEnter);
   316                 	    } else {
   330                         } else {
   317                     	    item->setKeyCode(keyboardMap->keys.at(key)->keycode.unicode());
   331                             item->setKeyCode(keyboardMap->keys.at(key)->keycode.unicode());
   318                     	}
   332                         }
   319                     } else {
   333                     } else {
   320                         i--;
   334                         i--;
   321                     }
   335                     }
   322                 } else {
   336                 } else {
   323                     item->setKeyCode(-1);
   337                     item->setKeyCode(-1);
   388     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup*>(q->contentItem());    
   402     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup*>(q->contentItem());    
   389     if (buttonGroup) {
   403     if (buttonGroup) {
   390         if (keyboardMap && totalKeys < keyboardMap->keys.count()) {
   404         if (keyboardMap && totalKeys < keyboardMap->keys.count()) {
   391             while (index){
   405             while (index){
   392                 if (focusedObject->characterAllowedInEditor(keyboardMap->keys.at(totalKeys)->characters(HbModifierNone).at(0))){
   406                 if (focusedObject->characterAllowedInEditor(keyboardMap->keys.at(totalKeys)->characters(HbModifierNone).at(0))){
   393                     index--;		            
   407                     index--;                    
   394                 }
   408                 }
   395                 totalKeys++;
   409                 totalKeys++;
   396             }            
   410             }            
   397         }
   411         }
   398     }
   412     }