move BackgroundHints to Plasma::, make it a plain enum

This commit is contained in:
Aaron Seigo 2011-06-24 16:35:09 +02:00
parent c19f04c2f4
commit bf17cc308a
4 changed files with 23 additions and 31 deletions

View File

@ -385,7 +385,7 @@ void Applet::setFailedToLaunch(bool failed, const QString &reason)
setLayout(0); setLayout(0);
if (failed) { if (failed) {
setBackgroundHints(d->backgroundHints|StandardBackground); setBackgroundHints(StandardBackground);
QGraphicsLinearLayout *failureLayout = new QGraphicsLinearLayout(this); QGraphicsLinearLayout *failureLayout = new QGraphicsLinearLayout(this);
failureLayout->setContentsMargins(0, 0, 0, 0); failureLayout->setContentsMargins(0, 0, 0, 0);
@ -918,12 +918,12 @@ void Applet::setImmutability(const ImmutabilityType immutable)
updateConstraints(ImmutableConstraint); updateConstraints(ImmutableConstraint);
} }
Applet::BackgroundHints Applet::backgroundHints() const BackgroundHints Applet::backgroundHints() const
{ {
return d->backgroundHints; return d->backgroundHints;
} }
void Applet::setBackgroundHints(const BackgroundHints hints) void Applet::setBackgroundHints(const Plasma::BackgroundHints hints)
{ {
if (d->backgroundHints == hints) { if (d->backgroundHints == hints) {
return; return;
@ -2555,8 +2555,8 @@ AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int
: appletId(uniqueID), : appletId(uniqueID),
q(applet), q(applet),
service(0), service(0),
preferredBackgroundHints(Applet::StandardBackground), preferredBackgroundHints(StandardBackground),
backgroundHints(Applet::NoBackground), backgroundHints(NoBackground),
aspectRatioMode(Plasma::KeepAspectRatio), aspectRatioMode(Plasma::KeepAspectRatio),
immutability(Mutable), immutability(Mutable),
appletDescription(info ? *info : KPluginInfo(service)), appletDescription(info ? *info : KPluginInfo(service)),
@ -2623,7 +2623,7 @@ void AppletPrivate::init(const QString &packagePath)
//set a default size before any saved settings are read //set a default size before any saved settings are read
QSize size(200, 200); QSize size(200, 200);
q->setBackgroundHints(Applet::DefaultBackground); q->setBackgroundHints(DefaultBackground);
q->setHasConfigurationInterface(true); //FIXME why not default it to true in the constructor? q->setHasConfigurationInterface(true); //FIXME why not default it to true in the constructor?
QAction *closeApplet = actions->action("remove"); QAction *closeApplet = actions->action("remove");
@ -2965,7 +2965,7 @@ void AppletOverlayWidget::paint(QPainter *painter,
QPainterPath backgroundShape; QPainterPath backgroundShape;
if (!applet || applet->backgroundHints() & Applet::StandardBackground) { if (!applet || applet->backgroundHints() == StandardBackground) {
//FIXME: a resize here is nasty, but perhaps still better than an eventfilter just for that.. //FIXME: a resize here is nasty, but perhaps still better than an eventfilter just for that..
if (parentWidget()->contentsRect().size() != size()) { if (parentWidget()->contentsRect().size() != size()) {
resize(parentWidget()->contentsRect().size()); resize(parentWidget()->contentsRect().size());

View File

@ -87,28 +87,13 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometry) Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometry)
Q_PROPERTY(bool shouldConserveResources READ shouldConserveResources) Q_PROPERTY(bool shouldConserveResources READ shouldConserveResources)
Q_PROPERTY(uint id READ id) Q_PROPERTY(uint id READ id)
Q_PROPERTY(bool userConfiguring READ isUserConfiguring)
Q_PROPERTY(BackgroundHints backgroundHints READ backgroundHints WRITE setBackgroundHints) Q_PROPERTY(BackgroundHints backgroundHints READ backgroundHints WRITE setBackgroundHints)
Q_ENUMS(BackgroundHints) Q_PROPERTY(bool userConfiguring READ isUserConfiguring)
public: public:
typedef QList<Applet*> List; typedef QList<Applet*> List;
typedef QHash<QString, Applet*> Dict; typedef QHash<QString, Applet*> Dict;
/**
* Description on how draw a background for the applet
*/
enum BackgroundHint {
NoBackground = 0, /**< Not drawing a background under the
applet, the applet has its own implementation */
StandardBackground = 1, /**< The standard background from the theme is drawn */
TranslucentBackground = 2, /**< An alternate version of the background is drawn,
usually more translucent */
DefaultBackground = StandardBackground /**< Default settings:
both standard background */
};
Q_DECLARE_FLAGS(BackgroundHints, BackgroundHint)
~Applet(); ~Applet();
/** /**
@ -507,13 +492,13 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
* *
* @param hints the BackgroundHint combination for this applet * @param hints the BackgroundHint combination for this applet
*/ */
void setBackgroundHints(const BackgroundHints hints); void setBackgroundHints(const Plasma::BackgroundHints hint);
/** /**
* @return BackgroundHints flags combination telling if the standard background is shown * @return BackgroundHints flags combination telling if the standard background is shown
* and if it has a drop shadow * and if it has a drop shadow
*/ */
BackgroundHints backgroundHints() const; Plasma::BackgroundHints backgroundHints() const;
/** /**
* @return true if this Applet is currently being used as a Containment, false otherwise * @return true if this Applet is currently being used as a Containment, false otherwise
@ -1129,8 +1114,6 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
} // Plasma namespace } // Plasma namespace
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Applet::BackgroundHints)
/** /**
* Register an applet when it is contained in a loadable module * Register an applet when it is contained in a loadable module
*/ */

View File

@ -284,6 +284,16 @@ enum TrustLevel {
}; };
Q_ENUMS(TrustLevel) Q_ENUMS(TrustLevel)
/**
* Description on how draw a background for the applet
*/
enum BackgroundHints {
NoBackground = 0, /**< Not drawing a background under the applet, the applet has its own implementation */
StandardBackground = 1, /**< The standard background from the theme is drawn */
TranslucentBackground = 2, /**< An alternate version of the background is drawn, usually more translucent */
DefaultBackground = StandardBackground /**< Default settings: both standard background */
};
Q_ENUMS(BackgroundHints)
/** /**
* @return the scaling factor (0..1) for a ZoomLevel * @return the scaling factor (0..1) for a ZoomLevel
@ -338,5 +348,4 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Flip)
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::ComponentTypes) Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::ComponentTypes)
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::MessageButtons) Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::MessageButtons)
#endif // multiple inclusion guard #endif // multiple inclusion guard

View File

@ -156,9 +156,9 @@ public:
// applet attributes // applet attributes
QWeakPointer<Extender> extender; QWeakPointer<Extender> extender;
Service *service; Service *service;
Applet::BackgroundHints preferredBackgroundHints; BackgroundHints preferredBackgroundHints;
Applet::BackgroundHints backgroundHints; BackgroundHints backgroundHints;
Plasma::AspectRatioMode aspectRatioMode; AspectRatioMode aspectRatioMode;
ImmutabilityType immutability; ImmutabilityType immutability;
// applet info we keep around in case its needed // applet info we keep around in case its needed