* share the package structures by using a single shared ptr
* use the script's contentSizeHint if we are a script svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=779417
This commit is contained in:
parent
12cea8acf1
commit
bed3c1d927
20
applet.cpp
20
applet.cpp
@ -143,7 +143,7 @@ public:
|
|||||||
QString packageFormat = appletDescription.property("X-Plasma-PackageFormat").toString();
|
QString packageFormat = appletDescription.property("X-Plasma-PackageFormat").toString();
|
||||||
|
|
||||||
if (packageFormat.isEmpty()) {
|
if (packageFormat.isEmpty()) {
|
||||||
package = new Package(path, PlasmoidPackage());
|
package = new Package(path, PackageStructure::Ptr(new PlasmoidPackage()));
|
||||||
} else {
|
} else {
|
||||||
package = new Package(path, PackageStructure::load(packageFormat));
|
package = new Package(path, PackageStructure::load(packageFormat));
|
||||||
}
|
}
|
||||||
@ -288,6 +288,7 @@ public:
|
|||||||
// number of members at this point.
|
// number of members at this point.
|
||||||
static uint s_maxAppletId;
|
static uint s_maxAppletId;
|
||||||
static uint s_maxZValue;
|
static uint s_maxZValue;
|
||||||
|
static PackageStructure::Ptr packageStructure;
|
||||||
uint appletId;
|
uint appletId;
|
||||||
KPluginInfo appletDescription;
|
KPluginInfo appletDescription;
|
||||||
Package* package;
|
Package* package;
|
||||||
@ -314,6 +315,7 @@ public:
|
|||||||
|
|
||||||
uint Applet::Private::s_maxAppletId = 0;
|
uint Applet::Private::s_maxAppletId = 0;
|
||||||
uint Applet::Private::s_maxZValue = 0;
|
uint Applet::Private::s_maxZValue = 0;
|
||||||
|
PackageStructure::Ptr Applet::Private::packageStructure(0);
|
||||||
|
|
||||||
Applet::Applet(QGraphicsItem *parent,
|
Applet::Applet(QGraphicsItem *parent,
|
||||||
const QString& serviceID,
|
const QString& serviceID,
|
||||||
@ -344,9 +346,13 @@ Applet::~Applet()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
PackageStructure Applet::packageStructure()
|
PackageStructure::Ptr Applet::packageStructure()
|
||||||
{
|
{
|
||||||
return PlasmoidPackage();
|
if (!Private::packageStructure) {
|
||||||
|
Private::packageStructure = new PlasmoidPackage();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Private::packageStructure;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Applet::init()
|
void Applet::init()
|
||||||
@ -1001,6 +1007,14 @@ void Applet::setContentSize(int width, int height)
|
|||||||
|
|
||||||
QSizeF Applet::contentSizeHint() const
|
QSizeF Applet::contentSizeHint() const
|
||||||
{
|
{
|
||||||
|
static bool checkingScript = false;
|
||||||
|
|
||||||
|
if (!checkingScript && d->script) {
|
||||||
|
checkingScript = true;
|
||||||
|
return d->script->contentSizeHint();
|
||||||
|
}
|
||||||
|
|
||||||
|
checkingScript = false;
|
||||||
QSizeF size;
|
QSizeF size;
|
||||||
if (layout()) {
|
if (layout()) {
|
||||||
size = layout()->sizeHint();
|
size = layout()->sizeHint();
|
||||||
|
8
applet.h
8
applet.h
@ -24,9 +24,9 @@
|
|||||||
#include <QtGui/QGraphicsItem>
|
#include <QtGui/QGraphicsItem>
|
||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
|
|
||||||
#include <kplugininfo.h>
|
#include <KPluginInfo>
|
||||||
#include <ksharedconfig.h>
|
#include <KSharedConfig>
|
||||||
#include <kgenericfactory.h>
|
#include <KGenericFactory>
|
||||||
|
|
||||||
#include <plasma/configxml.h>
|
#include <plasma/configxml.h>
|
||||||
#include <plasma/packagestructure.h>
|
#include <plasma/packagestructure.h>
|
||||||
@ -104,7 +104,7 @@ class PLASMA_EXPORT Applet : public Widget
|
|||||||
/**
|
/**
|
||||||
* @return a package structure representing a Theme
|
* @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.
|
* This method is called once the applet is loaded and added to a Corona.
|
||||||
|
10
theme.cpp
10
theme.cpp
@ -60,6 +60,7 @@ public:
|
|||||||
QString findInTheme(const QString &image, const QString &theme) const;
|
QString findInTheme(const QString &image, const QString &theme) const;
|
||||||
static const char *defaultTheme;
|
static const char *defaultTheme;
|
||||||
|
|
||||||
|
static PackageStructure::Ptr packageStructure;
|
||||||
QString themeName;
|
QString themeName;
|
||||||
QString app;
|
QString app;
|
||||||
KSharedConfigPtr colors;
|
KSharedConfigPtr colors;
|
||||||
@ -71,6 +72,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PackageStructure::Ptr Theme::Private::packageStructure(0);
|
||||||
const char *Theme::Private::defaultTheme = "default";
|
const char *Theme::Private::defaultTheme = "default";
|
||||||
|
|
||||||
class ThemeSingleton
|
class ThemeSingleton
|
||||||
@ -113,9 +115,13 @@ Theme::~Theme()
|
|||||||
delete d;
|
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)
|
void Theme::setApplication(const QString &appname)
|
||||||
|
2
theme.h
2
theme.h
@ -67,7 +67,7 @@ class PLASMA_EXPORT Theme : public QObject
|
|||||||
/**
|
/**
|
||||||
* @return a package structure representing a Theme
|
* @return a package structure representing a Theme
|
||||||
*/
|
*/
|
||||||
static PackageStructure packageStructure();
|
static PackageStructure::Ptr packageStructure();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the application the theme setting is associated with. This
|
* Sets the application the theme setting is associated with. This
|
||||||
|
Loading…
x
Reference in New Issue
Block a user