From 45f7769d446e04b1e8db14c7ce0faf2b42d5ce0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=C4=8Cuki=C4=87?= Date: Fri, 7 Sep 2007 13:05:28 +0000 Subject: [PATCH] Added stretched paint mode for background painting svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=709407 --- applet.cpp | 72 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 31 deletions(-) diff --git a/applet.cpp b/applet.cpp index 181774202..d6bb8ff88 100644 --- a/applet.cpp +++ b/applet.cpp @@ -210,41 +210,49 @@ public: background->paint(&p, QRect(leftOffset, bottomOffset, leftWidth, bottomHeight), "bottomleft"); background->paint(&p, QRect(rightOffset, bottomOffset, rightWidth, bottomHeight), "bottomright"); - QPixmap left(leftWidth, leftHeight); - left.fill(Qt::transparent); - { - QPainter sidePainter(&left); - sidePainter.setCompositionMode(QPainter::CompositionMode_Source); - background->paint(&sidePainter, QPoint(0, 0), "left"); - } - p.drawTiledPixmap(QRect(leftOffset, contentTop, leftWidth, contentHeight), left); + if (stretchBackgroundBorders) { + background->paint(&p, QRect(leftOffset, contentTop, leftWidth, contentHeight), "left"); + background->paint(&p, QRect(rightOffset, contentTop, rightWidth, contentHeight), "right"); + background->paint(&p, QRect(contentLeft, topOffset, contentWidth, topHeight), "top"); + background->paint(&p, QRect(contentLeft, bottomOffset, contentWidth, bottomHeight), "bottom"); + } else { - QPixmap right(rightWidth, leftHeight); - right.fill(Qt::transparent); - { - QPainter sidePainter(&right); - sidePainter.setCompositionMode(QPainter::CompositionMode_Source); - background->paint(&sidePainter, QPoint(0, 0), "right"); - } - p.drawTiledPixmap(QRect(rightOffset, contentTop, rightWidth, contentHeight), right); + QPixmap left(leftWidth, leftHeight); + left.fill(Qt::transparent); + { + QPainter sidePainter(&left); + sidePainter.setCompositionMode(QPainter::CompositionMode_Source); + background->paint(&sidePainter, QPoint(0, 0), "left"); + } + p.drawTiledPixmap(QRect(leftOffset, contentTop, leftWidth, contentHeight), left); - QPixmap top(topWidth, topHeight); - top.fill(Qt::transparent); - { - QPainter sidePainter(&top); - sidePainter.setCompositionMode(QPainter::CompositionMode_Source); - background->paint(&sidePainter, QPoint(0, 0), "top"); - } - p.drawTiledPixmap(QRect(contentLeft, topOffset, contentWidth, topHeight), top); + QPixmap right(rightWidth, leftHeight); + right.fill(Qt::transparent); + { + QPainter sidePainter(&right); + sidePainter.setCompositionMode(QPainter::CompositionMode_Source); + background->paint(&sidePainter, QPoint(0, 0), "right"); + } + p.drawTiledPixmap(QRect(rightOffset, contentTop, rightWidth, contentHeight), right); - QPixmap bottom(topWidth, bottomHeight); - bottom.fill(Qt::transparent); - { - QPainter sidePainter(&bottom); - sidePainter.setCompositionMode(QPainter::CompositionMode_Source); - background->paint(&sidePainter, QPoint(0, 0), "bottom"); + QPixmap top(topWidth, topHeight); + top.fill(Qt::transparent); + { + QPainter sidePainter(&top); + sidePainter.setCompositionMode(QPainter::CompositionMode_Source); + background->paint(&sidePainter, QPoint(0, 0), "top"); + } + p.drawTiledPixmap(QRect(contentLeft, topOffset, contentWidth, topHeight), top); + + QPixmap bottom(topWidth, bottomHeight); + bottom.fill(Qt::transparent); + { + QPainter sidePainter(&bottom); + sidePainter.setCompositionMode(QPainter::CompositionMode_Source); + background->paint(&sidePainter, QPoint(0, 0), "bottom"); + } + p.drawTiledPixmap(QRect(contentLeft, bottomOffset, contentWidth, bottomHeight), bottom); } - p.drawTiledPixmap(QRect(contentLeft, bottomOffset, contentWidth, bottomHeight), bottom); background->paint(&p, QRect(contentLeft, contentTop, contentWidth + 1, contentHeight + 1), "center"); p.end(); @@ -319,6 +327,7 @@ public: QStringList loadedEngines; static uint s_maxAppletId; Plasma::Svg *background; + bool stretchBackgroundBorders; Plasma::LineEdit *failureText; ScriptEngine* scriptEngine; ConfigXml* configXml; @@ -526,6 +535,7 @@ void Applet::setDrawStandardBackground(bool drawBackground) if (!d->background) { prepareGeometryChange(); d->background = new Plasma::Svg("widgets/background"); + d->stretchBackgroundBorders = d->background->elementExists("hint-stretch-borders"); } } else if (d->background) { prepareGeometryChange();