support attention

Change-Id: I5caf72dc3575294205e60bdb77897bf18500a7f5
This commit is contained in:
石博文 2018-02-22 14:19:52 +08:00
parent c0986e1c37
commit 3cc3ccb5a3
Notes: Deepin Code Review 2018-02-22 14:33:34 +08:00
Verified+1: Anonymous Coward #1000004
Code-Review+2: 石博文 <sbw@sbw.so>
Submitted-by: 石博文 <sbw@sbw.so>
Submitted-at: Thu, 22 Feb 2018 14:33:34 +0800
Reviewed-on: https://cr.deepin.io/31805
Project: dde/dde-dock
Branch: refs/heads/master
5 changed files with 41 additions and 16 deletions

View File

@ -158,6 +158,7 @@ AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
m_updateIconGeometryTimer->setSingleShot(true);
m_appPreviewTips->setVisible(false);
m_itemEntryInter->setSync(false);
connect(m_itemEntryInter, &DockEntryInter::IsActiveChanged, this, &AppItem::activeChanged);
connect(m_itemEntryInter, &DockEntryInter::IsActiveChanged, this, static_cast<void (AppItem::*)()>(&AppItem::update));
@ -171,7 +172,7 @@ AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
connect(m_appPreviewTips, &PreviewContainer::requestCancelAndHidePreview, this, &AppItem::cancelAndHidePreview);
connect(m_appPreviewTips, &PreviewContainer::requestCheckWindows, m_itemEntryInter, &DockEntryInter::Check);
updateWindowInfos();
updateWindowInfos(m_itemEntryInter->windowInfos());
refershIcon();
}
@ -283,9 +284,12 @@ void AppItem::paintEvent(QPaintEvent *e)
painter.fillRect(activeRect, QColor(44, 167, 248, 255));
}
else if (!m_windowInfos.isEmpty())
painter.fillRect(backgroundRect, QColor(255, 255, 255, 255 * 0.2));
// else
// painter.fillRect(backgroundRect, Qt::gray);
{
if (hasAttention())
painter.fillRect(backgroundRect, QColor(241, 138, 46, 255 * .8));
else
painter.fillRect(backgroundRect, QColor(255, 255, 255, 255 * 0.2));
}
}
else
{
@ -524,7 +528,7 @@ QWidget *AppItem::popupTips()
{
const quint32 currentWindow = m_itemEntryInter->currentWindow();
Q_ASSERT(m_windowInfos.contains(currentWindow));
m_appNameTips->setText(m_windowInfos[currentWindow].m_windowTitle);
m_appNameTips->setText(m_windowInfos[currentWindow].title);
} else {
m_appNameTips->setText(m_itemEntryInter->name());
}
@ -557,9 +561,17 @@ void AppItem::startDrag()
update();
}
void AppItem::updateWindowInfos()
bool AppItem::hasAttention() const
{
m_windowInfos = m_itemEntryInter->windowInfos();
for (const auto &info : m_windowInfos)
if (info.attention)
return true;
return false;
}
void AppItem::updateWindowInfos(const WindowInfoMap &info)
{
m_windowInfos = info;
m_appPreviewTips->setWindowInfos(m_windowInfos);
m_updateIconGeometryTimer->start();

View File

@ -74,9 +74,10 @@ private:
QWidget *popupTips();
void startDrag();
bool hasAttention() const;
private slots:
void updateWindowInfos();
void updateWindowInfos(const WindowInfoMap &info);
void refershIcon();
void activeChanged();
void showPreview();

View File

@ -87,12 +87,13 @@ void AppSnapshot::compositeChanged() const
const bool composite = m_wmHelper->hasComposite();
m_title->setVisible(!composite);
// m_closeBtn->setVisible(!composite);
}
void AppSnapshot::setWindowTitle(const QString &title)
void AppSnapshot::setWindowInfo(const WindowInfo &info)
{
m_title->setText(title);
m_windowInfo = info;
m_title->setText(m_windowInfo.title);
}
void AppSnapshot::dragEnterEvent(QDragEnterEvent *e)
@ -181,6 +182,7 @@ void AppSnapshot::paintEvent(QPaintEvent *e)
QWidget::paintEvent(e);
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
if (!m_wmHelper->hasComposite())
{
@ -195,9 +197,15 @@ void AppSnapshot::paintEvent(QPaintEvent *e)
const QRect r = rect().marginsRemoved(QMargins(8, 8, 8, 8));
const auto ratio = devicePixelRatioF();
// draw attention background
if (m_windowInfo.attention)
{
painter.setBrush(QColor(241, 138, 46, 255 * .8));
painter.setPen(Qt::NoPen);
painter.drawRoundedRect(rect(), 5, 5);
}
// draw image
// QImage im = m_snapshot.scaled(r.size() * ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation);
// im.setDevicePixelRatio(ratio);
const QImage &im = m_snapshot;
const QRect ir = im.rect();

View File

@ -30,6 +30,8 @@
#include <dimagebutton.h>
#include <DWindowManagerHelper>
#include <com_deepin_dde_daemon_dock_entry.h>
DWIDGET_USE_NAMESPACE
#define SNAP_WIDTH 200
@ -43,8 +45,9 @@ 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 QString title() const { return m_title->text(); }
const QString title() const { return m_windowInfo.title; }
signals:
void entered(const WId wid) const;
@ -55,7 +58,7 @@ public slots:
void fetchSnapshot();
void closeWindow() const;
void compositeChanged() const;
void setWindowTitle(const QString &title);
void setWindowInfo(const WindowInfo &info);
private:
void dragEnterEvent(QDragEnterEvent *e);
@ -67,6 +70,7 @@ private:
private:
const WId m_wid;
WindowInfo m_windowInfo;
QImage m_snapshot;
QLabel *m_title;
DImageButton *m_closeBtn;

View File

@ -74,7 +74,7 @@ void PreviewContainer::setWindowInfos(const WindowInfoMap &infos)
{
if (!m_snapshots.contains(it.key()))
appendSnapWidget(it.key());
m_snapshots[it.key()]->setWindowTitle(it.value().m_windowTitle);
m_snapshots[it.key()]->setWindowInfo(it.value());
}
if (m_snapshots.isEmpty())