support activate current preview window

Change-Id: I707eb139b06c6aa6c0d048806db25482c21c22d3
This commit is contained in:
石博文 2017-05-22 17:54:59 +08:00
parent fd82c588c1
commit 7093e945d5
Notes: Deepin Code Review 2017-05-23 09:10:09 +08:00
Code-Review+2: 石博文 <sbw@sbw.so>
Verified+1: Anonymous Coward #1000004
Submitted-by: 石博文 <sbw@sbw.so>
Submitted-at: Tue, 23 May 2017 09:10:07 +0800
Reviewed-on: https://cr.deepin.io/23332
Project: dde/dde-dock
Branch: refs/heads/master
3 changed files with 25 additions and 0 deletions

View File

@ -74,6 +74,11 @@ void _PreviewContainer::appendSnapWidget(const WId wid)
{ {
AppSnapshot *snap = new AppSnapshot(wid); AppSnapshot *snap = new AppSnapshot(wid);
connect(snap, &AppSnapshot::clicked, this, &_PreviewContainer::requestActivateWindow, Qt::QueuedConnection);
connect(snap, &AppSnapshot::clicked, this, &_PreviewContainer::requestCancelPreview);
connect(snap, &AppSnapshot::clicked, this, &_PreviewContainer::requestHidePreview);
connect(snap, &AppSnapshot::entered, this, &_PreviewContainer::requestPreviewWindow);
m_windowListLayout->addWidget(snap); m_windowListLayout->addWidget(snap);
m_snapshots.insert(wid, snap); m_snapshots.insert(wid, snap);

View File

@ -69,6 +69,13 @@ void AppSnapshot::fetchSnapshot()
update(); update();
} }
void AppSnapshot::enterEvent(QEvent *e)
{
QWidget::enterEvent(e);
emit entered(m_wid);
}
void AppSnapshot::paintEvent(QPaintEvent *e) void AppSnapshot::paintEvent(QPaintEvent *e)
{ {
QWidget::paintEvent(e); QWidget::paintEvent(e);
@ -96,3 +103,10 @@ void AppSnapshot::resizeEvent(QResizeEvent *e)
m_fetchSnapshotTimer->start(); m_fetchSnapshotTimer->start();
} }
void AppSnapshot::mousePressEvent(QMouseEvent *e)
{
QWidget::mousePressEvent(e);
emit clicked(m_wid);
}

View File

@ -12,12 +12,18 @@ class AppSnapshot : public QWidget
public: public:
explicit AppSnapshot(const WId wid, QWidget *parent = 0); explicit AppSnapshot(const WId wid, QWidget *parent = 0);
signals:
void entered(const WId wid) const;
void clicked(const WId wid) const;
private slots: private slots:
void fetchSnapshot(); void fetchSnapshot();
private: private:
void enterEvent(QEvent *e);
void paintEvent(QPaintEvent *e); void paintEvent(QPaintEvent *e);
void resizeEvent(QResizeEvent *e); void resizeEvent(QResizeEvent *e);
void mousePressEvent(QMouseEvent *e);
private: private:
const WId m_wid; const WId m_wid;