Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion inputeventitem.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "inputeventitem.h"
Expand All @@ -12,6 +12,33 @@
qApp->installEventFilter(this);
}

QQuickItem* InputEventItem::inputMethodSource() const

Check warning on line 15 in inputeventitem.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'inputMethodSource' is never used.
{
return m_inputMethodSource;
}

void InputEventItem::setInputMethodSource(QQuickItem* source)

Check warning on line 20 in inputeventitem.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'setInputMethodSource' is never used.
{
if (m_inputMethodSource != source) {
m_inputMethodSource = source;
Q_EMIT inputMethodSourceChanged();
}
}

QVariant InputEventItem::inputMethodQuery(Qt::InputMethodQuery query) const
{
if (m_inputMethodSource) {
if (query == Qt::ImCursorRectangle) {
QVariant result = m_inputMethodSource->inputMethodQuery(query);
QRectF rect = result.toRectF();
QPointF mapped = m_inputMethodSource->mapToItem(this, rect.topLeft());
rect.moveTopLeft(mapped);
return rect;
}
}
return QQuickItem::inputMethodQuery(query);
}

bool InputEventItem::eventFilter(QObject *obj, QEvent *event) {
if (event->type() == QEvent::InputMethod && (this->children().contains(obj) || obj == this)) {
QInputMethodEvent *inputMethodEvent = static_cast<QInputMethodEvent *>(event);
Expand Down
12 changes: 11 additions & 1 deletion inputeventitem.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef INPUTEVENTITEM_H
Expand All @@ -12,14 +12,24 @@ class InputEventItem : public QQuickItem
{
Q_OBJECT
QML_ELEMENT
Q_PROPERTY(QQuickItem* inputMethodSource READ inputMethodSource WRITE setInputMethodSource NOTIFY inputMethodSourceChanged)
public:
InputEventItem();

QQuickItem* inputMethodSource() const;
void setInputMethodSource(QQuickItem* source);

QVariant inputMethodQuery(Qt::InputMethodQuery query) const override;

protected:
bool eventFilter(QObject *obj, QEvent *event) override;

signals:
void inputReceived(const QString &input);
void inputMethodSourceChanged();

private:
QQuickItem* m_inputMethodSource = nullptr;
};

#endif // INPUTEVENTITEM_H
2 changes: 2 additions & 0 deletions qml/FullscreenFrame.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import 'windowed' as WindowedLaunchpad
InputEventItem {
anchors.fill: parent
objectName: "FullscreenFrame-InputEventItem"
inputMethodSource: searchEdit
focus: true

property Palette appTextColor: Palette {
normal {
Expand Down
1 change: 1 addition & 0 deletions qml/windowed/WindowedFrame.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import "."
InputEventItem {
id: baseLayer
objectName: "WindowedFrame-BaseLayer"
inputMethodSource: bottomBar.searchEdit

visible: true
focus: true
Expand Down
Loading