diff --git a/applet.cpp b/applet.cpp index 714e7f8b7..a2f34681a 100644 --- a/applet.cpp +++ b/applet.cpp @@ -143,7 +143,7 @@ public: QString packageFormat = appletDescription.property("X-Plasma-PackageFormat").toString(); if (packageFormat.isEmpty()) { - package = new Package(path, PlasmoidPackage()); + package = new Package(path, PackageStructure::Ptr(new PlasmoidPackage())); } else { package = new Package(path, PackageStructure::load(packageFormat)); } @@ -288,6 +288,7 @@ public: // number of members at this point. static uint s_maxAppletId; static uint s_maxZValue; + static PackageStructure::Ptr packageStructure; uint appletId; KPluginInfo appletDescription; Package* package; @@ -314,6 +315,7 @@ public: uint Applet::Private::s_maxAppletId = 0; uint Applet::Private::s_maxZValue = 0; +PackageStructure::Ptr Applet::Private::packageStructure(0); Applet::Applet(QGraphicsItem *parent, const QString& serviceID, @@ -344,9 +346,13 @@ Applet::~Applet() delete d; } -PackageStructure Applet::packageStructure() +PackageStructure::Ptr Applet::packageStructure() { - return PlasmoidPackage(); + if (!Private::packageStructure) { + Private::packageStructure = new PlasmoidPackage(); + } + + return Private::packageStructure; } void Applet::init() @@ -1001,6 +1007,14 @@ void Applet::setContentSize(int width, int height) QSizeF Applet::contentSizeHint() const { + static bool checkingScript = false; + + if (!checkingScript && d->script) { + checkingScript = true; + return d->script->contentSizeHint(); + } + + checkingScript = false; QSizeF size; if (layout()) { size = layout()->sizeHint(); diff --git a/applet.h b/applet.h index d4bdf07cc..f20012bf0 100644 --- a/applet.h +++ b/applet.h @@ -24,9 +24,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include @@ -104,7 +104,7 @@ class PLASMA_EXPORT Applet : public Widget /** * @return a package structure representing a Theme */ - static PackageStructure packageStructure(); + static PackageStructure::Ptr packageStructure(); /** * This method is called once the applet is loaded and added to a Corona. diff --git a/theme.cpp b/theme.cpp index 3f9b79606..030861882 100644 --- a/theme.cpp +++ b/theme.cpp @@ -60,6 +60,7 @@ public: QString findInTheme(const QString &image, const QString &theme) const; static const char *defaultTheme; + static PackageStructure::Ptr packageStructure; QString themeName; QString app; KSharedConfigPtr colors; @@ -71,6 +72,7 @@ public: #endif }; +PackageStructure::Ptr Theme::Private::packageStructure(0); const char *Theme::Private::defaultTheme = "default"; class ThemeSingleton @@ -113,9 +115,13 @@ Theme::~Theme() delete d; } -PackageStructure Theme::packageStructure() +PackageStructure::Ptr Theme::packageStructure() { - return ThemePackage(); + if (!Private::packageStructure) { + Private::packageStructure = new ThemePackage(); + } + + return Private::packageStructure; } void Theme::setApplication(const QString &appname) diff --git a/theme.h b/theme.h index 20f5b5b81..f714ab96e 100644 --- a/theme.h +++ b/theme.h @@ -67,7 +67,7 @@ class PLASMA_EXPORT Theme : public QObject /** * @return a package structure representing a Theme */ - static PackageStructure packageStructure(); + static PackageStructure::Ptr packageStructure(); /** * Sets the application the theme setting is associated with. This