Home · All Classes · Main Classes · Deprecated

minputmethodstate.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (directui@nokia.com)
00006 **
00007 ** This file is part of libmeegotouch.
00008 **
00009 ** If you have questions regarding the use of this file, please contact
00010 ** Nokia at directui@nokia.com.
00011 **
00012 ** This library is free software; you can redistribute it and/or
00013 ** modify it under the terms of the GNU Lesser General Public
00014 ** License version 2.1 as published by the Free Software Foundation
00015 ** and appearing in the file LICENSE.LGPL included in the packaging
00016 ** of this file.
00017 **
00018 ****************************************************************************/
00019 
00020 #include "minputmethodstate.h"
00021 #include "minputmethodstate_p.h"
00022 
00023 #include "qapplication.h"
00024 #include "qinputcontext.h"
00025 
00026 #include <QTimer>
00027 #include <QKeyEvent>
00028 
00029 
00030 MInputMethodStatePrivate::MInputMethodStatePrivate()
00031     : orientation(M::Angle0),
00032       q_ptr(NULL)
00033 {
00034 }
00035 
00036 MInputMethodStatePrivate::~MInputMethodStatePrivate()
00037 {
00038 }
00039 
00040 void MInputMethodStatePrivate::init()
00041 {
00042 }
00043 
00044 MInputMethodState::MInputMethodState()
00045     : d_ptr(new MInputMethodStatePrivate)
00046 {
00047     Q_D(MInputMethodState);
00048 
00049     d->q_ptr = this;
00050     d->init();
00051 }
00052 
00053 MInputMethodState::~MInputMethodState()
00054 {
00055     delete d_ptr;
00056 }
00057 
00058 MInputMethodState *MInputMethodState::instance()
00059 {
00060     static MInputMethodState singleton;
00061 
00062     return &singleton;
00063 }
00064 
00065 void MInputMethodState::setInputMethodArea(const QRect &newRegion)
00066 {
00067     Q_D(MInputMethodState);
00068 
00069     if (d->region != newRegion) {
00070         d->region = newRegion;
00071         emit inputMethodAreaChanged(d->region);
00072     }
00073 }
00074 
00075 QRect MInputMethodState::inputMethodArea() const
00076 {
00077     Q_D(const MInputMethodState);
00078 
00079     return d->region;
00080 }
00081 
00082 void MInputMethodState::setActiveWindowOrientationAngle(M::OrientationAngle newOrientation)
00083 {
00084     Q_D(MInputMethodState);
00085 
00086     if (d->orientation != newOrientation) {
00087         d->orientation = newOrientation;
00088         emit activeWindowOrientationAngleChanged(newOrientation);
00089     }
00090 }
00091 
00092 M::OrientationAngle MInputMethodState::activeWindowOrientationAngle() const
00093 {
00094     Q_D(const MInputMethodState);
00095 
00096     return d->orientation;
00097 }
00098 
00099 void MInputMethodState::requestSoftwareInputPanel()
00100 {
00101     QInputContext *inputContext = qApp->inputContext();
00102 
00103     if (!inputContext) {
00104         return;
00105     }
00106 
00107     QEvent request(QEvent::RequestSoftwareInputPanel);
00108     inputContext->filterEvent(&request);
00109 }
00110 
00111 void MInputMethodState::closeSoftwareInputPanel()
00112 {
00113     QInputContext *inputContext = qApp->inputContext();
00114 
00115     if (!inputContext) {
00116         return;
00117     }
00118 
00119     QEvent close(QEvent::CloseSoftwareInputPanel);
00120     inputContext->filterEvent(&close);
00121     inputContext->reset();
00122 }
00123 
00124 void MInputMethodState::emitKeyPress(const QKeyEvent &event)
00125 {
00126     emit keyPress(event);
00127 }
00128 
00129 void MInputMethodState::emitKeyRelease(const QKeyEvent &event)
00130 {
00131     emit keyRelease(event);
00132 }
00133 
00134 QList<int> MInputMethodState::toolbarIds() const
00135 {
00136     Q_D(const MInputMethodState);
00137     return d->toolbars.keys();
00138 }
00139 
00140 MInputMethodState::ItemAttributeMap MInputMethodState::toolbarState(int id) const
00141 {
00142     Q_D(const MInputMethodState);
00143     ToolbarInfo *toolbar = d->toolbars.value(id);
00144 
00145     return (toolbar ? toolbar->items : ItemAttributeMap());
00146 }
00147 
00148 int MInputMethodState::registerToolbar(const QString &fileName)
00149 {
00150     Q_D(MInputMethodState);
00151     static int idCounter = 0;
00152     // generate an application local unique identifier for the toolbar.
00153     int newId = idCounter;
00154     idCounter++;
00155     d->toolbars.insert(newId, new ToolbarInfo(fileName));
00156     emit toolbarRegistered(newId, fileName);
00157     return newId;
00158 }
00159 
00160 void MInputMethodState::unregisterToolbar(int id)
00161 {
00162     Q_D(MInputMethodState);
00163     delete d->toolbars[id];
00164     d->toolbars.remove(id);
00165     emit toolbarUnregistered(id);
00166 }
00167 
00168 void MInputMethodState::setToolbarItemAttribute(int id, const QString &item,
00169                                                 const QString &attribute, const QVariant &value)
00170 {
00171     Q_D(MInputMethodState);
00172 
00173     if (!d->toolbars.contains(id)) {
00174         return;
00175     }
00176 
00177     ToolbarInfo *toolbar = d->toolbars[id];
00178     toolbar->items[item][attribute] = value;
00179     emit toolbarItemAttributeChanged(id, item, attribute, value);
00180 }
00181 
00182 QString MInputMethodState::toolbar(int id) const
00183 {
00184     Q_D(const MInputMethodState);
00185 
00186     ToolbarInfo *toolbar = d->toolbars.value(id);
00187 
00188     if (toolbar) {
00189         return toolbar->fileName;
00190     } else {
00191         return QString();
00192     }
00193 }
00194 
00195 #include "moc_minputmethodstate.cpp"

Copyright © 2010 Nokia Corporation Generated on Thu Nov 4 2010 18:14:20 (PDT)
Doxygen 1.7.1
MeeGo Touch