代码拉取完成,页面将自动刷新
同步操作将从 src-anolis-os/qt5-qtbase 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 1ac5b8f6afbc441aa6cc2a1c81a604108eb11ee3 Mon Sep 17 00:00:00 2001
From: root <root@localhost.localdomain>
Date: Tue, 5 Jul 2022 11:07:10 +0800
Subject: [PATCH] fix-QLineEdit-cursor-jumping-on-touch-screen
---
src/widgets/widgets/qlineedit.cpp | 21 ++++++++++++---------
src/widgets/widgets/qlineedit_p.cpp | 7 -------
src/widgets/widgets/qlineedit_p.h | 4 +---
3 files changed, 13 insertions(+), 19 deletions(-)
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index 70d27b58..ae089ed5 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -1477,6 +1477,8 @@ bool QLineEdit::event(QEvent * e)
}
else if (timerId == d->tripleClickTimer.timerId())
d->tripleClickTimer.stop();
+ else if (timerId == d->popupClickTimer.timerId())
+ d->popupClickTimer.stop();
} else if (e->type() == QEvent::ContextMenu) {
#ifndef QT_NO_IM
if (d->control->composeMode())
@@ -1538,8 +1540,6 @@ void QLineEdit::mousePressEvent(QMouseEvent* e)
Q_D(QLineEdit);
if (e->source() == Qt::MouseEventSynthesizedByQt) {
d->touchPress = true;
- if (d->touchPopup)
- d->touchPopup = false;
d->oldPosX = e->screenPos().x();
}
@@ -1577,9 +1577,11 @@ void QLineEdit::mousePressEvent(QMouseEvent* e)
#endif
{
if (d->touchPress) {
- d->CurrentCursor = cursor;
- d->modStateMark = mark;
- QTimer::singleShot(QApplication::doubleClickInterval(), this, SLOT(_q_waitTouchPopup()));
+ if(selectionLength() == 0) {
+ d->control->moveCursor(cursor, mark);
+ }else {
+ d->popupClickTimer.start(QApplication::doubleClickInterval(), this);
+ }
} else {
d->control->moveCursor(cursor, mark);
}
@@ -1635,7 +1637,7 @@ void QLineEdit::mouseMoveEvent(QMouseEvent * e)
return;
// 1.0: Touch jitter causes the range of coordinates to change
- if ((d->touchPress && !d->touchPopup) && (qAbs(e->screenPos().x() - d->oldPosX) < 1.0)) {
+ if (d->touchPress && (qAbs(e->screenPos().x() - d->oldPosX) < 1.0)) {
d->oldPosX = e->screenPos().x();
return;
}
@@ -1661,11 +1663,13 @@ void QLineEdit::mouseReleaseEvent(QMouseEvent* e)
Q_D(QLineEdit);
if (e->source() == Qt::MouseEventSynthesizedByQt && d->touchPress) {
d->touchPress = false;
- d->touchPopup = true;
if (d->doublePress) {
- d->touchPopup = false;
d->doublePress = false;
}
+ //Press is triggered when the status is selected. Short press is normally triggered if the status is not long pressed
+ if (d->popupClickTimer.isActive()) {
+ d->control->moveCursor(d->xToPos(e->pos().x()));
+ }
}
if (d->sendMouseEventToInputContext(e))
@@ -2230,7 +2234,6 @@ void QLineEdit::contextMenuEvent(QContextMenuEvent *event)
{
Q_D(QLineEdit);
d->touchPress = false;
- d->touchPopup = false;
d->doublePress = false;
if (QMenu *menu = createStandardContextMenu()) {
diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp
index f1c49d45..231892f2 100644
--- a/src/widgets/widgets/qlineedit_p.cpp
+++ b/src/widgets/widgets/qlineedit_p.cpp
@@ -146,10 +146,6 @@ void QLineEditPrivate::_q_cursorPositionChanged(int from, int to)
void QLineEditPrivate::_q_waitTouchPopup()
{
- if (touchPopup) {
- control->moveCursor(CurrentCursor, modStateMark);
- touchPopup = false;
- }
}
@@ -251,11 +247,8 @@ void QLineEditPrivate::init(const QString& txt)
q->setAttribute(Qt::WA_MacShowFocusRect);
touchPress = false;
- touchPopup = false;
doublePress = false;
oldPosX = 0;
- CurrentCursor = 0;
- modStateMark = false;
initMouseYThreshold();
}
diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h
index fcb52b47..406f0d39 100644
--- a/src/widgets/widgets/qlineedit_p.h
+++ b/src/widgets/widgets/qlineedit_p.h
@@ -199,6 +199,7 @@ public:
QPoint tripleClick;
QBasicTimer tripleClickTimer;
+ QBasicTimer popupClickTimer;
uint frame : 1;
uint contextMenuEnabled : 1;
uint cursorVisible : 1;
@@ -207,11 +208,8 @@ public:
uint edited : 1;
int hscroll;
- int CurrentCursor;
bool touchPress;
- bool touchPopup;
bool doublePress;
- bool modStateMark;
qreal oldPosX ;
int vscroll;
--
2.31.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。