fix: 移动鼠标任务栏跳动

在高分屏开2.75倍缩放时,通过qt获取的任务栏高度不正常(实际为40,获取的值为39)导致显示动画可以重复执行。

Log: 修复移动鼠标任务栏跳动的问题。
Bug: https://pms.uniontech.com/zentao/bug-view-50417.html
Change-Id: I72e5c7239c785d1016866e420d49b15cd3031962
Reviewed-on: http://gerrit.uniontech.com/c/dde-dock/+/7059
Reviewed-by: <mailman@uniontech.com>
Reviewed-by: fanpengcheng <fanpengcheng@uniontech.com>
Tested-by: <mailman@uniontech.com>
This commit is contained in:
Zhang Qipeng 2020-10-10 18:19:13 +08:00 committed by zhangqipeng
parent cb91fdfe48
commit 2714dfa26c

View File

@ -1073,6 +1073,43 @@ void MultiScreenWorker::displayAnimation(const QString &screen, const Position &
if (!m_autoHide || m_draging || m_aniStart || m_hideAniStart || m_showAniStart)
return;
QRect mainwindowRect = parent()->geometry();
QRect dockShowRect = getDockShowGeometry(screen, pos, m_displayMode);
QRect dockHideRect = getDockHideGeometry(screen, pos, m_displayMode);
/** FIXME
* 2.75parent()->geometry()40,39
* 3842
* 1
*
*/
switch (act) {
case AniAction::Show:
if (pos == Position::Top || pos == Position::Bottom) {
if (dockShowRect.height() > mainwindowRect.height() - 2
&& dockShowRect.height() < mainwindowRect.height() + 2) {
emit requestNotifyWindowManager();
return;
}
} else if (pos == Position::Left || pos == Position::Right) {
if (dockShowRect.width() > mainwindowRect.width() - 2
&& dockShowRect.width() < mainwindowRect.width() + 2) {
emit requestNotifyWindowManager();
return;
}
}
break;
case AniAction::Hide:
if (dockHideRect == mainwindowRect) {
emit requestNotifyWindowManager();
return;
}
break;
default:
Q_UNREACHABLE();
break;
}
QVariantAnimation *ani = new QVariantAnimation(this);
ani->setEasingCurve(QEasingCurve::InOutCubic);
@ -1084,25 +1121,17 @@ void MultiScreenWorker::displayAnimation(const QString &screen, const Position &
#endif
ani->setDuration(duration);
ani->setStartValue(getDockHideGeometry(screen, pos, m_displayMode));
ani->setEndValue(getDockShowGeometry(screen, pos, m_displayMode));
ani->setStartValue(dockHideRect);
ani->setEndValue(dockShowRect);
switch (act) {
case AniAction::Show:
if (getDockShowGeometry(screen, pos, m_displayMode) == parent()->geometry()) {
emit requestNotifyWindowManager();
return;
}
ani->setDirection(QAbstractAnimation::Forward);
connect(ani, &QVariantAnimation::finished, this, &MultiScreenWorker::showAniFinished);
connect(this, &MultiScreenWorker::requestStopShowAni, ani, &QVariantAnimation::stop);
break;
case AniAction::Hide:
if (getDockHideGeometry(screen, pos, m_displayMode) == parent()->geometry()) {
emit requestNotifyWindowManager();
return;
}
ani->setDirection(QAbstractAnimation::Backward); // 隐藏时动画反向走
connect(ani, &QVariantAnimation::finished, this, &MultiScreenWorker::hideAniFinished);
connect(this, &MultiScreenWorker::requestStopHideAni, ani, &QVariantAnimation::stop);