don't try to paint non existent elements

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=803865
This commit is contained in:
Marco Martin 2008-05-04 11:19:11 +00:00
parent e8ebd60879
commit ee2468472c

View File

@ -425,13 +425,13 @@ void PanelSvg::Private::generateBackground(PanelData *panel)
} }
// Corners // Corners
if (panel->enabledBorders & TopBorder) { if (q->hasElement(prefix + "top") && panel->enabledBorders & TopBorder) {
if (!origined) { if (!origined) {
contentTop = panel->topHeight; contentTop = panel->topHeight;
bottomOffset += panel->topHeight; bottomOffset += panel->topHeight;
} }
if (panel->enabledBorders & LeftBorder) { if (q->hasElement(prefix + "topleft") && panel->enabledBorders & LeftBorder) {
q->paint(&p, QRect(leftOffset, topOffset, panel->leftWidth, panel->topHeight), prefix + "topleft"); q->paint(&p, QRect(leftOffset, topOffset, panel->leftWidth, panel->topHeight), prefix + "topleft");
if (!origined) { if (!origined) {
@ -440,13 +440,13 @@ void PanelSvg::Private::generateBackground(PanelData *panel)
} }
} }
if (panel->enabledBorders & RightBorder) { if (q->hasElement(prefix + "topright") && panel->enabledBorders & RightBorder) {
q->paint(&p, QRect(rightOffset, topOffset, panel->rightWidth, panel->topHeight), prefix + "topright"); q->paint(&p, QRect(rightOffset, topOffset, panel->rightWidth, panel->topHeight), prefix + "topright");
} }
} }
if (panel->enabledBorders & BottomBorder) { if (q->hasElement(prefix + "bottom") && panel->enabledBorders & BottomBorder) {
if (panel->enabledBorders & LeftBorder) { if (q->hasElement(prefix + "bottomleft") && panel->enabledBorders & LeftBorder) {
q->paint(&p, QRect(leftOffset, bottomOffset, panel->leftWidth, panel->bottomHeight), prefix + "bottomleft"); q->paint(&p, QRect(leftOffset, bottomOffset, panel->leftWidth, panel->bottomHeight), prefix + "bottomleft");
if (!origined) { if (!origined) {
@ -455,7 +455,7 @@ void PanelSvg::Private::generateBackground(PanelData *panel)
} }
} }
if (panel->enabledBorders & RightBorder) { if (q->hasElement(prefix + "bottomright") && panel->enabledBorders & RightBorder) {
q->paint(&p, QRect(rightOffset, bottomOffset, panel->rightWidth, panel->bottomHeight), prefix + "bottomright"); q->paint(&p, QRect(rightOffset, bottomOffset, panel->rightWidth, panel->bottomHeight), prefix + "bottomright");
} }
} }
@ -465,11 +465,11 @@ void PanelSvg::Private::generateBackground(PanelData *panel)
if (panel->enabledBorders & LeftBorder || panel->enabledBorders & RightBorder) { if (panel->enabledBorders & LeftBorder || panel->enabledBorders & RightBorder) {
q->resize(q->size().width(), scaledContentSize.height()); q->resize(q->size().width(), scaledContentSize.height());
if (panel->enabledBorders & LeftBorder) { if (q->hasElement(prefix + "left") && panel->enabledBorders & LeftBorder) {
q->paint(&p, QRect(leftOffset, contentTop, panel->leftWidth, contentHeight), prefix + "left"); q->paint(&p, QRect(leftOffset, contentTop, panel->leftWidth, contentHeight), prefix + "left");
} }
if (panel->enabledBorders & RightBorder) { if (q->hasElement(prefix + "right") && panel->enabledBorders & RightBorder) {
q->paint(&p, QRect(rightOffset, contentTop, panel->rightWidth, contentHeight), prefix + "right"); q->paint(&p, QRect(rightOffset, contentTop, panel->rightWidth, contentHeight), prefix + "right");
} }
@ -479,65 +479,57 @@ void PanelSvg::Private::generateBackground(PanelData *panel)
if (panel->enabledBorders & TopBorder || panel->enabledBorders & BottomBorder) { if (panel->enabledBorders & TopBorder || panel->enabledBorders & BottomBorder) {
q->resize(scaledContentSize.width(), q->size().height()); q->resize(scaledContentSize.width(), q->size().height());
if (panel->enabledBorders & TopBorder) { if (q->hasElement(prefix + "top") && panel->enabledBorders & TopBorder) {
q->paint(&p, QRect(contentLeft, topOffset, contentWidth, panel->topHeight), prefix + "top"); q->paint(&p, QRect(contentLeft, topOffset, contentWidth, panel->topHeight), prefix + "top");
} }
if (panel->enabledBorders & BottomBorder) { if (q->hasElement(prefix + "bottom") && panel->enabledBorders & BottomBorder) {
q->paint(&p, QRect(contentLeft, bottomOffset, contentWidth, panel->bottomHeight), prefix + "bottom"); q->paint(&p, QRect(contentLeft, bottomOffset, contentWidth, panel->bottomHeight), prefix + "bottom");
} }
q->resize(); q->resize();
} }
} else { } else {
if (panel->enabledBorders & LeftBorder) { if (q->hasElement(prefix + "left") && panel->enabledBorders & LeftBorder) {
QPixmap left(panel->leftWidth, leftHeight); QPixmap left(panel->leftWidth, leftHeight);
left.fill(Qt::transparent); left.fill(Qt::transparent);
{ QPainter sidePainter(&left);
QPainter sidePainter(&left); sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
sidePainter.setCompositionMode(QPainter::CompositionMode_Source); q->paint(&sidePainter, QPoint(0, 0), prefix + "left");
q->paint(&sidePainter, QPoint(0, 0), prefix + "left");
}
p.drawTiledPixmap(QRect(leftOffset, contentTop, panel->leftWidth, contentHeight), left); p.drawTiledPixmap(QRect(leftOffset, contentTop, panel->leftWidth, contentHeight), left);
} }
if (panel->enabledBorders & RightBorder) { if (q->hasElement(prefix + "right") && panel->enabledBorders & RightBorder) {
QPixmap right(panel->rightWidth, leftHeight); QPixmap right(panel->rightWidth, leftHeight);
right.fill(Qt::transparent); right.fill(Qt::transparent);
{ QPainter sidePainter(&right);
QPainter sidePainter(&right); sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
sidePainter.setCompositionMode(QPainter::CompositionMode_Source); q->paint(&sidePainter, QPoint(0, 0), prefix + "right");
q->paint(&sidePainter, QPoint(0, 0), prefix + "right");
}
p.drawTiledPixmap(QRect(rightOffset, contentTop, panel->rightWidth, contentHeight), right); p.drawTiledPixmap(QRect(rightOffset, contentTop, panel->rightWidth, contentHeight), right);
} }
if (panel->enabledBorders & TopBorder) { if (q->hasElement(prefix + "top") && panel->enabledBorders & TopBorder) {
QPixmap top(topWidth, panel->topHeight); QPixmap top(topWidth, panel->topHeight);
top.fill(Qt::transparent); top.fill(Qt::transparent);
{ QPainter sidePainter(&top);
QPainter sidePainter(&top); sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
sidePainter.setCompositionMode(QPainter::CompositionMode_Source); q->paint(&sidePainter, QPoint(0, 0), prefix + "top");
q->paint(&sidePainter, QPoint(0, 0), prefix + "top");
}
p.drawTiledPixmap(QRect(contentLeft, topOffset, contentWidth, panel->topHeight), top); p.drawTiledPixmap(QRect(contentLeft, topOffset, contentWidth, panel->topHeight), top);
} }
if (panel->enabledBorders & BottomBorder) { if (q->hasElement(prefix + "bottom") && panel->enabledBorders & BottomBorder) {
QPixmap bottom(topWidth, panel->bottomHeight); QPixmap bottom(topWidth, panel->bottomHeight);
bottom.fill(Qt::transparent); bottom.fill(Qt::transparent);
{ QPainter sidePainter(&bottom);
QPainter sidePainter(&bottom); sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
sidePainter.setCompositionMode(QPainter::CompositionMode_Source); q->paint(&sidePainter, QPoint(0, 0), prefix + "bottom");
q->paint(&sidePainter, QPoint(0, 0), prefix + "bottom");
}
p.drawTiledPixmap(QRect(contentLeft, bottomOffset, contentWidth, panel->bottomHeight), bottom); p.drawTiledPixmap(QRect(contentLeft, bottomOffset, contentWidth, panel->bottomHeight), bottom);
} }