mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
fix(preview): hovering preview picture size adjust
Change-Id: Ia01bc9bc73a2bac53a911effa3095f826d8472be
This commit is contained in:
parent
b1333a2795
commit
6417a6255c
@ -55,6 +55,11 @@ WId FloatingPreview::trackedWid() const
|
||||
return m_tracked->wid();
|
||||
}
|
||||
|
||||
AppSnapshot *FloatingPreview::trackedWindow()
|
||||
{
|
||||
return m_tracked;
|
||||
}
|
||||
|
||||
void FloatingPreview::trackWindow(AppSnapshot * const snap)
|
||||
{
|
||||
if (!m_tracked.isNull())
|
||||
@ -134,6 +139,13 @@ bool FloatingPreview::eventFilter(QObject *watched, QEvent *event)
|
||||
return QWidget::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void FloatingPreview::hideEvent(QHideEvent *event)
|
||||
{
|
||||
m_tracked->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
QWidget::hideEvent(event);
|
||||
}
|
||||
|
||||
void FloatingPreview::onCloseBtnClicked()
|
||||
{
|
||||
Q_ASSERT(!m_tracked.isNull());
|
||||
|
@ -38,6 +38,7 @@ public:
|
||||
explicit FloatingPreview(QWidget *parent = 0);
|
||||
|
||||
WId trackedWid() const;
|
||||
AppSnapshot *trackedWindow();
|
||||
|
||||
signals:
|
||||
void requestMove(const QPoint &p) const;
|
||||
@ -46,9 +47,10 @@ public slots:
|
||||
void trackWindow(AppSnapshot * const snap);
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void mouseReleaseEvent(QMouseEvent *e);
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
void hideEvent(QHideEvent *event) override;
|
||||
|
||||
private slots:
|
||||
void onCloseBtnClicked();
|
||||
|
@ -185,6 +185,7 @@ void PreviewContainer::leaveEvent(QEvent *e)
|
||||
{
|
||||
QWidget::leaveEvent(e);
|
||||
|
||||
m_floatingPreview->setVisible(false);
|
||||
m_mouseLeaveTimer->start();
|
||||
}
|
||||
|
||||
@ -213,10 +214,21 @@ void PreviewContainer::previewEntered(const WId wid)
|
||||
return;
|
||||
|
||||
AppSnapshot *snap = static_cast<AppSnapshot *>(sender());
|
||||
if (!snap) {
|
||||
return;
|
||||
}
|
||||
snap->setContentsMargins(100, 0, 100, 0);
|
||||
|
||||
m_floatingPreview->trackWindow(snap);
|
||||
m_floatingPreview->setVisible(true);
|
||||
m_floatingPreview->raise();
|
||||
AppSnapshot *preSnap = m_floatingPreview->trackedWindow();
|
||||
if (preSnap && preSnap != snap) {
|
||||
preSnap->setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
QTimer::singleShot(0, [=] {
|
||||
m_floatingPreview->trackWindow(snap);
|
||||
m_floatingPreview->setVisible(true);
|
||||
m_floatingPreview->raise();
|
||||
});
|
||||
|
||||
emit requestPreviewWindow(wid);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user