don't paint the title if there isn't a title to paint
svn path=/trunk/KDE/kdelibs/; revision=1111855
This commit is contained in:
parent
65ca45681f
commit
61ca96b034
@ -523,34 +523,37 @@ void ExtenderItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
rect = QRectF(0, 0, 30, d->titleRect().height());
|
||||
}
|
||||
|
||||
QPixmap pixmap(d->titleRect().size().toSize());
|
||||
pixmap.fill(Qt::transparent);
|
||||
QSize titleSize = d->titleRect().size().toSize();
|
||||
if (!titleSize.isEmpty()) {
|
||||
QPixmap pixmap(titleSize);
|
||||
pixmap.fill(Qt::transparent);
|
||||
|
||||
QPainter p(&pixmap);
|
||||
p.setPen(theme->color(Plasma::Theme::TextColor));
|
||||
p.setFont(font);
|
||||
p.drawText(QRectF(QPointF(0, 0), d->titleRect().size()),
|
||||
Qt::TextSingleLine | Qt::AlignVCenter | Qt::AlignLeft,
|
||||
d->title);
|
||||
QPainter p(&pixmap);
|
||||
p.setPen(theme->color(Plasma::Theme::TextColor));
|
||||
p.setFont(font);
|
||||
p.drawText(QRectF(QPointF(0, 0), d->titleRect().size()),
|
||||
Qt::TextSingleLine | Qt::AlignVCenter | Qt::AlignLeft,
|
||||
d->title);
|
||||
|
||||
// Create the alpha gradient for the fade out effect
|
||||
QLinearGradient alphaGradient(0, 0, 1, 0);
|
||||
alphaGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
|
||||
//TODO: correct handling of right to left text.
|
||||
if (option->direction == Qt::LeftToRight) {
|
||||
alphaGradient.setColorAt(0, QColor(0, 0, 0, 255));
|
||||
alphaGradient.setColorAt(1, QColor(0, 0, 0, 0));
|
||||
} else {
|
||||
alphaGradient.setColorAt(1, QColor(0, 0, 0, 255));
|
||||
alphaGradient.setColorAt(0, QColor(0, 0, 0, 0));
|
||||
// Create the alpha gradient for the fade out effect
|
||||
QLinearGradient alphaGradient(0, 0, 1, 0);
|
||||
alphaGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
|
||||
//TODO: correct handling of right to left text.
|
||||
if (option->direction == Qt::LeftToRight) {
|
||||
alphaGradient.setColorAt(0, QColor(0, 0, 0, 255));
|
||||
alphaGradient.setColorAt(1, QColor(0, 0, 0, 0));
|
||||
} else {
|
||||
alphaGradient.setColorAt(1, QColor(0, 0, 0, 255));
|
||||
alphaGradient.setColorAt(0, QColor(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
||||
p.fillRect(rect, alphaGradient);
|
||||
|
||||
p.end();
|
||||
|
||||
painter->drawPixmap(d->titleRect().topLeft(), pixmap);
|
||||
}
|
||||
|
||||
p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
||||
p.fillRect(rect, alphaGradient);
|
||||
|
||||
p.end();
|
||||
|
||||
painter->drawPixmap(d->titleRect().topLeft(), pixmap);
|
||||
}
|
||||
|
||||
void ExtenderItem::moveEvent(QGraphicsSceneMoveEvent *event)
|
||||
|
Loading…
Reference in New Issue
Block a user