src/hbplugins/inputmethods/common/hbinputspellquerydialog.cpp
changeset 34 ed14f46c0e55
parent 7 923ff622b8b9
equal deleted inserted replaced
31:7516d6d86cf5 34:ed14f46c0e55
    33 #include <hbaction.h>
    33 #include <hbaction.h>
    34 #include <hbmainwindow.h>
    34 #include <hbmainwindow.h>
    35 #include <hbinstance.h>
    35 #include <hbinstance.h>
    36 #include <hbeffect.h>
    36 #include <hbeffect.h>
    37 #include <hbinputregioncollector_p.h>
    37 #include <hbinputregioncollector_p.h>
       
    38 #include <hbinputmainwindow_p.h>
    38 
    39 
    39 #include "hbinputspellquerydialog.h"
    40 #include "hbinputspellquerydialog.h"
    40 #include "hbinputmodehandler.h"
    41 #include "hbinputmodehandler.h"
       
    42 #include "hbinputdialog_p.h"
    41 
    43 
    42 static const qint16 MAXUDBWORDSIZE = 64;
    44 static const qint16 MAXUDBWORDSIZE = 64;
       
    45 
       
    46 class HbInputSpellQueryPrivate : public HbInputDialogPrivate
       
    47 {
       
    48     Q_DECLARE_PUBLIC(HbInputSpellQuery)
       
    49 
       
    50 public:
       
    51     HbInputSpellQueryPrivate() {};
       
    52     ~HbInputSpellQueryPrivate() {};
       
    53 };
    43 
    54 
    44 HbInputSpellQuery::HbInputSpellQuery(HbInputMethod *inputMethod, HbInputPredictionHandler *predictionHandler)
    55 HbInputSpellQuery::HbInputSpellQuery(HbInputMethod *inputMethod, HbInputPredictionHandler *predictionHandler)
    45  : mOwner(inputMethod), mPredictionHandler(predictionHandler), mPrimaryAction(0) 
    56  : mOwner(inputMethod), mPredictionHandler(predictionHandler), mPrimaryAction(0) 
    46 {
    57 {
    47     setInputMode(HbInputDialog::TextInput);
    58     setInputMode(HbInputDialog::TextInput);
    54 {
    65 {
    55 }
    66 }
    56 
    67 
    57 void HbInputSpellQuery::launch(QString editorText)
    68 void HbInputSpellQuery::launch(QString editorText)
    58 {
    69 {
    59     HbInputFocusObject *focusObject = 0;
    70     Q_D(HbInputSpellQuery);
    60     if (!mOwner || !(focusObject = mOwner->focusObject())) {
    71 
       
    72     if (!mOwner) {
    61         return;
    73         return;
    62     }
    74     }
       
    75     HbInputFocusObject *focusObject = mOwner->focusObject();
       
    76     if (!focusObject) {
       
    77         return;
       
    78     }
       
    79 
    63     mSavedState = mOwner->inputState();
    80     mSavedState = mOwner->inputState();
    64     // close the keypad before showing the spell dialog
    81     // close the keypad before showing the spell dialog
    65     HbVkbHost *vkbHost = focusObject->editorInterface().vkbHost();
    82     HbVkbHost *vkbHost = focusObject->editorInterface().vkbHost();
    66     if (vkbHost && vkbHost->keypadStatus() != HbVkbHost::HbVkbStatusClosed) {
    83     if (vkbHost && vkbHost->keypadStatus() != HbVkbHost::HbVkbStatusClosed) {
    67         vkbHost->closeKeypad();
    84         vkbHost->closeKeypad();
    87         // we don't want prediction and automatic textcase in spell query dialog
   104         // we don't want prediction and automatic textcase in spell query dialog
    88         spellEdit->setInputMethodHints(spellEdit->inputMethodHints() | Qt::ImhNoPredictiveText | Qt::ImhNoAutoUppercase);
   105         spellEdit->setInputMethodHints(spellEdit->inputMethodHints() | Qt::ImhNoPredictiveText | Qt::ImhNoAutoUppercase);
    89         eInt.setLastFocusedState(mSavedState);
   106         eInt.setLastFocusedState(mSavedState);
    90         spellEdit->setFocus();
   107         spellEdit->setFocus();
    91     }
   108     }
       
   109 
       
   110     d->setPriority(focusObject->editorPriority());
       
   111 
    92     // execute the spell dialog
   112     // execute the spell dialog
    93     mSavedFocusObject = focusObject->object();
   113     mSavedFocusObject = focusObject->object();
    94     mSavedEditorText = editorText;
   114     mSavedEditorText = editorText;
    95     mDidHandleFinish = false;
   115     mDidHandleFinish = false;
    96     mainWindow()->setProperty("SpellQueryLaunched", true);
   116     HbInputMainWindow::instance()->lockFocus();
    97     open(this,SLOT(dialogClosed(HbAction*)));
   117     open(this,SLOT(dialogClosed(HbAction*)));
    98     mPrimaryAction = qobject_cast<HbAction*>(actions().first());
   118     mPrimaryAction = qobject_cast<HbAction*>(actions().first());
    99 
   119 
   100     // Open keypad for the spell query
   120     // Open keypad for the spell query
   101     QInputContext *ic = qApp->inputContext();
   121     QInputContext *ic = qApp->inputContext();
   106     }
   126     }
   107 }
   127 }
   108 
   128 
   109 void HbInputSpellQuery::dialogClosed(HbAction* action)
   129 void HbInputSpellQuery::dialogClosed(HbAction* action)
   110 {
   130 {
   111     mainWindow()->setProperty("SpellQueryLaunched", false);
       
   112     //There are multiple dialog closed event received. This will make sure we handle finish
   131     //There are multiple dialog closed event received. This will make sure we handle finish
   113     //only once
   132     //only once
   114     if(mDidHandleFinish) {
   133     if(mDidHandleFinish) {
   115         return;
   134         return;
   116     } else {
   135     } else {
   131     }
   150     }
   132     //Need to disable effects as asynchronous hide will commit the word otherwise.
   151     //Need to disable effects as asynchronous hide will commit the word otherwise.
   133     HbEffect::disable(this);
   152     HbEffect::disable(this);
   134     hide();
   153     hide();
   135     HbEffect::enable(this);  
   154     HbEffect::enable(this);  
   136 
   155     
       
   156     HbInputMainWindow::instance()->unlockFocus();
       
   157     
   137     mPredictionHandler->spellQueryDialogClosed(mSavedFocusObject,closeReason,string);
   158     mPredictionHandler->spellQueryDialogClosed(mSavedFocusObject,closeReason,string);
   138     mSavedFocusObject = 0;
   159     mSavedFocusObject = 0;
   139     mSavedEditorText.clear();
   160     mSavedEditorText.clear();
   140     mPrimaryAction = 0;
   161     mPrimaryAction = 0;
   141 }
   162 }