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 <IBusInputContext *>::iterator i;
QString text;
QVariant attrs;
int cursor_pos;
- bool show;
+ bool visible;
QList<QVariant> args = message.arguments ();
text = args[1].toString ();
attrs = args[2];
cursor_pos = args[3].toInt ();
- show = args[4].toBool ();
+ visible = args[4].toBool ();
QList <QList <quint32> > attr_list;
const QDBusArgument arg = attrs.value <QDBusArgument> ();
arg.beginArray ();
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<QVariant> args = message.arguments ();
+
+ ic = args[0].toString ();
+ IBusInputContext *ctx = context_dict[ic];
+ ctx->showPreedit ();
+}
+
+void
+IBusClient::slotHidePreedit (QDBusMessage message)
+{
+ QString ic;
+
+ QList<QVariant> args = message.arguments ();
+
+ ic = args[0].toString ();
+ IBusInputContext *ctx = context_dict[ic];
+ ctx->hidePreedit ();
+}
+
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 ();
}
void
-IBusInputContext::updatePreedit (QString text, QList <QList <quint32> > attr_list, int cursor_pos, bool show)
+IBusInputContext::updatePreedit (QString text, QList <QList <quint32> > attr_list, int cursor_pos, bool visible)
{
// qDebug () << text << cursor_pos << show;
QList <QAttribute> qattrs;
- if (show) {
+ if (visible) {
// append cursor pos
qattrs.append (QAttribute (QInputMethodEvent::Cursor, cursor_pos, true, 0));
}
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);
+}
+
QString getIC ();
void commitString (QString text);
- void updatePreedit (QString text, QList <QList <quint32> > attr_list, int cursor_pos, bool show);
+ void updatePreedit (QString text, QList <QList <quint32> > attr_list, int cursor_pos, bool visible);
+ void showPreedit ();
+ void hidePreedit ();
private:
QString preedit_string;
bool preedit_visible;
int preedit_cursor_pos;
+ QList <QList <quint32> > preedit_attrs;
QRect cursor_location;
};