diff --git a/applet.cpp b/applet.cpp index 256774955..88593493a 100644 --- a/applet.cpp +++ b/applet.cpp @@ -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" diff --git a/applet.h b/applet.h index b3272b91b..b208d490f 100644 --- a/applet.h +++ b/applet.h @@ -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.