From 06c827091e7748eaad72db61ad7dd4acf6855c5e Mon Sep 17 00:00:00 2001 From: justforlxz Date: Wed, 22 May 2019 18:51:09 +0800 Subject: [PATCH] fix(preview): float preview background have wrong offset taskID=5332 --- frame/item/components/floatingpreview.cpp | 8 +++----- frame/item/components/floatingpreview.h | 3 --- frame/item/components/previewcontainer.cpp | 24 ---------------------- frame/item/components/previewcontainer.h | 1 - 4 files changed, 3 insertions(+), 33 deletions(-) diff --git a/frame/item/components/floatingpreview.cpp b/frame/item/components/floatingpreview.cpp index 3685648db..af10d9a6e 100644 --- a/frame/item/components/floatingpreview.cpp +++ b/frame/item/components/floatingpreview.cpp @@ -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) diff --git a/frame/item/components/floatingpreview.h b/frame/item/components/floatingpreview.h index dc4c7fcd2..6c13588c9 100644 --- a/frame/item/components/floatingpreview.h +++ b/frame/item/components/floatingpreview.h @@ -40,9 +40,6 @@ public: WId trackedWid() const; AppSnapshot *trackedWindow(); -signals: - void requestMove(const QPoint &p) const; - public slots: void trackWindow(AppSnapshot * const snap); diff --git a/frame/item/components/previewcontainer.cpp b/frame/item/components/previewcontainer.cpp index a62f281c3..b5ff1f299 100644 --- a/frame/item/components/previewcontainer.cpp +++ b/frame/item/components/previewcontainer.cpp @@ -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); diff --git a/frame/item/components/previewcontainer.h b/frame/item/components/previewcontainer.h index 2369c488f..f39df307b 100644 --- a/frame/item/components/previewcontainer.h +++ b/frame/item/components/previewcontainer.h @@ -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: