mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
add(preview): support identify window closeable
There is no close button when previewing a window that cannot be closed Change-Id: Ic97f1fdd287fad1c06578e1745d526da61d0088e
This commit is contained in:
parent
85b7d50857
commit
8b084117f8
Notes:
gerrit
2018-10-08 11:46:48 +08:00
Verified+1: <jenkins@deepin.com> Code-Review+2: listenerri <listenerri@gmail.com> Submitted-by: listenerri <listenerri@gmail.com> Submitted-at: Mon, 08 Oct 2018 11:46:48 +0800 Reviewed-on: https://cr.deepin.io/37688 Project: dde/dde-dock Branch: refs/heads/master
@ -494,7 +494,7 @@ bool AppItem::hasAttention() const
|
||||
void AppItem::updateWindowInfos(const WindowInfoMap &info)
|
||||
{
|
||||
m_windowInfos = info;
|
||||
if (m_appPreviewTips) m_appPreviewTips->setWindowInfos(m_windowInfos);
|
||||
if (m_appPreviewTips) m_appPreviewTips->setWindowInfos(m_windowInfos, m_itemEntryInter->GetAllowedCloseWindows().value());
|
||||
m_updateIconGeometryTimer->start();
|
||||
|
||||
// process attention effect
|
||||
@ -549,7 +549,7 @@ void AppItem::showPreview()
|
||||
if (m_windowInfos.isEmpty())
|
||||
return;
|
||||
|
||||
m_appPreviewTips = PreviewWindow(m_windowInfos, DockPosition);
|
||||
m_appPreviewTips = PreviewWindow(m_windowInfos, m_itemEntryInter->GetAllowedCloseWindows().value(), DockPosition);
|
||||
|
||||
connect(m_appPreviewTips, &PreviewContainer::requestActivateWindow, this, &AppItem::requestActivateWindow, Qt::QueuedConnection);
|
||||
connect(m_appPreviewTips, &PreviewContainer::requestPreviewWindow, this, &AppItem::requestPreviewWindow, Qt::QueuedConnection);
|
||||
|
@ -48,11 +48,13 @@ class AppSnapshot : public QWidget
|
||||
public:
|
||||
explicit AppSnapshot(const WId wid, QWidget *parent = 0);
|
||||
|
||||
WId wid() const { return m_wid; }
|
||||
bool attentioned() const { return m_windowInfo.attention; }
|
||||
const QImage snapshot() const { return m_snapshot; }
|
||||
const QRectF snapshotGeometry() const { return m_snapshotSrcRect; }
|
||||
const QString title() const { return m_windowInfo.title; }
|
||||
inline WId wid() const { return m_wid; }
|
||||
inline bool attentioned() const { return m_windowInfo.attention; }
|
||||
inline bool closeAble() const { return m_closeAble; }
|
||||
inline void setCloseAble(const bool value) { m_closeAble = value; }
|
||||
inline const QImage snapshot() const { return m_snapshot; }
|
||||
inline const QRectF snapshotGeometry() const { return m_snapshotSrcRect; }
|
||||
inline const QString title() const { return m_windowInfo.title; }
|
||||
|
||||
signals:
|
||||
void entered(const WId wid) const;
|
||||
@ -78,8 +80,10 @@ private:
|
||||
|
||||
private:
|
||||
const WId m_wid;
|
||||
|
||||
WindowInfo m_windowInfo;
|
||||
|
||||
bool m_closeAble;
|
||||
|
||||
QImage m_snapshot;
|
||||
QRectF m_snapshotSrcRect;
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "previewcontainer.h"
|
||||
|
||||
static PreviewContainer *PreviewWindow(const WindowInfoMap &infos, const Dock::Position dockPos)
|
||||
static PreviewContainer *PreviewWindow(const WindowInfoMap &infos, const WindowList &allowClose, const Dock::Position dockPos)
|
||||
{
|
||||
static PreviewContainer *preview;
|
||||
if (!preview) {
|
||||
@ -12,7 +12,7 @@ static PreviewContainer *PreviewWindow(const WindowInfoMap &infos, const Dock::P
|
||||
}
|
||||
|
||||
preview->disconnect();
|
||||
preview->setWindowInfos(infos);
|
||||
preview->setWindowInfos(infos, allowClose);
|
||||
preview->updateSnapshots();
|
||||
preview->updateLayoutDirection(dockPos);
|
||||
|
||||
|
@ -61,6 +61,7 @@ void FloatingPreview::trackWindow(AppSnapshot * const snap)
|
||||
m_tracked->removeEventFilter(this);
|
||||
snap->installEventFilter(this);
|
||||
m_tracked = snap;
|
||||
m_closeBtn->setVisible(m_tracked->closeAble());
|
||||
|
||||
const QRect r = rect();
|
||||
const QRect sr = snap->geometry();
|
||||
|
@ -55,7 +55,7 @@ PreviewContainer::PreviewContainer(QWidget *parent)
|
||||
connect(m_floatingPreview, &FloatingPreview::requestMove, this, &PreviewContainer::moveFloatingPreview);
|
||||
}
|
||||
|
||||
void PreviewContainer::setWindowInfos(const WindowInfoMap &infos)
|
||||
void PreviewContainer::setWindowInfos(const WindowInfoMap &infos, const WindowList &allowClose)
|
||||
{
|
||||
// check removed window
|
||||
for (auto it(m_snapshots.begin()); it != m_snapshots.end();)
|
||||
@ -72,9 +72,11 @@ void PreviewContainer::setWindowInfos(const WindowInfoMap &infos)
|
||||
|
||||
for (auto it(infos.cbegin()); it != infos.cend(); ++it)
|
||||
{
|
||||
if (!m_snapshots.contains(it.key()))
|
||||
appendSnapWidget(it.key());
|
||||
m_snapshots[it.key()]->setWindowInfo(it.value());
|
||||
const WId key = it.key();
|
||||
if (!m_snapshots.contains(key))
|
||||
appendSnapWidget(key);
|
||||
m_snapshots[key]->setWindowInfo(it.value());
|
||||
m_snapshots[key]->setCloseAble(allowClose.contains(key));
|
||||
}
|
||||
|
||||
if (m_snapshots.isEmpty())
|
||||
|
@ -50,7 +50,7 @@ signals:
|
||||
void requestCancelAndHidePreview() const;
|
||||
|
||||
public:
|
||||
void setWindowInfos(const WindowInfoMap &infos);
|
||||
void setWindowInfos(const WindowInfoMap &infos, const WindowList &allowClose);
|
||||
void updateSnapshots();
|
||||
|
||||
public slots:
|
||||
|
Loading…
x
Reference in New Issue
Block a user