2008-01-25 01:04:03 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2007 by Aaron Seigo <aseigo@kde.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "scripting/appletscript.h"
|
|
|
|
|
|
|
|
#include "applet.h"
|
|
|
|
#include "package.h"
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2008-07-01 20:56:43 +02:00
|
|
|
class AppletScriptPrivate
|
2008-01-25 01:04:03 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
Applet* applet;
|
|
|
|
};
|
|
|
|
|
|
|
|
AppletScript::AppletScript(QObject *parent)
|
|
|
|
: ScriptEngine(parent),
|
2008-07-01 20:56:43 +02:00
|
|
|
d(new AppletScriptPrivate)
|
2008-01-25 01:04:03 +01:00
|
|
|
{
|
|
|
|
d->applet = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
AppletScript::~AppletScript()
|
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppletScript::setApplet(Plasma::Applet *applet)
|
|
|
|
{
|
|
|
|
d->applet = applet;
|
|
|
|
}
|
|
|
|
|
|
|
|
Applet* AppletScript::applet() const
|
|
|
|
{
|
|
|
|
Q_ASSERT(d->applet);
|
|
|
|
return d->applet;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppletScript::paintInterface(QPainter* painter, const QStyleOptionGraphicsItem* option, const QRect &contentsRect)
|
|
|
|
{
|
|
|
|
Q_UNUSED(painter)
|
|
|
|
Q_UNUSED(option)
|
|
|
|
Q_UNUSED(contentsRect)
|
|
|
|
}
|
|
|
|
|
|
|
|
QSizeF AppletScript::size() const
|
|
|
|
{
|
|
|
|
if (applet()) {
|
2008-04-25 21:55:24 +02:00
|
|
|
return applet()->size();
|
2008-01-25 01:04:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return QSizeF();
|
|
|
|
}
|
|
|
|
|
2008-04-27 13:23:09 +02:00
|
|
|
void AppletScript::constraintsEvent(Plasma::Constraints constraints)
|
2008-03-02 22:36:59 +01:00
|
|
|
{
|
|
|
|
Q_UNUSED(constraints);
|
|
|
|
}
|
|
|
|
|
2008-04-25 21:55:24 +02:00
|
|
|
QList<QAction*> AppletScript::contextualActions()
|
2008-03-02 22:36:59 +01:00
|
|
|
{
|
|
|
|
return QList<QAction*>();
|
|
|
|
}
|
|
|
|
|
2008-06-25 02:33:46 +02:00
|
|
|
QPainterPath AppletScript::shape() const
|
|
|
|
{
|
|
|
|
if (applet()) {
|
|
|
|
QPainterPath path;
|
|
|
|
path.addRect(applet()->boundingRect());
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
return QPainterPath();
|
|
|
|
}
|
|
|
|
|
2008-09-08 18:20:28 +02:00
|
|
|
void AppletScript::setHasConfigurationInterface(bool hasInterface)
|
|
|
|
{
|
2008-09-12 17:21:58 +02:00
|
|
|
Q_UNUSED(hasInterface)
|
2008-09-08 18:20:28 +02:00
|
|
|
if (applet()) {
|
|
|
|
applet()->setHasConfigurationInterface(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-08 19:46:28 +02:00
|
|
|
void AppletScript::showConfigurationInterface()
|
2008-03-02 22:36:59 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-09-12 17:21:58 +02:00
|
|
|
void AppletScript::configChanged()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-01-25 01:04:03 +01:00
|
|
|
DataEngine* AppletScript::dataEngine(const QString &engine) const
|
|
|
|
{
|
|
|
|
Q_ASSERT(d->applet);
|
|
|
|
return d->applet->dataEngine(engine);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString AppletScript::mainScript() const
|
|
|
|
{
|
|
|
|
Q_ASSERT(d->applet);
|
|
|
|
return d->applet->package()->filePath("mainscript");
|
|
|
|
}
|
|
|
|
|
|
|
|
const Package* AppletScript::package() const
|
|
|
|
{
|
|
|
|
Q_ASSERT(d->applet);
|
|
|
|
return d->applet->package();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // Plasma namespace
|
|
|
|
|
|
|
|
#include "appletscript.moc"
|