QWidgets: show SoftwareInputPanel for key release

Virtual keyboard should be shown when editable widget get focus by key
(like Tab or BackTab). Before this change SoftwareInputPanel was
handled only for mouseKeyRelease event

Task-number: QTBUG-61652
Pick-to: 5.15
Change-Id: I85f80422b596592a04c2f9af214f991c471485c8
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
This commit is contained in:
Bartlomiej Moskal 2021-02-18 14:00:01 +01:00
parent d831035435
commit 93038767b7
4 changed files with 14 additions and 3 deletions

View File

@ -595,9 +595,15 @@ public:
QSize adjustedSize() const;
inline void handleSoftwareInputPanel(Qt::MouseButton button, bool clickCausedFocus)
{
if (button == Qt::LeftButton)
handleSoftwareInputPanel(clickCausedFocus);
}
inline void handleSoftwareInputPanel(bool clickCausedFocus = false)
{
Q_Q(QWidget);
if (button == Qt::LeftButton && qApp->autoSipEnabled()) {
if (qApp->autoSipEnabled()) {
QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
q->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) {

View File

@ -1787,6 +1787,8 @@ void QLineEdit::keyPressEvent(QKeyEvent *event)
void QLineEdit::keyReleaseEvent(QKeyEvent *)
{
Q_D(QLineEdit);
if (!isReadOnly())
d->handleSoftwareInputPanel();
d->control->updateCursorBlinking();
}

View File

@ -1830,10 +1830,11 @@ void QPlainTextEdit::keyPressEvent(QKeyEvent *e)
void QPlainTextEdit::keyReleaseEvent(QKeyEvent *e)
{
Q_D(QPlainTextEdit);
if (!isReadOnly())
d->handleSoftwareInputPanel();
d->keyboardModifiers = e->modifiers();
#ifdef QT_KEYPAD_NAVIGATION
Q_D(QPlainTextEdit);
if (QApplicationPrivate::keypadNavigationEnabled()) {
if (!e->isAutoRepeat() && e->key() == Qt::Key_Back
&& d->deleteAllTimer.isActive()) {

View File

@ -1456,8 +1456,10 @@ void QTextEdit::keyPressEvent(QKeyEvent *e)
*/
void QTextEdit::keyReleaseEvent(QKeyEvent *e)
{
#ifdef QT_KEYPAD_NAVIGATION
Q_D(QTextEdit);
if (!isReadOnly())
d->handleSoftwareInputPanel();
#ifdef QT_KEYPAD_NAVIGATION
if (QApplicationPrivate::keypadNavigationEnabled()) {
if (!e->isAutoRepeat() && e->key() == Qt::Key_Back
&& d->deleteAllTimer.isActive()) {