mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
dock: change the rendering mechanism of HighlightEffect
This commit is contained in:
parent
ea0e018bd6
commit
736ea569df
@ -158,7 +158,8 @@ void AppItem::initBackground()
|
||||
|
||||
void AppItem::initHighlight()
|
||||
{
|
||||
m_highlight = new HighlightEffect(m_appIcon,this);
|
||||
m_highlight = new HighlightEffect(m_appIcon, this);
|
||||
m_highlight->setFixedSize(this->size());
|
||||
m_highlight->move(m_appIcon->pos());
|
||||
connect(this, &AppItem::mouseEntered, m_highlight, &HighlightEffect::showLighter);
|
||||
connect(this, &AppItem::mouseExited, m_highlight, &HighlightEffect::showNormal);
|
||||
|
@ -59,24 +59,21 @@ void HighlightEffect::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPixmap pixmap = m_source->grab();
|
||||
|
||||
switch (m_effectState)
|
||||
{
|
||||
case ESDarker:
|
||||
pixmapDarker(&pixmap);
|
||||
break;
|
||||
case ESLighter:
|
||||
pixmapLigher(&pixmap);
|
||||
default:
|
||||
break;
|
||||
QPainter painter;
|
||||
painter.begin(&pixmap);
|
||||
|
||||
painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
||||
|
||||
if (m_effectState == ESLighter) {
|
||||
painter.fillRect(pixmap.rect(), QColor::fromRgbF(1, 1, 1, 0.3));
|
||||
} else if (m_effectState == ESDarker) {
|
||||
painter.fillRect(pixmap.rect(), QColor::fromRgbF(0, 0, 0, 0.3));
|
||||
}
|
||||
|
||||
QPainter painter;
|
||||
painter.end();
|
||||
|
||||
painter.begin(this);
|
||||
|
||||
painter.setClipRect(rect());
|
||||
|
||||
painter.drawPixmap(0, 0, pixmap);
|
||||
|
||||
painter.end();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user