[MeeGo-dev] meego-im-framework is removing dependency to libmeegotouch from its API

Michael Hasselmann michaelh at openismus.com
Fri Mar 4 07:16:03 PST 2011


The upcoming meego-im-framework release (0.20.0) removes the dependency
to libmeegotouch from its API. It will also be possible to remove the
internal dependency to libmeegotouch (qmake CONFIG+=nomeegotouch -r).

Due to this, handling of inputmethod plugins will change. It'll free
them from using MPlainWindow. Instead, plugins can now choose between
traditional QWidget UI's or QGraphicsView UI's (including MeeGo Touch
and QML's declarative view).



WHAT INPUTMETHOD PLUGIN DEVELOPERS NEED TO CHANGE

1. Change your subclassed MAbstractInputMethod c'tor to accept a QWidget as
second parameter (instead of QObject). You might want to remove the default
value as well, as your input method plugin will most likely not work correctly
without this main window widget. The main window will be shown in fullscreen
mode (by default), but the geometry won't be correct until the first time
MAbstractInputMethod::show is called by framework.

Example (before/after):
- MyInputMethod::MyInputMethod(MAbstractInputMethodHost *host, QObject *parent = 0);
+ MyInputMethod::MyInputMethod(MAbstractInputMethodHost *host, QWidget *mainWindow);


2. In your subclassed  MAbstractInputMethod c'tor, make sure to reparent your central widget
to the supplied main window. Set up the remaining parts of your UI in this c'tor, too.

Example:
MyInputMethod::MyInputMethod(MAbstractInputMethodHost *host, QWidget *mainWindow)
    : MAbstractInputMethod(host, mainWindow)
{
   MyCentralWidget *w = new MyCentralWidget(mainWindow);
}


3. In your subclassed MInputMethodPlugin, change createInputMethod to take a
secondary QWidget parameter (the main window). Forward this main window to the
instantiated MAbstractInputMethod subclass.

Example (before/after):
- MAbstractInputMethod *createInputMethod(MAbstractInputMethodHost *host)
- {
-     return new MyInputMethod(host);
- }
+ MAbstractInputMethod *createInputMethod(MAbstractInputMethodHost *host, QWidget *mainWindow);
+ {
+     return new MyInputMethod(host, mainWindow);
+ }


4. Boost your plugin's performance by enabling support for self-compositing*:

4.1 If you have been using QGraphicsview as your central widget: Subclass from
MImGraphicsView instead and use it as the MAbstractInputMethod's central
widget.

4.2 If you have been using QWidget as your central widget: Subclass from
MImWidget instead and set use it as the MAbstractInputMethod's central widget.

4.3 If you have been using MWindow (MeeGo Touch): Override
QGraphicsView::drawBackground. The background pixmap will be supplied through
MAbstractInputMethodHost::background. If the returned pixmap is null, then
nothing should be painted in this method.

Example:
void MyCentralWidget::drawBackground(QPainter *painter, const QRectF &rect)
{
    if (not host || rect.isEmpty()) {
        return;
    }

    // "host" is the MAbstractInputMethodHost instance that was injected
    // into the MAbstractInputMethod c'tor:
    const QPixmap bg(host->background());
    if (not bg.isNull()) {
        painter->drawPixmap(rect, bg, rect);
    }
}

4.4 If you have been using a QWidget but cannot derive from MImWidget, then
override the paint event.

Example:
void MyCentralWidget::paintEvent(QPaintEvent *ev)
{
    if (ev->rect().isEmpty()) {
        return;
    }

    const QPixmap &bg(host->background());
    if (not bg.isNull()) {
        QPainter p(this);
        p.drawPixmap(ev->rect(), bg, ev->rect());
    }
}


5. If your plugin has been using MPlainWindow (and you need to keep
using it), then please either copy and paste this class from
meego-keyboard (if your plugin license allows copying from LGPL), or
follow the advice from 4.3 (preferred).


If you face difficulties while porting your plugin to meego-im-framework
0.20.0 or if you have further questions then please see
wiki.meego.com/Meego_Input_Methods#Communication_channels 


(* Self-compositing bypasses mcompositor for rendering, thus reducing latency 
and increasing FPS.)



CHANGES IN DETAIL

* Removed MeeGo Touch from public API.
* Allow to build framework without MeeGo Touch (optional)
  - Use "$ qmake CONFIG=+nomeegotouch -r ." or
    "DEB_BUILD_OPTIONS=nomeegotouch".
* New helper classes:
  - MImGraphicsView: Use this widget if your input method plugin uses
    QGraphicsView (or QDeclarative*).
  - MImWidget: Use this widget if your input method offers a tradtional
    QWidget-based UI.
  - MImHwKeyboardTracker: Tracks state (open/closed) of HW keyboard (does not
    provide any functionality yet when framework is build without MeeGo Touch
    support).
  - MImSettings: Currently a wrapper for GConf, but supposed to be extended for
    GConf-less platforms.
* API changes:
  - Removed MIMSettingsDialog (use settings applet instead).
    - Removed MAbstractInputMethodHost::showSettings, too. This means that IM
      plugins can no longer request the settings dialog.
  - Removed MPlainWindow.
  - MAbstractInputMethod:
    - c'tor now takes an additional QWidget parameter, the
      main window (top level widget) supplied by the framework.
  - MInputMethodPlugin:
    - createInputMethod: Takes an additional QWidget parameter, the main
      window. Parameter is supplied by framework.
  - MInputMethod namespace:
    - added OrientationAngle, Orientation, TextContentType (copied from MeeGo Touch)




More information about the MeeGo-dev mailing list
gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.