fix: 修复mips架构特效模式下,多窗口预览重叠问题

预览放大时的跟随窗口setGeometry所使用的AppSnapshot::geometry()还不是最终的值,所以导致跟随窗口的位置错误

Log: 优化mips架构特效模式下多窗口预览效果
Bug: https://pms.uniontech.com/zentao/bug-view-82885.html
Change-Id: Ief368927388129b6d755be5fe1a975d838a45f7a
This commit is contained in:
yanghongwei 2021-06-25 20:09:48 +08:00
parent 19cc7effa0
commit 03102c905e

View File

@ -107,7 +107,9 @@ void FloatingPreview::trackWindow(AppSnapshot *const snap)
}
QTimer::singleShot(0, this, [ = ] {
setGeometry(snap->geometry());
// 此处获取的snap->geometry()有可能是错误的所以做个判断并且在resizeEvent中也做处理
if(snap->width() == SNAP_WIDTH)
setGeometry(snap->geometry());
});
}
@ -136,17 +138,6 @@ void FloatingPreview::paintEvent(QPaintEvent *e)
DStyleHelper dstyle(style());
const int radius = dstyle.pixelMetric(DStyle::PM_FrameRadius);
// 预览图
QBrush brush;
brush.setTextureImage(snapshot);
painter.setBrush(brush);
painter.setPen(Qt::NoPen);
painter.scale(1 / ratio, 1 / ratio);
painter.translate(QPoint(offset_x * ratio, offset_y * ratio));
painter.drawRoundedRect(snapshot_geometry, radius * ratio, radius * ratio);
painter.translate(QPoint(-offset_x * ratio, -offset_y * ratio));
painter.scale(ratio, ratio);
// 选中外框
QPen pen;
pen.setColor(palette().highlight().color());
@ -179,8 +170,13 @@ bool FloatingPreview::eventFilter(QObject *watched, QEvent *event)
}
}
if (watched == m_tracked && event->type() == QEvent::Destroy)
hide();
if (watched == m_tracked) {
if (event->type() == QEvent::Destroy)
hide();
if (event->type() == QEvent::Resize && m_tracked->width() == SNAP_WIDTH)
setGeometry(m_tracked->geometry());
}
return QWidget::eventFilter(watched, event);
}