-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Can't input Chinese when opening the launcher
Create an InputEventItem object to forward the input events of the input method. Issue: linuxdeepin/developer-center#8469
- Loading branch information
1 parent
2b072d8
commit 2182128
Showing
5 changed files
with
516 additions
and
455 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
#include "inputeventitem.h" | ||
|
||
InputEventItem::InputEventItem() | ||
{ | ||
qApp->installEventFilter(this); | ||
} | ||
|
||
bool InputEventItem::eventFilter(QObject *obj, QEvent *event) { | ||
if (event->type() == QEvent::InputMethod && (this->children().contains(obj) || obj == this)) { | ||
QInputMethodEvent *inputMethodEvent = static_cast<QInputMethodEvent *>(event); | ||
qDebug() << "InputEventItem::eventFilter: " << inputMethodEvent->commitString(); | ||
if (!inputMethodEvent->commitString().isEmpty()) | ||
Q_EMIT inputReceived(inputMethodEvent->commitString()); | ||
} | ||
return QObject::eventFilter(obj, event); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
#ifndef INPUTEVENTITEM_H | ||
#define INPUTEVENTITEM_H | ||
|
||
#include <QObject> | ||
#include <QQmlEngine> | ||
#include <QQuickItem> | ||
|
||
class InputEventItem : public QQuickItem | ||
{ | ||
Q_OBJECT | ||
QML_ELEMENT | ||
public: | ||
InputEventItem(); | ||
|
||
protected: | ||
bool eventFilter(QObject *obj, QEvent *event) override; | ||
|
||
signals: | ||
void inputReceived(const QString &input); | ||
}; | ||
|
||
#endif // INPUTEVENTITEM_H |
Oops, something went wrong.