provide a way for applets to signal that they'd like their config saved out to disk, please.
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=755616
This commit is contained in:
parent
b6030dd8b3
commit
e12dbeb000
10
applet.h
10
applet.h
@ -581,6 +581,16 @@ class PLASMA_EXPORT Applet : public Widget
|
|||||||
*/
|
*/
|
||||||
void geometryChanged();
|
void geometryChanged();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emitted when an applet has changed values in its configuration
|
||||||
|
* and wishes for them to be saved at the next save point. As this implies
|
||||||
|
* disk activity, this signal should be used with care.
|
||||||
|
*
|
||||||
|
* @note This does not need to be emitted from saveState by individual
|
||||||
|
* applets.
|
||||||
|
*/
|
||||||
|
void configurationChanged();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* Sets whether or not this applet is immutable or not.
|
* Sets whether or not this applet is immutable or not.
|
||||||
|
@ -473,6 +473,11 @@ Applet* Containment::addApplet(const QString& name, const QVariantList& args, ui
|
|||||||
|
|
||||||
//kDebug() << applet->name() << "sizehint:" << applet->sizeHint() << "geometry:" << applet->geometry();
|
//kDebug() << applet->name() << "sizehint:" << applet->sizeHint() << "geometry:" << applet->geometry();
|
||||||
|
|
||||||
|
Corona *c = corona();
|
||||||
|
if (c) {
|
||||||
|
connect(applet, SIGNAL(configurationChanged()), corona(), SLOT(scheduleConfigSync()));
|
||||||
|
}
|
||||||
|
|
||||||
emit appletAdded(applet);
|
emit appletAdded(applet);
|
||||||
return applet;
|
return applet;
|
||||||
}
|
}
|
||||||
|
29
corona.cpp
29
corona.cpp
@ -28,6 +28,7 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include <KDebug>
|
#include <KDebug>
|
||||||
#include <KLocale>
|
#include <KLocale>
|
||||||
@ -45,6 +46,10 @@ using namespace Plasma;
|
|||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// constant controling how long between requesting a configuration sync
|
||||||
|
// and one happening should occur. currently 2 minutes.
|
||||||
|
const int CONFIG_SYNC_TIMEOUT = 120000;
|
||||||
|
|
||||||
class Corona::Private
|
class Corona::Private
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -64,6 +69,8 @@ public:
|
|||||||
|
|
||||||
void init(Corona* q)
|
void init(Corona* q)
|
||||||
{
|
{
|
||||||
|
configSyncTimer.setSingleShot(true);
|
||||||
|
connect(&configSyncTimer, SIGNAL(timeout()), q, SLOT(syncConfig()));
|
||||||
QObject::connect(QApplication::desktop(), SIGNAL(resized(int)), q, SLOT(screenResized(int)));
|
QObject::connect(QApplication::desktop(), SIGNAL(resized(int)), q, SLOT(screenResized(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +79,7 @@ public:
|
|||||||
QString mimetype;
|
QString mimetype;
|
||||||
QString configName;
|
QString configName;
|
||||||
KSharedConfigPtr config;
|
KSharedConfigPtr config;
|
||||||
|
QTimer configSyncTimer;
|
||||||
QList<Containment*> containments;
|
QList<Containment*> containments;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -151,6 +159,18 @@ void Corona::saveApplets() const
|
|||||||
saveApplets(d->configName);
|
saveApplets(d->configName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Corona::scheduleConfigSync()
|
||||||
|
{
|
||||||
|
//NOTE: this is a pretty simplistic model: we simply save no more than CONFIG_SYNC_TIMEOUT
|
||||||
|
// after the first time this is called. not much of a heuristic for save points, but
|
||||||
|
// it should at least compress these activities a bit and provide a way for applet
|
||||||
|
// authors to ween themselves from the sync() disease. A more interesting/dynamic
|
||||||
|
// algorithm for determining when to actually sync() to disk might be better, though.
|
||||||
|
if (!d->configSyncTimer.isActive()) {
|
||||||
|
d->configSyncTimer.start(CONFIG_SYNC_TIMEOUT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Corona::loadApplets(const QString& configName)
|
void Corona::loadApplets(const QString& configName)
|
||||||
{
|
{
|
||||||
clearApplets();
|
clearApplets();
|
||||||
@ -292,8 +312,8 @@ void Corona::loadDefaultSetup()
|
|||||||
panel->setLocation(Plasma::LeftEdge);
|
panel->setLocation(Plasma::LeftEdge);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// in case something goes bad during runtime, let's at least save this to disk right away
|
// in case something goes bad during runtime, let's at least save this to disk soonish
|
||||||
config()->sync();
|
scheduleConfigSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
Containment* Corona::containmentForScreen(int screen) const
|
Containment* Corona::containmentForScreen(int screen) const
|
||||||
@ -457,6 +477,11 @@ void Corona::screenResized(int screen)
|
|||||||
emit newScreen(screen);
|
emit newScreen(screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Corona::syncConfig()
|
||||||
|
{
|
||||||
|
config()->sync();
|
||||||
|
}
|
||||||
|
|
||||||
bool Corona::isImmutable() const
|
bool Corona::isImmutable() const
|
||||||
{
|
{
|
||||||
return d->kioskImmutable || d->immutable;
|
return d->kioskImmutable || d->immutable;
|
||||||
|
7
corona.h
7
corona.h
@ -114,6 +114,12 @@ public Q_SLOTS:
|
|||||||
*/
|
*/
|
||||||
void saveApplets() const;
|
void saveApplets() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when there have been changes made to configuration that should be saved
|
||||||
|
* to disk at the next convenient moment
|
||||||
|
*/
|
||||||
|
void scheduleConfigSync();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a Containment to the Corona
|
* Adds a Containment to the Corona
|
||||||
*
|
*
|
||||||
@ -177,6 +183,7 @@ protected:
|
|||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
void containmentDestroyed(QObject*);
|
void containmentDestroyed(QObject*);
|
||||||
void screenResized(int);
|
void screenResized(int);
|
||||||
|
void syncConfig();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Private;
|
class Private;
|
||||||
|
Loading…
Reference in New Issue
Block a user