Skip to content

Commit 32ab10b

Browse files
lichaofan2008deepin-bot[bot]
authored andcommitted
fix: prevent excessively long sliding distances.
Limit the speed within the range of -10 to 10 to prevent excessively long sliding distances caused by high speed. 限制速度在-10到10之间,避免速度过快导致滑动距离过长。 Bug: https://pms.uniontech.com/bug-view-353489.html
1 parent 98ba4aa commit 32ab10b

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/editor/dtextedit.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6706,6 +6706,8 @@ void TextEdit::mousePressEvent(QMouseEvent *e)
67066706

67076707
void TextEdit::mouseMoveEvent(QMouseEvent *e)
67086708
{
6709+
static const qreal MAX_INERTIAL_SPEED = 10.0;
6710+
67096711
if (Qt::MouseEventSynthesizedByQt == e->source())
67106712
{
67116713
m_endY = e->y();
@@ -6736,8 +6738,10 @@ void TextEdit::mouseMoveEvent(QMouseEvent *e)
67366738

67376739
/*预算惯性滑动时间*/
67386740
m_stepSpeedY = static_cast<qreal>(diffYpos) / static_cast<qreal>(diffTimeY + 0.000001);
6741+
m_stepSpeedY = qBound(-MAX_INERTIAL_SPEED, m_stepSpeedY, MAX_INERTIAL_SPEED); // 限制速度在-10到10之间,避免速度过快导致滑动距离过长
67396742
durationY = sqrt(abs(m_stepSpeedY)) * 1000;
67406743
m_stepSpeedX = static_cast<qreal>(diffXpos) / static_cast<qreal>(diffTimeX + 0.000001);
6744+
m_stepSpeedX = qBound(-MAX_INERTIAL_SPEED, m_stepSpeedX, MAX_INERTIAL_SPEED); // 限制速度在-10到10之间,避免速度过快导致滑动距离过长
67416745
durationX = sqrt(abs(m_stepSpeedX)) * 1000;
67426746

67436747
/*预算惯性滑动距离,4.0为调优数值*/

0 commit comments

Comments
 (0)