vcl/inc/qt5/Qt5Widget.hxx | 8 ++++++++ vcl/qt5/Qt5Frame.cxx | 10 ++++++++-- vcl/qt5/Qt5Widget.cxx | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 2 deletions(-)
New commits: commit 7da0f71cf15af0cfa74d0eaa0011a6b1db1a4abd Author: Jan-Marek Glogowski <glo...@fbihome.de> AuthorDate: Fri Dec 21 17:25:17 2018 +0100 Commit: Thorsten Behrens <thorsten.behr...@cib.de> CommitDate: Sun Dec 23 10:31:08 2018 +0100 tdf#121161 Qt5 initial IM support This just implements some minimal solution, since I have no idea, how all this IM handling should actually work. Change-Id: I0d02dfb96680891e275881927ebc17f798dc1f29 Reviewed-on: https://gerrit.libreoffice.org/65553 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glo...@fbihome.de> (cherry picked from commit c7ee454a35c392dfd03c9ccf8fd953ec9c98e484) Reviewed-on: https://gerrit.libreoffice.org/65558 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx index ad043650b32e..26f26c8bf0a3 100644 --- a/vcl/inc/qt5/Qt5Widget.hxx +++ b/vcl/inc/qt5/Qt5Widget.hxx @@ -22,9 +22,13 @@ #include <QtWidgets/QWidget> #include <rtl/ustring.hxx> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/accessibility/XAccessibleEditableText.hpp> + class Qt5Frame; class Qt5Object; class QFocusEvent; +class QInputMethodEvent; class QKeyEvent; class QMouseEvent; class QMoveEvent; @@ -32,6 +36,7 @@ class QPaintEvent; class QResizeEvent; class QShowEvent; class QWheelEvent; +class QVariant; class Qt5Widget : public QWidget { @@ -57,6 +62,9 @@ class Qt5Widget : public QWidget virtual void wheelEvent(QWheelEvent*) override; virtual void closeEvent(QCloseEvent*) override; + void inputMethodEvent(QInputMethodEvent*) override; + QVariant inputMethodQuery(Qt::InputMethodQuery) const override; + const QString m_InternalMimeType = "application/x-libreoffice-dnditem"; public slots: diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx index 781f1c6b67a4..230c98395a70 100644 --- a/vcl/qt5/Qt5Frame.cxx +++ b/vcl/qt5/Qt5Frame.cxx @@ -655,9 +655,15 @@ bool Qt5Frame::ShowTooltip(const OUString& rText, const tools::Rectangle& /*rHel // do we even need it? void Qt5Frame::Flush(const tools::Rectangle& /*rRect*/) {} -void Qt5Frame::SetInputContext(SalInputContext* /*pContext*/) +void Qt5Frame::SetInputContext(SalInputContext* pContext) { - // TODO some IM handler setup + if (!pContext) + return; + + if (!(pContext->mnOptions & InputContextFlags::Text)) + return; + + m_pQWidget->setAttribute(Qt::WA_InputMethodEnabled); } void Qt5Frame::EndExtTextInput(EndExtTextInputFlags /*nFlags*/) diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx index ba839a6abaea..462f19675905 100644 --- a/vcl/qt5/Qt5Widget.cxx +++ b/vcl/qt5/Qt5Widget.cxx @@ -428,4 +428,46 @@ Qt5Widget::Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f) setFocusPolicy(Qt::StrongFocus); } +void Qt5Widget::inputMethodEvent(QInputMethodEvent* pEvent) +{ + SolarMutexGuard aGuard; + SalExtTextInputEvent aInputEvent; + aInputEvent.mpTextAttr = nullptr; + aInputEvent.mnCursorFlags = 0; + + if (!pEvent->commitString().isEmpty()) + { + vcl::DeletionListener aDel(m_pFrame); + aInputEvent.maText = toOUString(pEvent->commitString()); + aInputEvent.mnCursorPos = aInputEvent.maText.getLength(); + m_pFrame->CallCallback(SalEvent::ExtTextInput, &aInputEvent); + pEvent->accept(); + if (!aDel.isDeleted()) + m_pFrame->CallCallback(SalEvent::EndExtTextInput, nullptr); + } + else + { + aInputEvent.maText = toOUString(pEvent->preeditString()); + aInputEvent.mnCursorPos = 0; + m_pFrame->CallCallback(SalEvent::ExtTextInput, &aInputEvent); + pEvent->accept(); + } +} + +QVariant Qt5Widget::inputMethodQuery(Qt::InputMethodQuery property) const +{ + switch (property) + { + case Qt::ImCursorRectangle: + { + SalExtTextInputPosEvent aPosEvent; + m_pFrame->CallCallback(SalEvent::ExtTextInputPos, &aPosEvent); + return QVariant( + QRect(aPosEvent.mnX, aPosEvent.mnY, aPosEvent.mnWidth, aPosEvent.mnHeight)); + } + default: + return QWidget::inputMethodQuery(property); + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits