- add a way to get at the Containment
- fix some apidox - add a method for state saving, but for the main applet class info as well as subclasses (plasmoids, e.g.) svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=714174
This commit is contained in:
parent
2b2b7f02e5
commit
2c63daad12
45
applet.cpp
45
applet.cpp
@ -43,6 +43,7 @@
|
||||
#include <KIconLoader>
|
||||
|
||||
#include "plasma/configxml.h"
|
||||
#include "plasma/containment.h"
|
||||
#include "plasma/corona.h"
|
||||
#include "plasma/dataenginemanager.h"
|
||||
#include "plasma/package.h"
|
||||
@ -106,10 +107,6 @@ public:
|
||||
void init(Applet* applet)
|
||||
{
|
||||
applet->setZValue(100);
|
||||
//these lines fix behaviour somewhat with update()s after resize in qt 4.3.0,
|
||||
//but the issues are fixed in 4.3.1 and this breaks shadows.
|
||||
//applet->setFlag(QGraphicsItem::ItemClipsToShape, false);
|
||||
//applet->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false);
|
||||
kioskImmutable = applet->globalConfig().isImmutable() ||
|
||||
applet->config().isImmutable();
|
||||
applet->setImmutable(kioskImmutable);
|
||||
@ -197,7 +194,9 @@ public:
|
||||
const int bottomOffset = contentHeight;
|
||||
const int contentTop = 0;
|
||||
const int contentLeft = 0;
|
||||
if (!cachedBackground || cachedBackground->size() != QSize(leftWidth + contentWidth + rightWidth, topHeight + contentHeight + bottomHeight)) {
|
||||
QSize s = QSize(leftWidth + contentWidth + rightWidth,
|
||||
topHeight + contentHeight + bottomHeight);
|
||||
if (!cachedBackground || cachedBackground->size() != s) {
|
||||
delete cachedBackground;
|
||||
cachedBackground = new QPixmap(leftWidth + contentWidth + rightWidth, topHeight + contentHeight + bottomHeight);
|
||||
cachedBackground->fill(Qt::transparent);
|
||||
@ -217,7 +216,6 @@ public:
|
||||
background->paint(&p, QRect(contentLeft, topOffset, contentWidth, topHeight), "top");
|
||||
background->paint(&p, QRect(contentLeft, bottomOffset, contentWidth, bottomHeight), "bottom");
|
||||
} else {
|
||||
|
||||
QPixmap left(leftWidth, leftHeight);
|
||||
left.fill(Qt::transparent);
|
||||
{
|
||||
@ -391,6 +389,24 @@ KConfigGroup Applet::config() const
|
||||
return KConfigGroup(d->config(), "General");
|
||||
}
|
||||
|
||||
void Applet::save(KConfigGroup* group) const
|
||||
{
|
||||
group->writeEntry("plugin", pluginName());
|
||||
group->writeEntry("geometry", QRect(pos().toPoint(), boundingRect().size().toSize()));
|
||||
|
||||
Containment* c = containment();
|
||||
if (c) {
|
||||
group->writeEntry("containment", c->id());
|
||||
}
|
||||
|
||||
saveState(group);
|
||||
}
|
||||
|
||||
void Applet::saveState(KConfigGroup* group) const
|
||||
{
|
||||
Q_UNUSED(group)
|
||||
}
|
||||
|
||||
KConfigGroup Applet::config(const QString& group) const
|
||||
{
|
||||
KConfigGroup cg = config();
|
||||
@ -749,20 +765,29 @@ void Applet::paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *o
|
||||
|
||||
FormFactor Applet::formFactor() const
|
||||
{
|
||||
if (!scene()) {
|
||||
Containment* c = containment();
|
||||
|
||||
if (!c) {
|
||||
return Plasma::Planar;
|
||||
}
|
||||
|
||||
return static_cast<Corona*>(scene())->formFactor();
|
||||
return c->formFactor();
|
||||
}
|
||||
|
||||
Containment* Applet::containment() const
|
||||
{
|
||||
return dynamic_cast<Containment*>(parentItem());
|
||||
}
|
||||
|
||||
Location Applet::location() const
|
||||
{
|
||||
if (!scene()) {
|
||||
Containment* c = containment();
|
||||
|
||||
if (!c) {
|
||||
return Plasma::Desktop;
|
||||
}
|
||||
|
||||
return static_cast<Corona*>(scene())->location();
|
||||
return c->location();
|
||||
}
|
||||
|
||||
QSizeF Applet::contentSize() const
|
||||
|
26
applet.h
26
applet.h
@ -35,6 +35,7 @@
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class Containment;
|
||||
class DataEngine;
|
||||
class Package;
|
||||
|
||||
@ -127,6 +128,11 @@ class PLASMA_EXPORT Applet : public Widget
|
||||
**/
|
||||
KConfigGroup config(const QString& group) const;
|
||||
|
||||
/**
|
||||
* Saves state information about this applet.
|
||||
**/
|
||||
void save(KConfigGroup* group) const;
|
||||
|
||||
/**
|
||||
* Returns a KConfigGroup object to be shared by all applets of this
|
||||
* type.
|
||||
@ -196,14 +202,14 @@ class PLASMA_EXPORT Applet : public Widget
|
||||
*
|
||||
* @see Plasma::FormFactor
|
||||
*/
|
||||
FormFactor formFactor() const;
|
||||
virtual FormFactor formFactor() const;
|
||||
|
||||
/**
|
||||
* Returns the location of the scene which is displaying applet.
|
||||
*
|
||||
* @see Plasma::Location
|
||||
*/
|
||||
Location location() const;
|
||||
virtual Location location() const;
|
||||
|
||||
/**
|
||||
* Returns the area within which contents can be painted. If there is no
|
||||
@ -225,8 +231,7 @@ class PLASMA_EXPORT Applet : public Widget
|
||||
virtual QSizeF contentSizeHint() const;
|
||||
|
||||
/**
|
||||
* Returns a list of all known applets in a hash keyed by a unique
|
||||
* identifier for each applet.
|
||||
* Returns a list of all known applets.
|
||||
*
|
||||
* @param category Only applets matchin this category will be returned.
|
||||
* Useful in conjunction with knownCategories.
|
||||
@ -245,8 +250,7 @@ class PLASMA_EXPORT Applet : public Widget
|
||||
const QString &parentApp = QString());
|
||||
|
||||
/**
|
||||
* Returns a list of all known applets associated with a certain mimetype in a hash keyed by a unique
|
||||
* identifier for each applet
|
||||
* Returns a list of all known applets associated with a certain mimetype.
|
||||
*
|
||||
* @return list of applets
|
||||
**/
|
||||
@ -491,6 +495,12 @@ class PLASMA_EXPORT Applet : public Widget
|
||||
void destroy();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Called when a request to save the state of the applet is made
|
||||
* during runtime
|
||||
**/
|
||||
virtual void saveState(KConfigGroup* config) const;
|
||||
|
||||
/**
|
||||
* Returns the name of the applet.
|
||||
*
|
||||
@ -548,6 +558,10 @@ class PLASMA_EXPORT Applet : public Widget
|
||||
*/
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
||||
|
||||
/**
|
||||
* @return the Containment, if any, this applet belongs to
|
||||
**/
|
||||
Containment* containment() const;
|
||||
|
||||
protected Q_SLOTS:
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user