mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix(preview): float preview background have wrong offset
taskID=5332
This commit is contained in:
parent
f1441cc1e7
commit
06c827091e
@ -68,11 +68,9 @@ void FloatingPreview::trackWindow(AppSnapshot * const snap)
|
|||||||
m_tracked = snap;
|
m_tracked = snap;
|
||||||
m_closeBtn3D->setVisible(m_tracked->closeAble());
|
m_closeBtn3D->setVisible(m_tracked->closeAble());
|
||||||
|
|
||||||
const QRect r = rect();
|
QTimer::singleShot(0, this, [=] {
|
||||||
const QRect sr = snap->geometry();
|
setGeometry(snap->geometry());
|
||||||
const QPoint offset = sr.center() - r.center();
|
});
|
||||||
|
|
||||||
emit requestMove(offset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FloatingPreview::paintEvent(QPaintEvent *e)
|
void FloatingPreview::paintEvent(QPaintEvent *e)
|
||||||
|
@ -40,9 +40,6 @@ public:
|
|||||||
WId trackedWid() const;
|
WId trackedWid() const;
|
||||||
AppSnapshot *trackedWindow();
|
AppSnapshot *trackedWindow();
|
||||||
|
|
||||||
signals:
|
|
||||||
void requestMove(const QPoint &p) const;
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void trackWindow(AppSnapshot * const snap);
|
void trackWindow(AppSnapshot * const snap);
|
||||||
|
|
||||||
|
@ -56,7 +56,6 @@ PreviewContainer::PreviewContainer(QWidget *parent)
|
|||||||
setFixedSize(SNAP_WIDTH, SNAP_HEIGHT);
|
setFixedSize(SNAP_WIDTH, SNAP_HEIGHT);
|
||||||
|
|
||||||
connect(m_mouseLeaveTimer, &QTimer::timeout, this, &PreviewContainer::checkMouseLeave, Qt::QueuedConnection);
|
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);
|
connect(m_waitForShowPreviewTimer, &QTimer::timeout, this, &PreviewContainer::previewFloating);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,29 +249,6 @@ void PreviewContainer::previewEntered(const WId wid)
|
|||||||
m_waitForShowPreviewTimer->start();
|
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()
|
void PreviewContainer::previewFloating()
|
||||||
{
|
{
|
||||||
m_floatingPreview->setVisible(true);
|
m_floatingPreview->setVisible(true);
|
||||||
|
@ -71,7 +71,6 @@ private:
|
|||||||
private slots:
|
private slots:
|
||||||
void onSnapshotClicked(const WId wid);
|
void onSnapshotClicked(const WId wid);
|
||||||
void previewEntered(const WId wid);
|
void previewEntered(const WId wid);
|
||||||
void moveFloatingPreview(const QPoint &p);
|
|
||||||
void previewFloating();
|
void previewFloating();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user