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);
if (failed) {
setBackgroundHints(d->backgroundHints|StandardBackground);
setBackgroundHints(StandardBackground);
QGraphicsLinearLayout *failureLayout = new QGraphicsLinearLayout(this);
failureLayout->setContentsMargins(0, 0, 0, 0);
@ -918,12 +918,12 @@ void Applet::setImmutability(const ImmutabilityType immutable)
updateConstraints(ImmutableConstraint);
}
Applet::BackgroundHints Applet::backgroundHints() const
BackgroundHints Applet::backgroundHints() const
{
return d->backgroundHints;
}
void Applet::setBackgroundHints(const BackgroundHints hints)
void Applet::setBackgroundHints(const Plasma::BackgroundHints hints)
{
if (d->backgroundHints == hints) {
return;
@ -2555,8 +2555,8 @@ AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int
: appletId(uniqueID),
q(applet),
service(0),
preferredBackgroundHints(Applet::StandardBackground),
backgroundHints(Applet::NoBackground),
preferredBackgroundHints(StandardBackground),
backgroundHints(NoBackground),
aspectRatioMode(Plasma::KeepAspectRatio),
immutability(Mutable),
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
QSize size(200, 200);
q->setBackgroundHints(Applet::DefaultBackground);
q->setBackgroundHints(DefaultBackground);
q->setHasConfigurationInterface(true); //FIXME why not default it to true in the constructor?
QAction *closeApplet = actions->action("remove");
@ -2965,7 +2965,7 @@ void AppletOverlayWidget::paint(QPainter *painter,
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..
if (parentWidget()->contentsRect().size() != 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(bool shouldConserveResources READ shouldConserveResources)
Q_PROPERTY(uint id READ id)
Q_PROPERTY(bool userConfiguring READ isUserConfiguring)
Q_PROPERTY(BackgroundHints backgroundHints READ backgroundHints WRITE setBackgroundHints)
Q_ENUMS(BackgroundHints)
Q_PROPERTY(bool userConfiguring READ isUserConfiguring)
public:
typedef QList<Applet*> List;
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();
/**
@ -507,13 +492,13 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
*
* @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
* 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
@ -1129,8 +1114,6 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
} // Plasma namespace
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Applet::BackgroundHints)
/**
* Register an applet when it is contained in a loadable module
*/

View File

@ -284,6 +284,16 @@ enum 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
@ -338,5 +348,4 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Flip)
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::ComponentTypes)
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::MessageButtons)
#endif // multiple inclusion guard

View File

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