less ugly with svg based painting
svn path=/trunk/KDE/kdelibs/; revision=972776
This commit is contained in:
parent
559b8a38af
commit
9c3ebb58a9
14
delegate.cpp
14
delegate.cpp
@ -372,7 +372,8 @@ void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
|||||||
|
|
||||||
const int column = index.column();
|
const int column = index.column();
|
||||||
const int columns = index.model()->columnCount();
|
const int columns = index.model()->columnCount();
|
||||||
const int roundedRadius = 5;
|
int roundedRadius = 5;
|
||||||
|
const bool useSvg = option.palette.color(QPalette::Base).alpha() == 0;
|
||||||
|
|
||||||
// use a slightly translucent version of the palette's highlight color
|
// use a slightly translucent version of the palette's highlight color
|
||||||
// for the background
|
// for the background
|
||||||
@ -389,6 +390,9 @@ void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
|||||||
if (column == 0) {
|
if (column == 0) {
|
||||||
//clip right (or left for rtl languages) to make the connection with the next column
|
//clip right (or left for rtl languages) to make the connection with the next column
|
||||||
if (columns > 1) {
|
if (columns > 1) {
|
||||||
|
if (useSvg) {
|
||||||
|
roundedRadius = d->svg->marginSize(Plasma::RightMargin);
|
||||||
|
}
|
||||||
painter->setClipRect(option.rect);
|
painter->setClipRect(option.rect);
|
||||||
highlightRect.adjust(0, 0, roundedRadius, 0);
|
highlightRect.adjust(0, 0, roundedRadius, 0);
|
||||||
}
|
}
|
||||||
@ -411,17 +415,23 @@ void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
|||||||
|
|
||||||
//last column, clip left (right for rtl)
|
//last column, clip left (right for rtl)
|
||||||
} else if (column == columns-1) {
|
} else if (column == columns-1) {
|
||||||
|
if (useSvg) {
|
||||||
|
roundedRadius = d->svg->marginSize(Plasma::LeftMargin);
|
||||||
|
}
|
||||||
painter->setClipRect(option.rect);
|
painter->setClipRect(option.rect);
|
||||||
highlightRect.adjust(-roundedRadius, 0, 0, 0);
|
highlightRect.adjust(-roundedRadius, 0, 0, 0);
|
||||||
|
|
||||||
//column < columns-1; clip both ways
|
//column < columns-1; clip both ways
|
||||||
} else {
|
} else {
|
||||||
|
if (useSvg) {
|
||||||
|
roundedRadius = d->svg->marginSize(Plasma::LeftMargin);
|
||||||
|
}
|
||||||
painter->setClipRect(option.rect);
|
painter->setClipRect(option.rect);
|
||||||
highlightRect.adjust(-roundedRadius, 0, +roundedRadius, 0);
|
highlightRect.adjust(-roundedRadius, 0, +roundedRadius, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if the view is transparent paint as plasma, otherwise paint with kde colors
|
//if the view is transparent paint as plasma, otherwise paint with kde colors
|
||||||
if (option.palette.color(QPalette::Base).alpha() > 0) {
|
if (!useSvg) {
|
||||||
painter->setPen(outlinePen);
|
painter->setPen(outlinePen);
|
||||||
painter->drawPath(PaintUtils::roundedRectangle(highlightRect, roundedRadius));
|
painter->drawPath(PaintUtils::roundedRectangle(highlightRect, roundedRadius));
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user