Fix drawing of selection for QGtkStyle
BUG:85 BUG:86
This commit is contained in:
@@ -72,12 +72,16 @@ void FancyTabWidget::drawGtkSelection(const QStyleOptionViewItemV4 &opt, QPainte
|
||||
static const int constMaxDimension=32;
|
||||
static QCache<QString, QPixmap> cache(30000);
|
||||
|
||||
if (opt.rect.width()<2 || opt.rect.height()<2) {
|
||||
return;
|
||||
}
|
||||
|
||||
int width=qMin(constMaxDimension, opt.rect.width());
|
||||
QString key=QString::number(width)+QChar(':')+QString::number(opt.rect.height());
|
||||
QPixmap *pix=cache.object(key);
|
||||
|
||||
if (!pix) {
|
||||
pix=new QPixmap(opt.rect.width(), opt.rect.height());
|
||||
pix=new QPixmap(width, opt.rect.height());
|
||||
QStyleOptionViewItemV4 styleOpt(opt);
|
||||
pix->fill(Qt::transparent);
|
||||
QPainter p(pix);
|
||||
@@ -96,9 +100,9 @@ void FancyTabWidget::drawGtkSelection(const QStyleOptionViewItemV4 &opt, QPainte
|
||||
int half=qMin(opt.rect.width()>>1, pix->width()>>1);
|
||||
painter->drawPixmap(opt.rect.x(), opt.rect.y(), pix->copy(0, 0, half, pix->height()));
|
||||
if ((half*2)!=opt.rect.width()) {
|
||||
painter->drawTiledPixmap(opt.rect.x()+half, opt.rect.y(), (opt.rect.width()-(2*half)), opt.rect.height(), pix->copy(half-1, 0, 1, pix->height()));
|
||||
painter->drawTiledPixmap(opt.rect.x()+half, opt.rect.y(), (opt.rect.width()-((2*half))), opt.rect.height(), pix->copy(half-1, 0, 1, pix->height()));
|
||||
}
|
||||
painter->drawPixmap((opt.rect.x()+opt.rect.width()-1)-half, opt.rect.y(), pix->copy(half-1, 0, half, pix->height()));
|
||||
painter->drawPixmap((opt.rect.x()+opt.rect.width())-half, opt.rect.y(), pix->copy(half, 0, half, pix->height()));
|
||||
} else {
|
||||
painter->drawPixmap(opt.rect, *pix);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user