paint the background as the same size of the progress bar, no more empty
areas before and after support for stretched bars svn path=/trunk/KDE/kdelibs/; revision=900723
This commit is contained in:
parent
38ab27d842
commit
d1e083f211
@ -122,11 +122,41 @@ public:
|
|||||||
|
|
||||||
QRectF barRect()
|
QRectF barRect()
|
||||||
{
|
{
|
||||||
|
QRectF elementRect;
|
||||||
|
|
||||||
if (labels.count() > 0) {
|
if (labels.count() > 0) {
|
||||||
return image->elementRect("background");
|
elementRect = image->elementRect("background");
|
||||||
} else {
|
} else {
|
||||||
return QRectF(QPoint(0,0), meter->size());
|
elementRect = QRectF(QPoint(0,0), meter->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (image->hasElement("hint-bar-stretch")) {
|
||||||
|
return elementRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize imageSize = image->size();
|
||||||
|
image->resize();
|
||||||
|
QSize tileSize = image->elementSize("bar-active-center");
|
||||||
|
|
||||||
|
if (elementRect.width() > elementRect.height()) {
|
||||||
|
qreal ratio = tileSize.height() / tileSize.width();
|
||||||
|
int numTiles = elementRect.width()/(elementRect.height()/ratio);
|
||||||
|
tileSize = QSize(elementRect.width()/numTiles, elementRect.height());
|
||||||
|
|
||||||
|
QPoint center = elementRect.center().toPoint();
|
||||||
|
elementRect.setWidth(tileSize.width()*numTiles);
|
||||||
|
elementRect.moveCenter(center);
|
||||||
|
} else {
|
||||||
|
qreal ratio = tileSize.width() / tileSize.height();
|
||||||
|
int numTiles = elementRect.height()/(elementRect.width()/ratio);
|
||||||
|
tileSize = QSize(elementRect.width(), elementRect.height()/numTiles);
|
||||||
|
|
||||||
|
QPoint center = elementRect.center().toPoint();
|
||||||
|
elementRect.setHeight(tileSize.height()*numTiles);
|
||||||
|
elementRect.moveCenter(center);
|
||||||
|
}
|
||||||
|
|
||||||
|
return elementRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
void paintBackground(QPainter *p)
|
void paintBackground(QPainter *p)
|
||||||
@ -151,6 +181,11 @@ public:
|
|||||||
void paintBar(QPainter *p, const QString &prefix)
|
void paintBar(QPainter *p, const QString &prefix)
|
||||||
{
|
{
|
||||||
QRectF elementRect = barRect();
|
QRectF elementRect = barRect();
|
||||||
|
|
||||||
|
if (image->hasElement("hint-bar-stretch")) {
|
||||||
|
image->resizeFrame(elementRect.size());
|
||||||
|
image->paintFrame(p);
|
||||||
|
} else {
|
||||||
QSize imageSize = image->size();
|
QSize imageSize = image->size();
|
||||||
image->resize();
|
image->resize();
|
||||||
QSize tileSize = image->elementSize("bar-active-center");
|
QSize tileSize = image->elementSize("bar-active-center");
|
||||||
@ -159,18 +194,10 @@ public:
|
|||||||
qreal ratio = tileSize.height() / tileSize.width();
|
qreal ratio = tileSize.height() / tileSize.width();
|
||||||
int numTiles = elementRect.width()/(elementRect.height()/ratio);
|
int numTiles = elementRect.width()/(elementRect.height()/ratio);
|
||||||
tileSize = QSize(elementRect.width()/numTiles, elementRect.height());
|
tileSize = QSize(elementRect.width()/numTiles, elementRect.height());
|
||||||
|
|
||||||
QPoint center = elementRect.center().toPoint();
|
|
||||||
elementRect.setWidth(tileSize.width()*numTiles);
|
|
||||||
elementRect.moveCenter(center);
|
|
||||||
} else {
|
} else {
|
||||||
qreal ratio = tileSize.width() / tileSize.height();
|
qreal ratio = tileSize.width() / tileSize.height();
|
||||||
int numTiles = elementRect.height()/(elementRect.width()/ratio);
|
int numTiles = elementRect.height()/(elementRect.width()/ratio);
|
||||||
tileSize = QSize(elementRect.width(), elementRect.height()/numTiles);
|
tileSize = QSize(elementRect.width(), elementRect.height()/numTiles);
|
||||||
|
|
||||||
QPoint center = elementRect.center().toPoint();
|
|
||||||
elementRect.setHeight(tileSize.height()*numTiles);
|
|
||||||
elementRect.moveCenter(center);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
image->setElementPrefix(prefix);
|
image->setElementPrefix(prefix);
|
||||||
@ -178,6 +205,7 @@ public:
|
|||||||
p->drawTiledPixmap(elementRect, image->framePixmap());
|
p->drawTiledPixmap(elementRect, image->framePixmap());
|
||||||
image->resize(imageSize);
|
image->resize(imageSize);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void paintForeground(QPainter *p)
|
void paintForeground(QPainter *p)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user