mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
fix: quick click on the preview window will crash
This commit is contained in:
parent
55c4c74a82
commit
d5e586fc98
@ -66,9 +66,6 @@ AppSnapshot::AppSnapshot(const WId wid, QWidget *parent)
|
||||
m_closeBtn2D->setVisible(false);
|
||||
m_title->setObjectName("AppSnapshotTitle");
|
||||
|
||||
m_waitLeaveTimer->setInterval(200);
|
||||
m_waitLeaveTimer->setSingleShot(true);
|
||||
|
||||
QHBoxLayout *centralLayout = new QHBoxLayout;
|
||||
centralLayout->addWidget(m_title);
|
||||
centralLayout->addWidget(m_closeBtn2D);
|
||||
@ -83,9 +80,6 @@ AppSnapshot::AppSnapshot(const WId wid, QWidget *parent)
|
||||
|
||||
connect(m_closeBtn2D, &DImageButton::clicked, this, &AppSnapshot::closeWindow, Qt::QueuedConnection);
|
||||
connect(m_wmHelper, &DWindowManagerHelper::hasCompositeChanged, this, &AppSnapshot::compositeChanged, Qt::QueuedConnection);
|
||||
connect(m_waitLeaveTimer, &QTimer::timeout, this, [=] {
|
||||
emit entered(wid);
|
||||
});
|
||||
QTimer::singleShot(1, this, &AppSnapshot::compositeChanged);
|
||||
}
|
||||
|
||||
@ -208,7 +202,7 @@ void AppSnapshot::enterEvent(QEvent *e)
|
||||
m_closeBtn2D->setVisible(true);
|
||||
}
|
||||
else {
|
||||
m_waitLeaveTimer->start();
|
||||
emit entered(wid());
|
||||
}
|
||||
|
||||
update();
|
||||
@ -219,7 +213,8 @@ void AppSnapshot::leaveEvent(QEvent *e)
|
||||
QWidget::leaveEvent(e);
|
||||
|
||||
m_closeBtn2D->setVisible(false);
|
||||
m_waitLeaveTimer->stop();
|
||||
|
||||
emit leaved(wid());
|
||||
|
||||
update();
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ public:
|
||||
|
||||
signals:
|
||||
void entered(const WId wid) const;
|
||||
void leaved(const WId wid) const;
|
||||
void clicked(const WId wid) const;
|
||||
void requestCheckWindow() const;
|
||||
|
||||
|
@ -47,12 +47,17 @@ PreviewContainer::PreviewContainer(QWidget *parent)
|
||||
|
||||
m_floatingPreview->setVisible(false);
|
||||
|
||||
m_waitForShowPreviewTimer = new QTimer(this);
|
||||
m_waitForShowPreviewTimer->setSingleShot(true);
|
||||
m_waitForShowPreviewTimer->setInterval(200);
|
||||
|
||||
setAcceptDrops(true);
|
||||
setLayout(m_windowListLayout);
|
||||
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);
|
||||
}
|
||||
|
||||
void PreviewContainer::setWindowInfos(const WindowInfoMap &infos, const WindowList &allowClose)
|
||||
@ -164,6 +169,7 @@ void PreviewContainer::appendSnapWidget(const WId wid)
|
||||
connect(snap, &AppSnapshot::clicked, this, &PreviewContainer::onSnapshotClicked, Qt::QueuedConnection);
|
||||
connect(snap, &AppSnapshot::entered, this, &PreviewContainer::previewEntered, Qt::QueuedConnection);
|
||||
connect(snap, &AppSnapshot::requestCheckWindow, this, &PreviewContainer::requestCheckWindows);
|
||||
connect(snap, &AppSnapshot::leaved, m_waitForShowPreviewTimer, &QTimer::stop);
|
||||
|
||||
m_windowListLayout->addWidget(snap);
|
||||
|
||||
@ -187,6 +193,7 @@ void PreviewContainer::leaveEvent(QEvent *e)
|
||||
QWidget::leaveEvent(e);
|
||||
|
||||
m_mouseLeaveTimer->start();
|
||||
m_waitForShowPreviewTimer->stop();
|
||||
}
|
||||
|
||||
void PreviewContainer::dragEnterEvent(QDragEnterEvent *e)
|
||||
@ -233,13 +240,10 @@ void PreviewContainer::previewEntered(const WId wid)
|
||||
preSnap->setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
QTimer::singleShot(0, [=] {
|
||||
m_floatingPreview->trackWindow(snap);
|
||||
m_floatingPreview->setVisible(true);
|
||||
m_floatingPreview->raise();
|
||||
});
|
||||
m_currentWId = wid;
|
||||
|
||||
emit requestPreviewWindow(wid);
|
||||
m_floatingPreview->trackWindow(snap);
|
||||
m_waitForShowPreviewTimer->start();
|
||||
}
|
||||
|
||||
void PreviewContainer::moveFloatingPreview(const QPoint &p)
|
||||
@ -264,3 +268,11 @@ void PreviewContainer::moveFloatingPreview(const QPoint &p)
|
||||
m_floatingPreview->move(p);
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewContainer::previewFloating()
|
||||
{
|
||||
m_floatingPreview->setVisible(true);
|
||||
m_floatingPreview->raise();
|
||||
|
||||
emit requestPreviewWindow(m_currentWId);
|
||||
}
|
||||
|
@ -72,6 +72,7 @@ private slots:
|
||||
void onSnapshotClicked(const WId wid);
|
||||
void previewEntered(const WId wid);
|
||||
void moveFloatingPreview(const QPoint &p);
|
||||
void previewFloating();
|
||||
|
||||
private:
|
||||
bool m_needActivate;
|
||||
@ -82,6 +83,8 @@ private:
|
||||
|
||||
QTimer *m_mouseLeaveTimer;
|
||||
DWindowManagerHelper *m_wmHelper;
|
||||
QTimer *m_waitForShowPreviewTimer;
|
||||
WId m_currentWId;
|
||||
};
|
||||
|
||||
#endif // PREVIEWCONTAINER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user