dock: change the rendering mechanism of HighlightEffect

This commit is contained in:
Hualet Wang 2015-07-22 21:50:06 +08:00
parent ea0e018bd6
commit 736ea569df
2 changed files with 13 additions and 15 deletions

View File

@ -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);

View File

@ -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();
}
}