@@ -1353,6 +1353,15 @@ void MainWindow::initScrollShot()
13531353 }
13541354 // 定时2s后滚动截图的提示消失
13551355 m_tipShowtimer = new QTimer (this );
1356+ m_waylandManualScrollTimer = new QTimer (this );
1357+ m_waylandManualScrollTimer->setSingleShot (true );
1358+ connect (m_waylandManualScrollTimer, &QTimer::timeout, this , [this ] {
1359+ if (!m_scrollShot || status::scrollshot != m_functionType || m_isErrorWithScrollShot) {
1360+ return ;
1361+ }
1362+ scrollShotGrabPixmap (m_waylandManualScrollPreviewPostion, m_waylandManualScrollDirection,
1363+ m_waylandManualScrollMouseTime);
1364+ });
13561365 connect (m_tipShowtimer, &QTimer::timeout, this , [ = ]() {
13571366 m_tipShowtimer->stop ();
13581367 m_scrollShotTip->hide ();
@@ -1489,6 +1498,18 @@ void MainWindow::handleManualScrollShot(int mouseTime, int direction)
14891498 m_scrollShotTip->hide ();
14901499 m_isAdjustArea = false ;
14911500 update ();
1501+ if (Utils::isWaylandMode) {
1502+ m_waylandManualScrollPreviewPostion = m_previewPostion;
1503+ m_waylandManualScrollDirection = direction;
1504+ m_waylandManualScrollMouseTime = mouseTime;
1505+ if (m_waylandManualScrollTimer) {
1506+ m_waylandManualScrollTimer->start (320 );
1507+ } else {
1508+ scrollShotGrabPixmap (m_previewPostion, direction, mouseTime);
1509+ }
1510+ return ;
1511+ }
1512+
14921513 static int num = 1 ;
14931514 ++num;
14941515 if (num % 3 == 0 ) {
@@ -1523,7 +1544,7 @@ void MainWindow::showAdjustArea()
15231544}
15241545#ifdef OCR_SCROLL_FLAGE_ON
15251546// 滚动截图模式,抓取当前捕捉区域的图片,传递给滚动截图处理类进行图片的拼接
1526- void MainWindow::scrollShotGrabPixmap (PreviewWidget::PostionStatus previewPostion, int direction, int mouseTime)
1547+ void MainWindow::scrollShotGrabPixmap (PreviewWidget::PostionStatus previewPostion, int direction, qint64 mouseTime)
15271548{
15281549
15291550// 不同的平台延时时间不同
@@ -2117,23 +2138,29 @@ void MainWindow::wheelEvent(QWheelEvent *event)
21172138 int y = this ->cursor ().pos ().y ();
21182139
21192140 // 将当前捕捉区域画为一个矩形
2120- QRect recordRect {
2121- static_cast <int >(recordX * m_pixelRatio),
2122- static_cast <int >(recordY * m_pixelRatio),
2123- static_cast <int >(recordWidth * m_pixelRatio),
2124- static_cast <int >(recordHeight * m_pixelRatio)
2125- };
2141+ QRect recordRect (recordX, recordY, recordWidth, recordHeight);
21262142 // 当前鼠标的点
21272143 QPoint mouseMovePoint (x, y);
21282144 // 判断当鼠标位置是否在捕捉区域内部,不在捕捉区域内则暂停自动滚动
21292145 if (!recordRect.contains (mouseMovePoint))
21302146 return ;
21312147 if (m_scrollShot) {
2132- int time = int (QDateTime::currentDateTime ().toTime_t ());
2133- float len = (event->delta () > 15.0 ) ? -15.0 : 15.0 ; // 获取滚轮方向
2134- int direction = (fabs (double (len) - 15.0 ) <= EPSILON ) ? 5 : 4 ; // 获取滚轮方向
2135- scrollShotMouseScrollEvent (time, direction, x, y);
2148+ if (m_isErrorWithScrollShot)
2149+ return ;
2150+
2151+ qint64 time = QDateTime::currentMSecsSinceEpoch ();
2152+ float len = (event->delta () > 0 ) ? -5.0 : 5.0 ; // 获取滚轮方向
2153+ int direction = (fabs (double (len) - 5.0 ) <= EPSILON ) ? 5 : 4 ; // 获取滚轮方向
2154+ m_scrollShotType = ScrollShotType::ManualScroll;
2155+ if (m_scrollShotStatus == 0 ) {
2156+ scrollShotMouseScrollEvent (time, direction, x, y);
2157+ }
21362158 m_scrollShot->sigalWheelScrolling (len);
2159+ QTimer::singleShot (200 , this , [ = ] {
2160+ if (m_scrollShot && status::scrollshot == m_functionType && !m_isErrorWithScrollShot) {
2161+ scrollShotMouseScrollEvent (QDateTime::currentMSecsSinceEpoch (), direction, x, y);
2162+ }
2163+ });
21372164 qDebug () << __FUNCTION__ << __LINE__;
21382165 }
21392166#endif
@@ -5204,15 +5231,10 @@ void MainWindow::scrollShotMouseMoveEvent(int x, int y)
52045231 * @param x 当前的x坐标
52055232 * @param y 当前的y坐标
52065233 */
5207- void MainWindow::scrollShotMouseScrollEvent (int mouseTime, int direction, int x, int y)
5234+ void MainWindow::scrollShotMouseScrollEvent (qint64 mouseTime, int direction, int x, int y)
52085235{
52095236#ifdef OCR_SCROLL_FLAGE_ON
5210- QRect recordRect {
5211- static_cast <int >(recordX * m_pixelRatio),
5212- static_cast <int >(recordY * m_pixelRatio),
5213- static_cast <int >(recordWidth * m_pixelRatio),
5214- static_cast <int >(recordHeight * m_pixelRatio)
5215- };
5237+ QRect recordRect (recordX, recordY, recordWidth, recordHeight);
52165238 // 当前鼠标滚动的点
52175239 QPoint mouseScrollPoint (x, y);
52185240 // 判断鼠标滚动的位置是否是在捕捉区域内部,不在捕捉区域内部不进行处理
0 commit comments