Home · API Reference · Modules |
This page shows some excerpts from MeeGo Keyboard source code.
class MKeyboardHost: public MAbstractInputMethod { Q_OBJECT public: MKeyboardHost(MAbstractInputMethodHost *host, QWidget *mainWindow); virtual ~MKeyboardHost(); .....
The MAbstractInputMethod itself needs to be loaded by the plugin class, which is a MInputMethodPlugin class. For the plugin system to work, class must declare proper interface using Q_INTERFACES (in the header file) and export the plugin with Q_EXPORT_PLUGIN2 (in the .cpp file):
// The header file: class MKeyboardPlugin : public QObject, public MInputMethodPlugin { Q_OBJECT Q_INTERFACES(MInputMethodPlugin) public: MKeyboardPlugin(); virtual ~MKeyboardPlugin(); .....
// At the end of the .cpp file:
Q_EXPORT_PLUGIN2(meego-keyboard, MKeyboardPlugin)
The UI class is created in the createInputMethod method:
MAbstractInputMethod * MKeyboardPlugin::createInputMethod(MAbstractInputMethodHost *host, QWidget *mainWindow) { MAbstractInputMethod *inputMethod = new MKeyboardHost(host, mainWindow); return inputMethod; }
The plugin is given a main window that should be used as a parent widget for plugin visualization. Plugin is then free to create a QWidget or QGraphicsView or similar.
The interaction between the UI and the application is done by employing functions provided by MAbstractInputMethod and MAbstractInputMethodHost.
The settings is created by subclassing MAbstractInputMethodSettings.
class MKeyboardSettings: public QObject, public MAbstractInputMethodSettings { Q_OBJECT public: MKeyboardSettings(); .....
The actual widget shown is created in MKeyboardSettings::createContentWidget:
QGraphicsWidget *MKeyboardSettings::createContentWidget(QGraphicsWidget *parent) { // the pointer of returned QGraphicsWidget is owned by the caller, // so we just always create a new containerWidget. return new MKeyboardSettingsWidget(this, parent); }
plugin
and meegoimframework
to CONFIG
variable in your project file. CONFIG += plugin meegoimframework
/usr/lib/meego-im-plugins
directory. Depending on the user interface type, the plugin can be activated programmaticaly by setting the handler GConf key to the name of the plugin. The GConf parent key is /meegotouch/inputmethods/plugins/handler
.During runtime the plugin can be selected from control panel on the system.
Copyright © 2011 Nokia Corporation | Maliit |