-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathplugintutorial.dox
More file actions
105 lines (83 loc) · 3.83 KB
/
plugintutorial.dox
File metadata and controls
105 lines (83 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*! @page plugintutorial Plugin Tutorial
@section intro Introduction
This page is a short tutorial about creating your own input method plugin.
MeeGo Touch Input Method provides a framework which developers can extend the functionality
of the input method by providing a new input method user interface. The new input method is implemented as
a plugin.
This page shows some excerpts from MeeGo Keyboard source code.
@section skeleton Skeleton
There are two important parts in the plugin making: the user interface of the input method, which is the part that user interact with while inputting text; and the settings, which is the part that enables user to set preferences on the input method.
@subsection ui User interface
The UI is loaded and controlled by a MAbstractInputMethod class.
@code
class MKeyboardHost: public MAbstractInputMethod
{
Q_OBJECT
public:
MKeyboardHost(MAbstractInputMethodHost *host, QWidget *mainWindow);
virtual ~MKeyboardHost();
.....
@endcode
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):
@code
// The header file:
class MKeyboardPlugin : public QObject, public MInputMethodPlugin
{
Q_OBJECT
Q_INTERFACES(MInputMethodPlugin)
public:
MKeyboardPlugin();
virtual ~MKeyboardPlugin();
.....
@endcode
@code
// At the end of the .cpp file:
Q_EXPORT_PLUGIN2(meego-keyboard, MKeyboardPlugin)
@endcode
The UI class is created in the createInputMethod method:
@code
MAbstractInputMethod *
MKeyboardPlugin::createInputMethod(MAbstractInputMethodHost *host, QWidget *mainWindow)
{
MAbstractInputMethod *inputMethod = new MKeyboardHost(host, mainWindow);
return inputMethod;
}
@endcode
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.
@subsection settings Settings
Settings is basically a QGraphicsWidget which holds items to provide user to set some preferences or behaviour of the input method. It is displayed in the control panel of the system.
The settings is created by subclassing MAbstractInputMethodSettings.
@code
/*!
* \brief MKeyboardSettings is the implemetation of meego-keyboard setting.
* MKeyboardSettings implement MAbstractInputMethodSettings and create the meego-keyboard
* setting. It provides below functionalities: get/set error corretion, get/set word
* completion, get/set installed (selected) keyboards.
*/
class MKeyboardSettings: public QObject, public MAbstractInputMethodSettings
{
Q_OBJECT
public:
MKeyboardSettings();
.....
@endcode
The actual widget shown is created in MKeyboardSettings::createContentWidget:
@code
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);
}
@endcode
@section compilation Compilation
To use the framework you need to add @c plugin and @c meegoimframework to @c CONFIG variable in your project file.
@code
CONFIG += plugin meegoimframework
@endcode
@section installation Installation
The plugin is installed to @c /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 @c /meegotouch/inputmethods/plugins/handler.
During runtime the plugin can be selected from control panel on the system.
*/