From 7093e945d517cde0604620a5ba0681f968eb7405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E5=8D=9A=E6=96=87?= Date: Mon, 22 May 2017 17:54:59 +0800 Subject: [PATCH] support activate current preview window Change-Id: I707eb139b06c6aa6c0d048806db25482c21c22d3 --- frame/item/components/_previewcontainer.cpp | 5 +++++ frame/item/components/appsnapshot.cpp | 14 ++++++++++++++ frame/item/components/appsnapshot.h | 6 ++++++ 3 files changed, 25 insertions(+) diff --git a/frame/item/components/_previewcontainer.cpp b/frame/item/components/_previewcontainer.cpp index a7e928f3c..7dc40e4b6 100644 --- a/frame/item/components/_previewcontainer.cpp +++ b/frame/item/components/_previewcontainer.cpp @@ -74,6 +74,11 @@ void _PreviewContainer::appendSnapWidget(const WId 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_snapshots.insert(wid, snap); diff --git a/frame/item/components/appsnapshot.cpp b/frame/item/components/appsnapshot.cpp index 2be89d79d..4924c2181 100644 --- a/frame/item/components/appsnapshot.cpp +++ b/frame/item/components/appsnapshot.cpp @@ -69,6 +69,13 @@ void AppSnapshot::fetchSnapshot() update(); } +void AppSnapshot::enterEvent(QEvent *e) +{ + QWidget::enterEvent(e); + + emit entered(m_wid); +} + void AppSnapshot::paintEvent(QPaintEvent *e) { QWidget::paintEvent(e); @@ -96,3 +103,10 @@ void AppSnapshot::resizeEvent(QResizeEvent *e) m_fetchSnapshotTimer->start(); } + +void AppSnapshot::mousePressEvent(QMouseEvent *e) +{ + QWidget::mousePressEvent(e); + + emit clicked(m_wid); +} diff --git a/frame/item/components/appsnapshot.h b/frame/item/components/appsnapshot.h index ce75628c0..700ad6c79 100644 --- a/frame/item/components/appsnapshot.h +++ b/frame/item/components/appsnapshot.h @@ -12,12 +12,18 @@ class AppSnapshot : public QWidget public: explicit AppSnapshot(const WId wid, QWidget *parent = 0); +signals: + void entered(const WId wid) const; + void clicked(const WId wid) const; + private slots: void fetchSnapshot(); private: + void enterEvent(QEvent *e); void paintEvent(QPaintEvent *e); void resizeEvent(QResizeEvent *e); + void mousePressEvent(QMouseEvent *e); private: const WId m_wid;