From aaab3a310aee19c47b6b61bd938f605455c2f222 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Sun, 27 Jul 2008 17:20:27 +0000 Subject: [PATCH] API change: changed paintPanel(QPainter* painter, const QRectF& rect, const QPointF& pos = QPointF(0, 0)); into void paintPanel(QPainter* painter, const QRectF& target, const QRectF& source); and void paintPanel(QPainter* painter, const QPointF& pos = QPointF(0, 0)); to be more similat di QPainter::drawPixmap api svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=838379 --- applet.cpp | 2 +- dialog.cpp | 2 +- panelsvg.cpp | 16 +++++++++++++--- panelsvg.h | 13 +++++++++++-- tooltip.cpp | 2 +- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/applet.cpp b/applet.cpp index 49a43c244..e33875b39 100644 --- a/applet.cpp +++ b/applet.cpp @@ -880,7 +880,7 @@ void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW formFactor() != Plasma::Vertical && formFactor() != Plasma::Horizontal) { //kDebug() << "option rect is" << option->rect; - d->background->paintPanel(p, option->rect, QPointF(0,0)); + d->background->paintPanel(p); } if (!d->failed) { diff --git a/dialog.cpp b/dialog.cpp index a72316d4a..4f3b8e047 100644 --- a/dialog.cpp +++ b/dialog.cpp @@ -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->paintPanel(&p, e->rect()); + d->background->paintPanel(&p); } void Dialog::resizeEvent(QResizeEvent *e) diff --git a/panelsvg.cpp b/panelsvg.cpp index 880893ed6..cd0402e7f 100644 --- a/panelsvg.cpp +++ b/panelsvg.cpp @@ -353,16 +353,26 @@ void PanelSvg::clearCache() } } -void PanelSvg::paintPanel(QPainter* painter, const QRectF& rect, const QPointF& pos) +void PanelSvg::paintPanel(QPainter* painter, const QRectF& target, const QRectF& source) { - //kDebug(); PanelData *panel = d->panels[d->prefix]; if (!panel->cachedBackground) { d->generateBackground(panel); Q_ASSERT(panel->cachedBackground); } - painter->drawPixmap(rect, *(panel->cachedBackground), rect.translated(-pos.x(),-pos.y())); + painter->drawPixmap(target, *(panel->cachedBackground), source); +} + +void PanelSvg::paintPanel(QPainter* painter, const QPointF& pos) +{ + PanelData *panel = d->panels[d->prefix]; + if (!panel->cachedBackground) { + d->generateBackground(panel); + Q_ASSERT(panel->cachedBackground); + } + + painter->drawPixmap(pos, *(panel->cachedBackground)); } void PanelSvgPrivate::generateBackground(PanelData *panel) diff --git a/panelsvg.h b/panelsvg.h index e36dab06a..7edfcd901 100644 --- a/panelsvg.h +++ b/panelsvg.h @@ -191,9 +191,18 @@ class PLASMA_EXPORT PanelSvg : public Svg /** * Paints the loaded SVG with the elements that represents the border * @arg painter the QPainter to use - * @arg rect the exposed rect to draw into + * @arg target the target rectangle on the paint device + * @arg source the portion rectangle of the source image */ - Q_INVOKABLE void paintPanel(QPainter* painter, const QRectF& rect, const QPointF& pos = QPointF(0, 0)); + Q_INVOKABLE void paintPanel(QPainter* painter, const QRectF& target, const QRectF& source); + + /** + * Paints the loaded SVG with the elements that represents the border + * This is an overloaded member provided for convenience + * @arg painter the QPainter to use + * @arg pos where to paint the svg + */ + Q_INVOKABLE void paintPanel(QPainter* painter, const QPointF& pos = QPointF(0, 0)); private: PanelSvgPrivate * const d; diff --git a/tooltip.cpp b/tooltip.cpp index 58046822d..a154a66e6 100644 --- a/tooltip.cpp +++ b/tooltip.cpp @@ -169,7 +169,7 @@ void ToolTip::paintEvent(QPaintEvent *e) painter.setCompositionMode(QPainter::CompositionMode_Source ); painter.fillRect(rect(), Qt::transparent); - d->background->paintPanel(&painter, rect()); + d->background->paintPanel(&painter); } void ToolTip::sourceDestroyed()