diff --git a/applet.cpp b/applet.cpp index 212c7cc09..9f58cdae6 100644 --- a/applet.cpp +++ b/applet.cpp @@ -782,7 +782,8 @@ void Applet::setDrawStandardBackground(bool drawBackground) { if (drawBackground) { if (!d->background) { - d->background = new Plasma::PanelSvg("widgets/background"); + d->background = new Plasma::PanelSvg(); + d->background->setImagePath("widgets/background"); d->background->setEnabledBorders(Plasma::PanelSvg::AllBorders); int left, top, right, bottom; d->getBorderSize(left, top, right, bottom); diff --git a/dialog.cpp b/dialog.cpp index 22f211b53..54cd4cdc5 100644 --- a/dialog.cpp +++ b/dialog.cpp @@ -71,7 +71,8 @@ Dialog::Dialog( QWidget * parent, Qt::WindowFlags f ) d(new Private) { d->q = this; - d->background = new PanelSvg("dialogs/background", this); + d->background = new PanelSvg(this); + d->background->setImagePath("dialogs/background"); d->background->setEnabledBorders(PanelSvg::AllBorders); d->background->resize(size()); diff --git a/panelsvg.cpp b/panelsvg.cpp index c13119cf4..89e621991 100644 --- a/panelsvg.cpp +++ b/panelsvg.cpp @@ -35,6 +35,7 @@ public: PanelData() : enabledBorders(PanelSvg::AllBorders), cachedBackground(0), + panelSize(-1,-1), contentAtOrigin(false) { } @@ -90,15 +91,13 @@ public: QHash panels; }; -PanelSvg::PanelSvg(const QString& imagePath, QObject* parent) - : Svg(imagePath, parent), +PanelSvg::PanelSvg(QObject* parent) + : Svg(parent), d(new Private(this)) { connect(this, SIGNAL(repaintNeeded()), this, SLOT(updateSizes())); d->panels.insert(QString(), new PanelData()); - d->updateSizes(); - d->panels[QString()]->panelSize = size(); } PanelSvg::~PanelSvg() @@ -112,9 +111,13 @@ void PanelSvg::setImagePath(const QString& path) return; } + Svg::setImagePath(path); + qDeleteAll(d->panels); - setImagePath(path); + d->panels.insert(QString(), new PanelData()); + d->updateSizes(); + d->panels[QString()]->panelSize = size(); } void PanelSvg::setEnabledBorders(const EnabledBorders borders) diff --git a/panelsvg.h b/panelsvg.h index 78ca5a1a5..de7e6f02c 100644 --- a/panelsvg.h +++ b/panelsvg.h @@ -69,7 +69,7 @@ class PLASMA_EXPORT PanelSvg : public Svg * * @related Plasma::Theme */ - explicit PanelSvg(const QString& imagePath, QObject* parent = 0); + explicit PanelSvg(QObject* parent = 0); ~PanelSvg(); /** diff --git a/svg.cpp b/svg.cpp index f11c43b85..8d84d8389 100644 --- a/svg.cpp +++ b/svg.cpp @@ -63,13 +63,12 @@ class SharedSvgRenderer : public KSvgRenderer, public QSharedData class Svg::Private { public: - Private(const QString& imagePath, Svg *svg) + Private(Svg *svg) : q(svg), renderer(0), multipleImages(false), themed(false) { - setImagePath(imagePath, q); } ~Private() @@ -290,9 +289,9 @@ class Svg::Private QHash Svg::Private::renderers; -Svg::Svg(const QString& imagePath, QObject* parent) +Svg::Svg(QObject* parent) : QObject(parent), - d(new Private(imagePath, this)) + d(new Private(this)) { } diff --git a/svg.h b/svg.h index a0a81555b..d41b0cc09 100644 --- a/svg.h +++ b/svg.h @@ -69,7 +69,7 @@ class PLASMA_EXPORT Svg : public QObject * * @related Plasma::Theme */ - explicit Svg(const QString& imagePath = QString(), QObject* parent = 0); + explicit Svg(QObject* parent = 0); ~Svg(); diff --git a/widgets/icon.cpp b/widgets/icon.cpp index 69f14bcc2..c505ec04e 100644 --- a/widgets/icon.cpp +++ b/widgets/icon.cpp @@ -471,11 +471,11 @@ void Icon::layoutIcons(const QStyleOptionGraphicsItem *option) void Icon::setSvg(const QString &svgFilePath, const QString &elementId) { if (!d->iconSvg) { - d->iconSvg = new Plasma::Svg(svgFilePath); - } else { - d->iconSvg->setImagePath(svgFilePath); + d->iconSvg = new Plasma::Svg(); } + d->iconSvg->setImagePath(svgFilePath); + d->iconSvgElement = elementId; } diff --git a/widgets/meter.cpp b/widgets/meter.cpp index c8101018a..e6aaef66a 100644 --- a/widgets/meter.cpp +++ b/widgets/meter.cpp @@ -243,7 +243,8 @@ void Meter::setSvg(const QString &svg) { d->svg = svg; delete d->image; - d->image = new Plasma::Svg(svg, this); + d->image = new Plasma::Svg(this); + d->image->setImagePath(svg); // To create renderer and get default size d->image->resize(); d->setSizePolicyAndPreferredSize(); diff --git a/widgets/signalplotter.cpp b/widgets/signalplotter.cpp index 17689cebf..5244ab170 100644 --- a/widgets/signalplotter.cpp +++ b/widgets/signalplotter.cpp @@ -455,7 +455,8 @@ void SignalPlotter::setSvgBackground(const QString &filename) if (!d->svgFilename.isEmpty()) { if (d->svgBackground) delete d->svgBackground; - d->svgBackground = new Svg(d->svgFilename); + d->svgBackground = new Svg(); + d->svgBackground->setImagePath(d->svgFilename); } }