Skip to content

Commit

Permalink
fix: Fix the issue that causes the wrong toolbar thumbnail movable range
Browse files Browse the repository at this point in the history
shorten the toolbar thumbnail vovable range and the animation of recoverey

Log: Fix the issue that toolbar thumbnail movable range is wrong.
Bug: https://pms.uniontech.com/bug-view-158443.html
  • Loading branch information
rb-union authored and lJxDabab committed Jan 17, 2024
1 parent 87637ab commit 1d12b09
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions libimageviewer/viewpanel/contents/imgviewwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
DWIDGET_USE_NAMESPACE

//const int Distance_factor = 4;//距离因子
#define LEFT_LISTVIEW_MOVE_MAXLEN 60
#define RIGHT_LISTVIEW_MOVE_UPDATE 35


MyImageListWidget::MyImageListWidget(QWidget *parent)
: QWidget(parent)
Expand Down Expand Up @@ -123,7 +126,12 @@ bool MyImageListWidget::eventFilter(QObject *obj, QEvent *e)
m_movePoints.pop_front();
m_movePoints.push_back(p);
}
m_listview->move(m_listview->x() + p.x() - m_moveViewPoint.x(), m_listview->y());
int moveRangeX = m_listview->x() + p.x() - m_moveViewPoint.x();
int rowWidth = m_listview->getRowWidth();
int offsetRowMove = rowWidth - ((rowWidth / RIGHT_LISTVIEW_MOVE_UPDATE) > 14 ? 12 : (rowWidth / RIGHT_LISTVIEW_MOVE_UPDATE - 3)) * RIGHT_LISTVIEW_MOVE_UPDATE;
moveRangeX = moveRangeX > LEFT_LISTVIEW_MOVE_MAXLEN ? LEFT_LISTVIEW_MOVE_MAXLEN : moveRangeX;
moveRangeX = moveRangeX < (LEFT_LISTVIEW_MOVE_MAXLEN - offsetRowMove) ? (LEFT_LISTVIEW_MOVE_MAXLEN - offsetRowMove) : moveRangeX;
m_listview->move(moveRangeX, m_listview->y());
m_moveViewPoint = p;

//目的为了获取moveX的值,中心离当前位置的差值
Expand Down Expand Up @@ -342,7 +350,11 @@ void MyImageListWidget::animationStart(bool isReset, int endPos, int duration)
}
m_resetAnimation->setEasingCurve(QEasingCurve::OutQuad);
m_resetAnimation->setStartValue(m_listview->pos());
m_resetAnimation->setEndValue(QPoint(m_listview->pos().x() + moveX, m_listview->pos().y()));
int moveRangeX = m_listview->pos().x() + moveX;
int offsetRowMove = rowWidth - ((rowWidth / RIGHT_LISTVIEW_MOVE_UPDATE) >= 12 ? 9 : (rowWidth / RIGHT_LISTVIEW_MOVE_UPDATE - 3)) * RIGHT_LISTVIEW_MOVE_UPDATE;
moveRangeX = moveRangeX > LEFT_LISTVIEW_MOVE_MAXLEN ? LEFT_LISTVIEW_MOVE_MAXLEN : moveRangeX;
moveRangeX = moveRangeX < (LEFT_LISTVIEW_MOVE_MAXLEN - offsetRowMove) ? (LEFT_LISTVIEW_MOVE_MAXLEN - offsetRowMove) : moveRangeX;
m_resetAnimation->setEndValue(QPoint(moveRangeX, m_listview->pos().y()));
m_resetAnimation->start();

}
Expand Down

0 comments on commit 1d12b09

Please sign in to comment.