fix(preview): float preview background have wrong offset

taskID=5332
This commit is contained in:
justforlxz 2019-05-22 18:51:09 +08:00
parent f1441cc1e7
commit 06c827091e
No known key found for this signature in database
GPG Key ID: 593AFD577C1B1A60
4 changed files with 3 additions and 33 deletions

View File

@ -68,11 +68,9 @@ void FloatingPreview::trackWindow(AppSnapshot * const snap)
m_tracked = snap;
m_closeBtn3D->setVisible(m_tracked->closeAble());
const QRect r = rect();
const QRect sr = snap->geometry();
const QPoint offset = sr.center() - r.center();
emit requestMove(offset);
QTimer::singleShot(0, this, [=] {
setGeometry(snap->geometry());
});
}
void FloatingPreview::paintEvent(QPaintEvent *e)

View File

@ -40,9 +40,6 @@ public:
WId trackedWid() const;
AppSnapshot *trackedWindow();
signals:
void requestMove(const QPoint &p) const;
public slots:
void trackWindow(AppSnapshot * const snap);

View File

@ -56,7 +56,6 @@ PreviewContainer::PreviewContainer(QWidget *parent)
setFixedSize(SNAP_WIDTH, SNAP_HEIGHT);
connect(m_mouseLeaveTimer, &QTimer::timeout, this, &PreviewContainer::checkMouseLeave, Qt::QueuedConnection);
connect(m_floatingPreview, &FloatingPreview::requestMove, this, &PreviewContainer::moveFloatingPreview);
connect(m_waitForShowPreviewTimer, &QTimer::timeout, this, &PreviewContainer::previewFloating);
}
@ -250,29 +249,6 @@ void PreviewContainer::previewEntered(const WId wid)
m_waitForShowPreviewTimer->start();
}
void PreviewContainer::moveFloatingPreview(const QPoint &p)
{
const bool horizontal = m_windowListLayout->direction() == QBoxLayout::LeftToRight;
const QRect r = rect();
if (horizontal)
{
if (p.x() < r.left())
m_floatingPreview->move(MARGIN, p.y());
else if (p.x() + m_floatingPreview->width() > r.right())
m_floatingPreview->move(r.right() - m_floatingPreview->width() - MARGIN + 1, p.y());
else
m_floatingPreview->move(p);
} else {
if (p.y() < r.top())
m_floatingPreview->move(p.x(), MARGIN);
else if (p.y() + m_floatingPreview->height() > r.bottom())
m_floatingPreview->move(p.x(), r.bottom() - m_floatingPreview->height() - MARGIN + 1);
else
m_floatingPreview->move(p);
}
}
void PreviewContainer::previewFloating()
{
m_floatingPreview->setVisible(true);

View File

@ -71,7 +71,6 @@ private:
private slots:
void onSnapshotClicked(const WId wid);
void previewEntered(const WId wid);
void moveFloatingPreview(const QPoint &p);
void previewFloating();
private: