Add an opacity attribute. GUI portion coming later

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=793581
This commit is contained in:
Andre Duffeck 2008-04-04 13:16:55 +00:00
parent 88ffba62e0
commit ef0c0375c3
2 changed files with 33 additions and 1 deletions

View File

@ -116,7 +116,8 @@ public:
hasConfigurationInterface(false),
failed(false),
isContainment(false),
square(false)
square(false),
opacity(1.0)
{
if (appletId == 0) {
appletId = ++s_maxAppletId;
@ -331,6 +332,7 @@ public:
bool failed : 1;
bool isContainment : 1;
bool square : 1;
qreal opacity;
};
uint Applet::Private::s_maxAppletId = 0;
@ -398,6 +400,7 @@ void Applet::save(KConfigGroup* group) const
//kDebug() << pluginName() << "geometry is" << geometry() << "pos is" << pos() << "bounding rect is" << boundingRect();
group->writeEntry("geometry", geometry());
group->writeEntry("zvalue", zValue());
group->writeEntry("opacity", d->opacity);
if (transform() == QTransform()) {
group->deleteEntry("transform");
@ -435,6 +438,8 @@ void Applet::restore(KConfigGroup *c)
if (c->readEntry("locked", false)) {
setImmutable(true);
}
setOpacity(c->readEntry("opacity", 1.0));
}
void Applet::saveState(KConfigGroup* group) const
@ -933,6 +938,12 @@ void Applet::paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *opti
}
painter->save();
//Set opacity
if (d->opacity >= 0.1 && d->opacity <= 0.9) {
painter->setOpacity(d->opacity);
}
if (transform().isRotating()) {
painter->setRenderHint(QPainter::SmoothPixmapTransform);
painter->setRenderHint(QPainter::Antialiasing);
@ -1595,6 +1606,16 @@ void Applet::themeChanged()
update();
}
void Applet::setOpacity( qreal opacity )
{
d->opacity = opacity;
}
qreal Applet::opacity() const
{
return d->opacity;
}
} // Plasma namespace
#include "applet.moc"

View File

@ -628,6 +628,17 @@ class PLASMA_EXPORT Applet : public Widget
**/
Containment* containment() const;
/**
* Sets the opacity of this Plasma::Applet
* @param opacity the new opacity
*/
void setOpacity( qreal opacity );
/**
* @return opacity of this Applet
**/
qreal opacity() const;
Q_SIGNALS:
/**
* Emitted when the applet needs to take (or lose) keyboard focus.