libplasma
appletscript.cpp
Go to the documentation of this file.00001 /* 00002 * Copyright 2007 by Aaron Seigo <aseigo@kde.org> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU Library General Public License as 00006 * published by the Free Software Foundation; either version 2, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details 00013 * 00014 * You should have received a copy of the GNU Library General Public 00015 * License along with this program; if not, write to the 00016 * Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #include "scripting/appletscript.h" 00021 00022 #include "applet.h" 00023 #include "package.h" 00024 00025 namespace Plasma 00026 { 00027 00028 class AppletScriptPrivate 00029 { 00030 public: 00031 Applet* applet; 00032 }; 00033 00034 AppletScript::AppletScript(QObject *parent) 00035 : ScriptEngine(parent), 00036 d(new AppletScriptPrivate) 00037 { 00038 d->applet = 0; 00039 } 00040 00041 AppletScript::~AppletScript() 00042 { 00043 delete d; 00044 } 00045 00046 void AppletScript::setApplet(Plasma::Applet *applet) 00047 { 00048 d->applet = applet; 00049 } 00050 00051 Applet* AppletScript::applet() const 00052 { 00053 Q_ASSERT(d->applet); 00054 return d->applet; 00055 } 00056 00057 void AppletScript::paintInterface(QPainter* painter, const QStyleOptionGraphicsItem* option, const QRect &contentsRect) 00058 { 00059 Q_UNUSED(painter) 00060 Q_UNUSED(option) 00061 Q_UNUSED(contentsRect) 00062 } 00063 00064 QSizeF AppletScript::size() const 00065 { 00066 if (applet()) { 00067 return applet()->size(); 00068 } 00069 00070 return QSizeF(); 00071 } 00072 00073 void AppletScript::constraintsEvent(Plasma::Constraints constraints) 00074 { 00075 Q_UNUSED(constraints); 00076 } 00077 00078 QList<QAction*> AppletScript::contextualActions() 00079 { 00080 return QList<QAction*>(); 00081 } 00082 00083 QPainterPath AppletScript::shape() const 00084 { 00085 if (applet()) { 00086 QPainterPath path; 00087 path.addRect(applet()->boundingRect()); 00088 return path; 00089 } 00090 00091 return QPainterPath(); 00092 } 00093 00094 void AppletScript::showConfigurationInterface() 00095 { 00096 } 00097 00098 DataEngine* AppletScript::dataEngine(const QString &engine) const 00099 { 00100 Q_ASSERT(d->applet); 00101 return d->applet->dataEngine(engine); 00102 } 00103 00104 QString AppletScript::mainScript() const 00105 { 00106 Q_ASSERT(d->applet); 00107 return d->applet->package()->filePath("mainscript"); 00108 } 00109 00110 const Package* AppletScript::package() const 00111 { 00112 Q_ASSERT(d->applet); 00113 return d->applet->package(); 00114 } 00115 00116 } // Plasma namespace 00117 00118 #include "appletscript.moc"