From: Huang Peng Date: Sun, 20 Jul 2008 04:55:10 +0000 (+0800) Subject: WIP. X-Git-Tag: 0.1.0.20080810~170 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=804a3b32cb2df4a3f2aa0a0357cb29b98e09fa63;p=platform%2Fupstream%2Fibus.git WIP. --- diff --git a/qt4/ibus-client.cpp b/qt4/ibus-client.cpp index ef963e7..c765961 100644 --- a/qt4/ibus-client.cpp +++ b/qt4/ibus-client.cpp @@ -385,6 +385,28 @@ IBusClient::connectToBus () return false; } + if (!connection->connect ("", + IBUS_PATH, + IBUS_INTERFACE, + "ShowPreedit", + this, SLOT (slotShowPreedit(QDBusMessage)))) { + qWarning () << "Can not connect ShowPreedit signal"; + delete connection; + QDBusConnection::disconnectFromBus ("ibus"); + return false; + } + + if (!connection->connect ("", + IBUS_PATH, + IBUS_INTERFACE, + "HidePreedit", + this, SLOT (slotHidePreedit(QDBusMessage)))) { + qWarning () << "Can not connect ShowPreedit signal"; + delete connection; + QDBusConnection::disconnectFromBus ("ibus"); + return false; + } + ibus = connection; QList ::iterator i; @@ -450,7 +472,7 @@ IBusClient::slotUpdatePreedit (QDBusMessage message) QString text; QVariant attrs; int cursor_pos; - bool show; + bool visible; QList args = message.arguments (); @@ -458,7 +480,7 @@ IBusClient::slotUpdatePreedit (QDBusMessage message) text = args[1].toString (); attrs = args[2]; cursor_pos = args[3].toInt (); - show = args[4].toBool (); + visible = args[4].toBool (); QList > attr_list; const QDBusArgument arg = attrs.value (); arg.beginArray (); @@ -478,5 +500,30 @@ IBusClient::slotUpdatePreedit (QDBusMessage message) arg.endArray (); IBusInputContext *ctx = context_dict[ic]; - ctx->updatePreedit (text, attr_list, cursor_pos, show); + ctx->updatePreedit (text, attr_list, cursor_pos, visible); } + +void +IBusClient::slotShowPreedit (QDBusMessage message) +{ + QString ic; + + QList args = message.arguments (); + + ic = args[0].toString (); + IBusInputContext *ctx = context_dict[ic]; + ctx->showPreedit (); +} + +void +IBusClient::slotHidePreedit (QDBusMessage message) +{ + QString ic; + + QList args = message.arguments (); + + ic = args[0].toString (); + IBusInputContext *ctx = context_dict[ic]; + ctx->hidePreedit (); +} + diff --git a/qt4/ibus-client.h b/qt4/ibus-client.h index 4565a78..6a37224 100644 --- a/qt4/ibus-client.h +++ b/qt4/ibus-client.h @@ -66,6 +66,8 @@ private slots: void slotCommitString (QString ic, QString text); //void slotUpdatePreedit (QString ic, QString text, QVariant attrs, int cursor_pos, bool show); void slotUpdatePreedit (QDBusMessage message); + void slotShowPreedit (QDBusMessage message); + void slotHidePreedit (QDBusMessage message); private: bool connectToBus (); diff --git a/qt4/ibus-input-context.cpp b/qt4/ibus-input-context.cpp index 6a00ec7..692fecb 100644 --- a/qt4/ibus-input-context.cpp +++ b/qt4/ibus-input-context.cpp @@ -174,12 +174,12 @@ IBusInputContext::commitString (QString text) } void -IBusInputContext::updatePreedit (QString text, QList > attr_list, int cursor_pos, bool show) +IBusInputContext::updatePreedit (QString text, QList > attr_list, int cursor_pos, bool visible) { // qDebug () << text << cursor_pos << show; QList qattrs; - if (show) { + if (visible) { // append cursor pos qattrs.append (QAttribute (QInputMethodEvent::Cursor, cursor_pos, true, 0)); @@ -214,10 +214,30 @@ IBusInputContext::updatePreedit (QString text, QList > attr_lis } preedit_string = text; - preedit_visible = show; + preedit_visible = visible; + preedit_attrs = attr_list; preedit_cursor_pos = cursor_pos; QInputMethodEvent event (text, qattrs); sendEvent (event); update (); } + +void +IBusInputContext::showPreedit () +{ + if (preedit_visible) + return; + + updatePreedit (preedit_string, preedit_attrs, preedit_cursor_pos, TRUE); +} + +void +IBusInputContext::hidePreedit () +{ + if (!preedit_visible) + return; + + updatePreedit (preedit_string, preedit_attrs, preedit_cursor_pos, FALSE); +} + diff --git a/qt4/ibus-input-context.h b/qt4/ibus-input-context.h index 6aac46b..317c876 100644 --- a/qt4/ibus-input-context.h +++ b/qt4/ibus-input-context.h @@ -51,7 +51,9 @@ public: QString getIC (); void commitString (QString text); - void updatePreedit (QString text, QList > attr_list, int cursor_pos, bool show); + void updatePreedit (QString text, QList > attr_list, int cursor_pos, bool visible); + void showPreedit (); + void hidePreedit (); private: @@ -60,6 +62,7 @@ private: QString preedit_string; bool preedit_visible; int preedit_cursor_pos; + QList > preedit_attrs; QRect cursor_location; };