add configChanged to Applet and AppletScript

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=860299
This commit is contained in:
Petri Damstén 2008-09-12 15:21:58 +00:00
parent b4818c5cac
commit 11317e0d7e
4 changed files with 30 additions and 5 deletions

View File

@ -190,7 +190,7 @@ void Applet::save(KConfigGroup &g) const
//which isn't very nice. //which isn't very nice.
foreach (ExtenderItem *item, extender()->attachedItems()) { foreach (ExtenderItem *item, extender()->attachedItems()) {
if (!item->isDetached() || item->autoExpireDelay()) { if (!item->isDetached() || item->autoExpireDelay()) {
//destroy temporary extender items, or items that aren't detached, so their //destroy temporary extender items, or items that aren't detached, so their
//configuration won't linger after a plasma restart. //configuration won't linger after a plasma restart.
item->destroy(); item->destroy();
} }
@ -443,7 +443,7 @@ QGraphicsView *Applet::view() const
QGraphicsView *found = 0; QGraphicsView *found = 0;
QGraphicsView *possibleFind = 0; QGraphicsView *possibleFind = 0;
foreach (QGraphicsView *view, scene()->views()) { foreach (QGraphicsView *view, scene()->views()) {
kDebug() << "checking" << view->sceneRect() << "against" << sceneBoundingRect() kDebug() << "checking" << view->sceneRect() << "against" << sceneBoundingRect()
<< scenePos(); << scenePos();
if (view->sceneRect().intersects(sceneBoundingRect()) || if (view->sceneRect().intersects(sceneBoundingRect()) ||
view->sceneRect().contains(scenePos())) { view->sceneRect().contains(scenePos())) {
@ -651,9 +651,9 @@ bool Applet::hasFailedToLaunch() const
void Applet::paintWindowFrame(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) void Applet::paintWindowFrame(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
{ {
Q_UNUSED( painter ); Q_UNUSED(painter)
Q_UNUSED( option ); Q_UNUSED(option)
Q_UNUSED( widget ); Q_UNUSED(widget)
//Here come the code for the window frame //Here come the code for the window frame
//kDebug() << windowFrameGeometry(); //kDebug() << windowFrameGeometry();
//painter->drawRoundedRect(windowFrameGeometry(), 5, 5); //painter->drawRoundedRect(windowFrameGeometry(), 5, 5);
@ -1241,12 +1241,21 @@ void Applet::showConfigurationInterface()
connect(dialog, SIGNAL(finished()), nullManager, SLOT(deleteLater())); connect(dialog, SIGNAL(finished()), nullManager, SLOT(deleteLater()));
//TODO: Apply button does not correctly work for now, so do not show it //TODO: Apply button does not correctly work for now, so do not show it
dialog->showButton( KDialog::Apply, false ); dialog->showButton( KDialog::Apply, false );
connect(dialog, SIGNAL(applyClicked()), this, SLOT(configChanged()));
connect(dialog, SIGNAL(okClicked()), this, SLOT(configChanged()));
dialog->show(); dialog->show();
} }
emit releaseVisualFocus(); emit releaseVisualFocus();
} }
void Applet::configChanged()
{
if (d->script) {
d->script->configChanged();
}
}
void Applet::createConfigurationInterface(KConfigDialog *parent) void Applet::createConfigurationInterface(KConfigDialog *parent)
{ {
Q_UNUSED(parent) Q_UNUSED(parent)
@ -1645,6 +1654,7 @@ void AppletPrivate::setupScriptSupport()
// FIXME: KConfigSkeleton doesn't play well with KConfigGroup =/ // FIXME: KConfigSkeleton doesn't play well with KConfigGroup =/
KConfigGroup config = q->config(); KConfigGroup config = q->config();
configXml = new ConfigXml(&config, &file); configXml = new ConfigXml(&config, &file);
QObject::connect(configXml, SIGNAL(configChanged()), q, SLOT(configChanged()));
} }
if (!package->filePath("mainconfigui").isEmpty()) { if (!package->filePath("mainconfigui").isEmpty()) {

View File

@ -593,6 +593,11 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
**/ **/
virtual void init(); virtual void init();
/**
* Called when applet configuration values has changed.
*/
virtual void configChanged();
/** /**
* Get's called when and extender item has to be initialized after a plasma restart. If you * Get's called when and extender item has to be initialized after a plasma restart. If you
* create ExtenderItems in your applet, you should implement this function to again create * create ExtenderItems in your applet, you should implement this function to again create

View File

@ -93,6 +93,7 @@ QPainterPath AppletScript::shape() const
void AppletScript::setHasConfigurationInterface(bool hasInterface) void AppletScript::setHasConfigurationInterface(bool hasInterface)
{ {
Q_UNUSED(hasInterface)
if (applet()) { if (applet()) {
applet()->setHasConfigurationInterface(true); applet()->setHasConfigurationInterface(true);
} }
@ -102,6 +103,10 @@ void AppletScript::showConfigurationInterface()
{ {
} }
void AppletScript::configChanged()
{
}
DataEngine* AppletScript::dataEngine(const QString &engine) const DataEngine* AppletScript::dataEngine(const QString &engine) const
{ {
Q_ASSERT(d->applet); Q_ASSERT(d->applet);

View File

@ -125,6 +125,11 @@ public Q_SLOTS:
*/ */
virtual void showConfigurationInterface(); virtual void showConfigurationInterface();
/**
* Configure was changed.
*/
virtual void configChanged();
protected: protected:
/** /**
* @arg engine name of the engine * @arg engine name of the engine