paint -> paintPanel. allows one to use the Svg api directly when you have a PanelSvg class and falls into line with the resize->resizePanel change as well.
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=801077
This commit is contained in:
parent
fe9e21934d
commit
de3ab77f26
@ -1019,7 +1019,7 @@ void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
|
||||
formFactor() != Plasma::Vertical &&
|
||||
formFactor() != Plasma::Horizontal) {
|
||||
//kDebug() << "option rect is" << option->rect;
|
||||
d->background->paint(painter, option->rect, QPointF(0,0));
|
||||
d->background->paintPanel(painter, option->rect, QPointF(0,0));
|
||||
}
|
||||
if (!d->failed) {
|
||||
if (widget && isContainment()) {
|
||||
|
@ -94,7 +94,7 @@ void Dialog::paintEvent(QPaintEvent *e)
|
||||
p.setClipRect(e->rect());
|
||||
p.setCompositionMode(QPainter::CompositionMode_Source );
|
||||
p.fillRect(rect(), Qt::transparent);
|
||||
d->background->paint(&p, e->rect());
|
||||
d->background->paintPanel(&p, e->rect());
|
||||
}
|
||||
|
||||
void Dialog::resizeEvent(QResizeEvent *e)
|
||||
|
30
panelsvg.cpp
30
panelsvg.cpp
@ -271,7 +271,7 @@ void PanelSvg::clearCache()
|
||||
d->panels[d->prefix] = panel;
|
||||
}
|
||||
|
||||
void PanelSvg::paint(QPainter* painter, const QRectF& rect, const QPointF& pos)
|
||||
void PanelSvg::paintPanel(QPainter* painter, const QRectF& rect, const QPointF& pos)
|
||||
{
|
||||
PanelData *panel = d->panels[d->prefix];
|
||||
if (!panel->cachedBackground) {
|
||||
@ -335,7 +335,7 @@ void PanelSvg::Private::generateBackground(PanelData *panel)
|
||||
{
|
||||
QPainter centerPainter(¢er);
|
||||
centerPainter.setCompositionMode(QPainter::CompositionMode_Source);
|
||||
q->Svg::paint(¢erPainter, QPoint(0, 0), prefix + "center");
|
||||
q->paint(¢erPainter, QPoint(0, 0), prefix + "center");
|
||||
}
|
||||
|
||||
p.drawTiledPixmap(QRect(contentLeft - panel->leftWidth, contentTop - panel->topHeight,
|
||||
@ -351,7 +351,7 @@ void PanelSvg::Private::generateBackground(PanelData *panel)
|
||||
panel->panelSize.height()*(((qreal)(panel->topHeight + panel->bottomHeight)) / panel->panelSize.height()));
|
||||
|
||||
q->resize(scaledSize.width(), scaledSize.height());
|
||||
q->Svg::paint(&p, QRect(contentLeft - panel->leftWidth, contentTop - panel->topHeight,
|
||||
q->paint(&p, QRect(contentLeft - panel->leftWidth, contentTop - panel->topHeight,
|
||||
contentWidth + panel->leftWidth*2, contentHeight + panel->topHeight*2),
|
||||
prefix + "center");
|
||||
q->resize();
|
||||
@ -366,7 +366,7 @@ void PanelSvg::Private::generateBackground(PanelData *panel)
|
||||
}
|
||||
|
||||
if (panel->enabledBorders & LeftBorder) {
|
||||
q->Svg::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) {
|
||||
contentLeft = panel->leftWidth;
|
||||
@ -375,13 +375,13 @@ void PanelSvg::Private::generateBackground(PanelData *panel)
|
||||
}
|
||||
|
||||
if (panel->enabledBorders & RightBorder) {
|
||||
q->Svg::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 (panel->enabledBorders & LeftBorder) {
|
||||
q->Svg::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) {
|
||||
contentLeft = panel->leftWidth;
|
||||
@ -390,26 +390,26 @@ void PanelSvg::Private::generateBackground(PanelData *panel)
|
||||
}
|
||||
|
||||
if (panel->enabledBorders & RightBorder) {
|
||||
q->Svg::paint(&p, QRect(rightOffset, bottomOffset, panel->rightWidth, panel->bottomHeight), prefix + "bottomright");
|
||||
q->paint(&p, QRect(rightOffset, bottomOffset, panel->rightWidth, panel->bottomHeight), prefix + "bottomright");
|
||||
}
|
||||
}
|
||||
|
||||
// Sides
|
||||
if (panel->stretchBorders) {
|
||||
if (panel->enabledBorders & LeftBorder) {
|
||||
q->Svg::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) {
|
||||
q->Svg::paint(&p, QRect(rightOffset, contentTop, panel->rightWidth, contentHeight), prefix + "right");
|
||||
q->paint(&p, QRect(rightOffset, contentTop, panel->rightWidth, contentHeight), prefix + "right");
|
||||
}
|
||||
|
||||
if (panel->enabledBorders & TopBorder) {
|
||||
q->Svg::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) {
|
||||
q->Svg::paint(&p, QRect(contentLeft, bottomOffset, contentWidth, panel->bottomHeight), prefix + "bottom");
|
||||
q->paint(&p, QRect(contentLeft, bottomOffset, contentWidth, panel->bottomHeight), prefix + "bottom");
|
||||
}
|
||||
} else {
|
||||
if (panel->enabledBorders & LeftBorder) {
|
||||
@ -419,7 +419,7 @@ void PanelSvg::Private::generateBackground(PanelData *panel)
|
||||
{
|
||||
QPainter sidePainter(&left);
|
||||
sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
|
||||
q->Svg::paint(&sidePainter, QPoint(0, 0), prefix + "left");
|
||||
q->paint(&sidePainter, QPoint(0, 0), prefix + "left");
|
||||
}
|
||||
|
||||
p.drawTiledPixmap(QRect(leftOffset, contentTop, panel->leftWidth, contentHeight), left);
|
||||
@ -432,7 +432,7 @@ void PanelSvg::Private::generateBackground(PanelData *panel)
|
||||
{
|
||||
QPainter sidePainter(&right);
|
||||
sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
|
||||
q->Svg::paint(&sidePainter, QPoint(0, 0), prefix + "right");
|
||||
q->paint(&sidePainter, QPoint(0, 0), prefix + "right");
|
||||
}
|
||||
|
||||
p.drawTiledPixmap(QRect(rightOffset, contentTop, panel->rightWidth, contentHeight), right);
|
||||
@ -445,7 +445,7 @@ void PanelSvg::Private::generateBackground(PanelData *panel)
|
||||
{
|
||||
QPainter sidePainter(&top);
|
||||
sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
|
||||
q->Svg::paint(&sidePainter, QPoint(0, 0), prefix + "top");
|
||||
q->paint(&sidePainter, QPoint(0, 0), prefix + "top");
|
||||
}
|
||||
|
||||
p.drawTiledPixmap(QRect(contentLeft, topOffset, contentWidth, panel->topHeight), top);
|
||||
@ -458,7 +458,7 @@ void PanelSvg::Private::generateBackground(PanelData *panel)
|
||||
{
|
||||
QPainter sidePainter(&bottom);
|
||||
sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
|
||||
q->Svg::paint(&sidePainter, QPoint(0, 0), prefix + "bottom");
|
||||
q->paint(&sidePainter, QPoint(0, 0), prefix + "bottom");
|
||||
}
|
||||
|
||||
p.drawTiledPixmap(QRect(contentLeft, bottomOffset, contentWidth, panel->bottomHeight), bottom);
|
||||
|
@ -59,7 +59,8 @@ class PLASMA_EXPORT PanelSvg : public Svg
|
||||
|
||||
/**
|
||||
* Constructs a new PanelSvg that paints the proper named subelements
|
||||
* as borders
|
||||
* as borders. It may also be used as a regular Plasma::Svg object
|
||||
* for direct access to elements in the Svg.
|
||||
*
|
||||
* @arg parent options QObject to parent this to
|
||||
*
|
||||
@ -157,7 +158,7 @@ class PLASMA_EXPORT PanelSvg : public Svg
|
||||
* @arg painter the QPainter to use
|
||||
* @arg rect the exposed rect to draw into
|
||||
*/
|
||||
Q_INVOKABLE void paint(QPainter* painter, const QRectF& rect, const QPointF& pos = QPointF(0, 0));
|
||||
Q_INVOKABLE void paintPanel(QPainter* painter, const QRectF& rect, const QPointF& pos = QPointF(0, 0));
|
||||
|
||||
Q_SIGNALS:
|
||||
void repaintNeeded();
|
||||
|
Loading…
Reference in New Issue
Block a user