Fixes to the ibus input context

Adjust to changes in the QPlatformInputContext
and implement commit(). Fix a bug that caused the
cursor to be hidden after the first commit.

Change-Id: I85e59a72766d1180a54df412cf33beb653af4e7b
Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com>
This commit is contained in:
Lars Knoll 2011-10-31 10:16:15 +01:00 committed by Qt by Nokia
parent c9ef22b185
commit d7649245ec
2 changed files with 35 additions and 4 deletions

View File

@ -77,6 +77,7 @@ public:
QIBusInputContextProxy *context;
bool valid;
QString predit;
};
@ -104,10 +105,11 @@ bool QIBusPlatformInputContext::isValid() const
void QIBusPlatformInputContext::invokeAction(QInputPanel::Action a, int x)
{
QPlatformInputContext::invokeAction(a, x);
if (!d->valid)
return;
if (a == QInputPanel::Click)
commit();
}
void QIBusPlatformInputContext::reset()
@ -118,8 +120,31 @@ void QIBusPlatformInputContext::reset()
return;
d->context->Reset();
d->predit = QString();
}
void QIBusPlatformInputContext::commit()
{
QPlatformInputContext::commit();
if (!d->valid)
return;
QObject *input = qApp->inputPanel()->inputItem();
if (!input) {
d->predit = QString();
return;
}
QInputMethodEvent event;
event.setCommitString(d->predit);
QCoreApplication::sendEvent(input, &event);
d->context->Reset();
d->predit = QString();
}
void QIBusPlatformInputContext::update(Qt::InputMethodQueries q)
{
QPlatformInputContext::update(q);
@ -179,6 +204,8 @@ void QIBusPlatformInputContext::commitText(const QDBusVariant &text)
QInputMethodEvent event;
event.setCommitString(t.text);
QCoreApplication::sendEvent(input, &event);
d->predit = QString();
}
void QIBusPlatformInputContext::updatePreeditText(const QDBusVariant &text, uint cursorPos, bool visible)
@ -195,10 +222,13 @@ void QIBusPlatformInputContext::updatePreeditText(const QDBusVariant &text, uint
qDebug() << "preedit text:" << t.text;
QList<QInputMethodEvent::Attribute> attributes = t.attributes.imAttributes();
if (!t.text.isEmpty())
attributes += QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursorPos, visible ? 1 : 0, QVariant());
QInputMethodEvent event(t.text, attributes);
QCoreApplication::sendEvent(input, &event);
d->predit = t.text;
}

View File

@ -58,7 +58,8 @@ public:
bool isValid() const;
void invokeAction(QInputPanel::Action a, int x);
void reset(void);
void reset();
void commit();
void update(Qt::InputMethodQueries);
Q_INVOKABLE bool x11FilterEvent(uint keyval, uint keycode, uint state, bool press);