src/hbplugins/inputmethods/hardwareinput/hbhardwareinputbasicqwertyhandler.cpp
changeset 34 ed14f46c0e55
parent 6 c3690ec91ef8
equal deleted inserted replaced
31:7516d6d86cf5 34:ed14f46c0e55
    61 {
    61 {
    62 }
    62 }
    63 
    63 
    64 bool HbHardwareInputBasicQwertyHandlerPrivate::buttonPressed(const QKeyEvent * event)
    64 bool HbHardwareInputBasicQwertyHandlerPrivate::buttonPressed(const QKeyEvent * event)
    65 {
    65 {
    66 	mButton = event->key();
    66     mButton = event->key();
    67 	if (!mTimer->isActive()){
    67     if (!mTimer->isActive()){
    68 		mTimer->start(HbLongPressTimerTimeout);
    68         mTimer->start(HbLongPressTimerTimeout);
    69 	}
    69     }
    70 
    70 
    71 	if (event->key() != Qt::Key_Delete && event->key() != Qt::Key_Backspace) {
    71     if (event->key() != Qt::Key_Delete && event->key() != Qt::Key_Backspace) {
    72 		return true;
    72         return true;
    73 	} else {
    73     } else {
    74 		return false;
    74         return false;
    75 	}
    75     }
    76 }
    76 }
    77 
    77 
    78 bool HbHardwareInputBasicQwertyHandlerPrivate::buttonReleased(const QKeyEvent * event)
    78 bool HbHardwareInputBasicQwertyHandlerPrivate::buttonReleased(const QKeyEvent * event)
    79 {
    79 {
    80 // Kept for handling button released specific logic
    80 // Kept for handling button released specific logic
    81 	
    81     
    82 	Q_Q(HbHardwareInputBasicQwertyHandler);
    82     Q_Q(HbHardwareInputBasicQwertyHandler);
    83 	HbInputFocusObject *focusObject = 0;
    83     HbInputFocusObject *focusObject = 0;
    84     focusObject = mInputMethod->focusObject();
    84     focusObject = mInputMethod->focusObject();
    85     if (!focusObject) {
    85     if (!focusObject) {
    86         qDebug("HbHardwareInputBasicQwertyHandler::virtualButtonClicked : no focused editor widget!");
    86         qDebug("HbHardwareInputBasicQwertyHandler::virtualButtonClicked : no focused editor widget!");
    87         return false;
    87         return false;
    88     }
    88     }
    89 	
    89     
    90 	// If the timer is not active and it is alpha mode, it is a long press
    90     // If the timer is not active and it is alpha mode, it is a long press
    91     // and handled in another function. So just return.
    91     // and handled in another function. So just return.
    92     if (mTimer->isActive()) {
    92     if (mTimer->isActive()) {
    93         mTimer->stop();
    93         mTimer->stop();
    94     }
    94     }
    95 	int eventKey = event->key();
    95     int eventKey = event->key();
    96 
    96 
    97 	//Handle long key press here
    97     //Handle long key press here
    98    
    98    
    99     switch(eventKey) {
    99     switch(eventKey) {
   100     case Qt::Key_Alt:
   100     case Qt::Key_Alt:
   101 		//handle function key (fn key) states here using fn & shift handler helper class
   101         //handle function key (fn key) states here using fn & shift handler helper class
   102 		break;
   102         break;
   103     case Qt::Key_Shift: {
   103     case Qt::Key_Shift: {
   104         //If the shift key state is EShiftKeyPressed and a second shift key press is received before any other
   104         //If the shift key state is EShiftKeyPressed and a second shift key press is received before any other
   105         //key events, then current text case should not be changed.
   105         //key events, then current text case should not be changed.
   106         if (mShiftKeyState){
   106         if (mShiftKeyState){
   107             mShiftKeyState = EKeyPressedNone;
   107             mShiftKeyState = EKeyPressedNone;
   123             }
   123             }
   124         }
   124         }
   125     }
   125     }
   126         break;
   126         break;
   127     case Qt::Key_Control:{
   127     case Qt::Key_Control:{
   128 		return true;
   128         return true;
   129 		}
   129         }
   130 		
   130         
   131 		break;
   131         break;
   132 	case Qt::Key_Backspace:
   132     case Qt::Key_Backspace:
   133 	case Qt::Key_Delete: {
   133     case Qt::Key_Delete: {
   134 		// let's pass the backspace event to the focused editor.
   134         // let's pass the backspace event to the focused editor.
   135 		//return q->HbInputBasicHandler::filterEvent(event);
   135         //return q->HbInputBasicHandler::filterEvent(event);
   136 		break;
   136         break;
   137 	}
   137     }
   138 	case Qt::Key_Return:
   138     case Qt::Key_Return:
   139 	case Qt::Key_Enter:
   139     case Qt::Key_Enter:
   140 	case Qt::Key_Space: {
   140     case Qt::Key_Space: {
   141 		QChar qc(eventKey);
   141         QChar qc(eventKey);
   142 		if(Qt::Key_Space == eventKey && (event->modifiers() & Qt::ControlModifier)){
   142         if(Qt::Key_Space == eventKey && (event->modifiers() & Qt::ControlModifier)){
   143 			if (HbInputSettingProxy::instance()->predictiveInputStatus()) {
   143             if (HbInputSettingProxy::instance()->predictiveInputStatus()) {
   144 					HbInputSettingProxy::instance()->setPredictiveInputStatus(0);
   144                     HbInputSettingProxy::instance()->setPredictiveInputStatus(0);
   145 				} else {
   145                 } else {
   146 					HbInputSettingProxy::instance()->setPredictiveInputStatus(1);
   146                     HbInputSettingProxy::instance()->setPredictiveInputStatus(1);
   147 				}
   147                 }
   148 			break;
   148             break;
   149 		}
   149         }
   150 
   150 
   151 		if (qc == Qt::Key_Enter || qc == Qt::Key_Return) {
   151         if (qc == Qt::Key_Enter || qc == Qt::Key_Return) {
   152 			qc = QChar('\n');  // Editor expects normal line feed.
   152             qc = QChar('\n');  // Editor expects normal line feed.
   153 		}
   153         }
   154 		if(focusObject){
   154         if(focusObject){
   155 			q->commitAndUpdate(qc);	
   155             q->commitAndUpdate(qc); 
   156 		}
   156         }
   157 		break;
   157         break;
   158 		}
   158         }
   159     default: {
   159     default: {
   160 		if (q->HbInputBasicHandler::filterEvent(event)) {
   160         if (q->HbInputBasicHandler::filterEvent(event)) {
   161 				return true;
   161                 return true;
   162 			}   
   162             }   
   163 		QList<QInputMethodEvent::Attribute> list;
   163         QList<QInputMethodEvent::Attribute> list;
   164         QString newText;
   164         QString newText;
   165         int currentTextCase = focusObject->editorInterface().textCase();
   165         int currentTextCase = focusObject->editorInterface().textCase();
   166         // If function key is pressed, get the functionized 
   166         // If function key is pressed, get the functionized 
   167         
   167         
   168         QString chars;
   168         QString chars;
   192             focusObject->syncEditorInterface();
   192             focusObject->syncEditorInterface();
   193         }
   193         }
   194         mInputMethod->updateState();
   194         mInputMethod->updateState();
   195         }
   195         }
   196         break;
   196         break;
   197     }	
   197     }   
   198 	return true;
   198     return true;
   199 }
   199 }
   200 
   200 
   201 void HbHardwareInputBasicQwertyHandlerPrivate::_q_timeout()
   201 void HbHardwareInputBasicQwertyHandlerPrivate::_q_timeout()
   202 {
   202 {
   203     mTimer->stop();
   203     mTimer->stop();
   204 	qDebug("Timer stoped");
   204     qDebug("Timer stoped");
   205 	if (mButton == Qt::Key_Shift ){
   205     if (mButton == Qt::Key_Shift ){
   206         mShiftKeyState = EShiftKeyPressed;
   206         mShiftKeyState = EShiftKeyPressed;
   207 	} else {		
   207     } else {        
   208 		mFnState = HbFnNext;
   208         mFnState = HbFnNext;
   209 	}
   209     }
   210 	return;
   210     return;
   211 }
   211 }
   212 
   212 
   213 HbHardwareInputBasicQwertyHandler::HbHardwareInputBasicQwertyHandler(HbInputAbstractMethod* inputMethod)
   213 HbHardwareInputBasicQwertyHandler::HbHardwareInputBasicQwertyHandler(HbInputAbstractMethod* inputMethod)
   214 :HbInputBasicHandler(* new HbHardwareInputBasicQwertyHandlerPrivate, inputMethod)
   214 :HbInputBasicHandler(* new HbHardwareInputBasicQwertyHandlerPrivate, inputMethod)
   215 {
   215 {
   226 */
   226 */
   227 bool HbHardwareInputBasicQwertyHandler::filterEvent(const QKeyEvent* event)
   227 bool HbHardwareInputBasicQwertyHandler::filterEvent(const QKeyEvent* event)
   228 {
   228 {
   229     Q_D(HbHardwareInputBasicQwertyHandler);
   229     Q_D(HbHardwareInputBasicQwertyHandler);
   230 
   230 
   231 	if (!event->isAutoRepeat()) {
   231     if (!event->isAutoRepeat()) {
   232 		if ((event->type() == QEvent::KeyRelease) ) {
   232         if ((event->type() == QEvent::KeyRelease) ) {
   233 			return d->buttonReleased(event);
   233             return d->buttonReleased(event);
   234 		} else {
   234         } else {
   235 			return d->buttonPressed(event);
   235             return d->buttonPressed(event);
   236 		}
   236         }
   237 	}
   237     }
   238     return false;
   238     return false;
   239 }
   239 }
   240 
   240 
   241 /*!
   241 /*!
   242 returns true if in inline edit.
   242 returns true if in inline edit.
   256     bool ret = true;
   256     bool ret = true;
   257     switch (action) {
   257     switch (action) {
   258     case HbInputModeActionReset:
   258     case HbInputModeActionReset:
   259         if (d->mTimer->isActive()) {
   259         if (d->mTimer->isActive()) {
   260             d->mTimer->stop();
   260             d->mTimer->stop();
   261 			qDebug("Timer stoped");
   261             qDebug("Timer stoped");
   262         }
   262         }
   263         break;
   263         break;
   264     default: {
   264     default: {
   265         ret = HbInputBasicHandler::actionHandler(action);
   265         ret = HbInputBasicHandler::actionHandler(action);
   266         }
   266         }