context API adjustments
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=857207
This commit is contained in:
parent
b3b8ac7ee3
commit
d89ad4cba0
@ -1016,10 +1016,11 @@ Location Applet::location() const
|
||||
return c ? c->d->location : Plasma::Desktop;
|
||||
}
|
||||
|
||||
QString Applet::context() const
|
||||
Context* Applet::context() const
|
||||
{
|
||||
Containment *c = containment();
|
||||
return c->Containment::context();
|
||||
Q_ASSERT(c);
|
||||
return c->d->context();
|
||||
}
|
||||
|
||||
Plasma::AspectRatioMode Applet::aspectRatioMode() const
|
||||
|
3
applet.h
3
applet.h
@ -46,6 +46,7 @@ namespace Plasma
|
||||
|
||||
class AppletPrivate;
|
||||
class Containment;
|
||||
class Context;
|
||||
class DataEngine;
|
||||
class Extender;
|
||||
class ExtenderItem;
|
||||
@ -245,7 +246,7 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
|
||||
/**
|
||||
* Returns the workspace context which the applet is operating in
|
||||
*/
|
||||
QString context() const;
|
||||
Context *context() const;
|
||||
|
||||
/**
|
||||
* @return the preferred aspect ratio mode for placement and resizing
|
||||
|
@ -277,7 +277,7 @@ void Containment::save(KConfigGroup &g) const
|
||||
group.writeEntry("screen", d->screen);
|
||||
group.writeEntry("formfactor", (int)d->formFactor);
|
||||
group.writeEntry("location", (int)d->location);
|
||||
group.writeEntry("activity", d->activity);
|
||||
group.writeEntry("activity", d->context()->currentActivity());
|
||||
|
||||
if (d->wallpaper) {
|
||||
group.writeEntry("wallpaperplugin", d->wallpaper->pluginName());
|
||||
@ -1207,13 +1207,9 @@ Plasma::Wallpaper* Containment::wallpaper() const
|
||||
|
||||
void Containment::setActivity(const QString &activity)
|
||||
{
|
||||
if (d->activity != activity) {
|
||||
d->activity = activity;
|
||||
Context c;
|
||||
QStringList activities = c.listActivities();
|
||||
if (!activities.contains(activity)) {
|
||||
c.createActivity(activity);
|
||||
}
|
||||
Context *context = d->context();
|
||||
if (context->currentActivity() != activity) {
|
||||
context->setCurrentActivity(activity);
|
||||
|
||||
foreach (Applet *a, d->applets) {
|
||||
a->updateConstraints(ContextConstraint);
|
||||
@ -1223,7 +1219,16 @@ void Containment::setActivity(const QString &activity)
|
||||
|
||||
QString Containment::activity() const
|
||||
{
|
||||
return d->activity;
|
||||
return d->context()->currentActivity();
|
||||
}
|
||||
|
||||
Context* ContainmentPrivate::context()
|
||||
{
|
||||
if (!con) {
|
||||
con = new Context(q);
|
||||
}
|
||||
|
||||
return con;
|
||||
}
|
||||
|
||||
KActionCollection& ContainmentPrivate::actions()
|
||||
|
15
context.cpp
15
context.cpp
@ -25,12 +25,14 @@ namespace Plasma
|
||||
class ContextPrivate
|
||||
{
|
||||
public:
|
||||
QString activity;
|
||||
};
|
||||
|
||||
Context::Context(QObject *parent)
|
||||
: QObject(parent),
|
||||
d(new ContextPrivate)
|
||||
{
|
||||
//TODO: look up activity in Nepomuk
|
||||
}
|
||||
|
||||
Context::~Context()
|
||||
@ -49,11 +51,22 @@ QStringList Context::listActivities() const
|
||||
|
||||
void Context::setCurrentActivity(const QString &name)
|
||||
{
|
||||
if (d->activity == name || name.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->activity = name;
|
||||
emit activityChanged(this);
|
||||
|
||||
QStringList activities = listActivities();
|
||||
if (!activities.contains(name)) {
|
||||
createActivity(name);
|
||||
}
|
||||
}
|
||||
|
||||
QString Context::currentActivity() const
|
||||
{
|
||||
return QString();
|
||||
return d->activity;
|
||||
}
|
||||
|
||||
} // namespace Plasma
|
||||
|
@ -44,8 +44,11 @@ public:
|
||||
void setCurrentActivity(const QString &name);
|
||||
QString currentActivity() const;
|
||||
|
||||
//TODO: location
|
||||
|
||||
Q_SIGNALS:
|
||||
void currentChanged(const QString &);
|
||||
void activityChanged(Plasma::Context *context);
|
||||
void locationChanged(Plasma::Context *context);
|
||||
|
||||
private:
|
||||
ContextPrivate * const d;
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
wallpaper(0),
|
||||
screen(-1), // no screen
|
||||
toolBox(0),
|
||||
con(0),
|
||||
type(Containment::NoContainmentType),
|
||||
positioning(false),
|
||||
drawWallpaper(true)
|
||||
@ -92,6 +93,11 @@ public:
|
||||
*/
|
||||
void focusApplet(Plasma::Applet *applet);
|
||||
|
||||
/**
|
||||
* returns the Context for this Containment
|
||||
*/
|
||||
Context* context();
|
||||
|
||||
Containment *q;
|
||||
FormFactor formFactor;
|
||||
Location location;
|
||||
@ -101,8 +107,8 @@ public:
|
||||
QMap<Applet*, AppletHandle*> handles;
|
||||
int screen;
|
||||
ToolBox *toolBox;
|
||||
Context *con;
|
||||
Containment::Type type;
|
||||
QString activity;
|
||||
bool positioning;
|
||||
bool drawWallpaper;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user