plasma: leave only the declarative scripting engine

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2016-08-06 20:06:02 +00:00
parent 32428f3373
commit bfc04340f4
133 changed files with 157 additions and 13749 deletions

View file

@ -16,7 +16,7 @@ add_subdirectory(dataengines)
add_subdirectory(declarativeimports)
add_subdirectory(desktoptheme)
add_subdirectory(runners)
add_subdirectory(scriptengines)
add_subdirectory(scriptengine)
add_subdirectory(shells)
add_subdirectory(wallpapers)
add_subdirectory(kpart)

View file

@ -0,0 +1,40 @@
#DECLARATIVE APPLET
set(declarative_appletscript_SRCS
common/extension_launchapp.cpp
common/extension_io.cpp
common/javascriptaddonpackagestructure.cpp
common/scriptenv.cpp
declarative/toolboxproxy.cpp
declarative/appletcontainer.cpp
declarative/declarativeitemcontainer.cpp
plasmoid/abstractjsappletscript.cpp
plasmoid/appletinterface.cpp
plasmoid/declarativeappletscript.cpp
plasmoid/themedsvg.cpp
simplebindings/bytearrayclass.cpp
simplebindings/bytearrayprototype.cpp
simplebindings/dataengine.cpp
simplebindings/dataenginereceiver.cpp
simplebindings/filedialogproxy.cpp
simplebindings/qscriptbookkeeping.cpp
simplebindings/url.cpp
simplebindings/point.cpp
)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/common)
kde4_add_plugin(plasma_appletscript_declarative ${declarative_appletscript_SRCS})
target_link_libraries(plasma_appletscript_declarative
${KDE4_PLASMA_LIBS}
${KDE4_KIO_LIBS}
${QT_QTSCRIPT_LIBRARY}
${QT_QTDECLARATIVE_LIBRARY}
${QT_QTUITOOLS_LIBRARY}
)
install(TARGETS plasma_appletscript_declarative DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES data/plasma-scriptengine-applet-declarative.desktop DESTINATION ${SERVICES_INSTALL_DIR})

View file

@ -38,10 +38,7 @@
#include <Plasma/Package>
#ifdef USEGUI
#include "simplebindings/filedialogproxy.h"
#endif
#include "javascriptaddonpackagestructure.h"
Q_DECLARE_METATYPE(ScriptEnv*)
@ -69,9 +66,6 @@ void ScriptEnv::setupGlobalObject()
global.setProperty("__plasma_scriptenv", m_engine->newQObject(this),
QScriptValue::ReadOnly|QScriptValue::Undeletable|QScriptValue::SkipInEnumeration);
// Add utility functions
#ifndef DECLARATIVE
global.setProperty("print", m_engine->newFunction(ScriptEnv::print));
#endif
global.setProperty("debug", m_engine->newFunction(ScriptEnv::debug));
}
@ -156,10 +150,8 @@ bool ScriptEnv::importBuiltinExtension(const QString &extension, QScriptValue &o
{
kDebug() << extension;
if ("filedialog" == extension) {
#ifdef USEGUI
FileDialogProxy::registerWithRuntime(m_engine);
return true;
#endif
} else if ("launchapp" == extension) {
m_allowedUrls |= AppLaunching;
obj.setProperty("runApplication", m_engine->newFunction(ScriptEnv::runApplication));
@ -262,16 +254,6 @@ QScriptValue ScriptEnv::throwNonFatalError(const QString &msg, QScriptContext *c
return rv;
}
QScriptValue ScriptEnv::print(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() != 1) {
return throwNonFatalError(i18n("print() takes one argument"), context, engine);
}
std::cout << context->argument(0).toString().toLocal8Bit().constData() << std::endl;
return engine->undefinedValue();
}
QScriptValue ScriptEnv::listAddons(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() < 1) {
@ -514,6 +496,4 @@ bool ScriptEnv::removeEventListener(const QString &event, const QScriptValue &fu
return found;
}
#ifndef USEGUI
#include "moc_scriptenv.cpp"
#endif

View file

@ -82,7 +82,6 @@ private:
bool importBuiltinExtension(const QString &extension, QScriptValue &obj);
static QScriptValue debug(QScriptContext *context, QScriptEngine *engine);
static QScriptValue print(QScriptContext *context, QScriptEngine *engine);
static QScriptValue runApplication(QScriptContext *context, QScriptEngine *engine);
static QScriptValue runCommand(QScriptContext *context, QScriptEngine *engine);
static QScriptValue defaultApplication(QScriptContext *context, QScriptEngine *engine);

View file

@ -347,17 +347,6 @@ bool AppletInterface::userConfiguring() const
return applet()->isUserConfiguring();
}
int AppletInterface::apiVersion() const
{
const QString constraint("[X-Plasma-API] == 'javascript' and 'Applet' in [X-Plasma-ComponentTypes]");
KService::List offers = KServiceTypeTrader::self()->query("Plasma/ScriptEngine", constraint);
if (offers.isEmpty()) {
return -1;
}
return offers.first()->property("X-KDE-PluginInfo-Version", QVariant::Int).toInt();
}
bool AppletInterface::include(const QString &script)
{
const QString path = m_appletScriptEngine->filePath("scripts", script);

View file

@ -76,7 +76,6 @@ class AppletInterface : public QObject
Q_PROPERTY(BackgroundHints backgroundHints WRITE setBackgroundHints READ backgroundHints)
Q_PROPERTY(bool immutable READ immutable NOTIFY immutableChanged)
Q_PROPERTY(bool userConfiguring READ userConfiguring) // @since 4.5
Q_PROPERTY(int apiVersion READ apiVersion CONSTANT)
Q_PROPERTY(ItemStatus status READ status WRITE setStatus NOTIFY statusChanged)
Q_PROPERTY(QRectF rect READ rect)
Q_PROPERTY(QSizeF size READ size)
@ -297,7 +296,6 @@ enum IntervalAlignment {
QList<QAction*> contextualActions() const;
bool immutable() const;
bool userConfiguring() const;
int apiVersion() const;
static AppletInterface *extract(QScriptEngine *engine);
inline Plasma::Applet *applet() const { return m_appletScriptEngine->applet(); }

View file

@ -52,8 +52,6 @@
#include "common/scriptenv.h"
#include "declarative/declarativeitemcontainer_p.h"
#include "simplebindings/bytearrayclass.h"
//not pretty but only way to avoid a double Q_DECLARE_METATYPE(QVariant) in dataengine.h
#define DECLARATIVE_BINDING
#include "simplebindings/dataengine.h"
#include "simplebindings/dataenginereceiver.h"

View file

@ -0,0 +1,34 @@
/****************************************************************************
**
** This file is part of the Qt Script Generator.
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation info@qt.nokia.com
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging of
** this file. Please review the following information to ensure the GNU
** Lesser General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** Copyright (C) 2011 Nokia. All rights reserved
****************************************************************************/
#ifndef QTSCRIPTEXTENSIONS_GLOBAL_H
#define QTSCRIPTEXTENSIONS_GLOBAL_H
#include <QtGui/QPixmap>
Q_DECLARE_METATYPE(QPixmap*)
Q_DECLARE_METATYPE(QPixmap)
#define DECLARE_SELF(Class, __fn__) \
Class* self = qscriptvalue_cast<Class*>(ctx->thisObject()); \
if (!self) { \
return ctx->throwError(QScriptContext::TypeError, \
QString::fromLatin1("%0.prototype.%1: this object is not a %0") \
.arg(#Class).arg(#__fn__)); \
}
#endif // QTSCRIPTEXTENSIONS_GLOBAL_H

View file

@ -30,9 +30,6 @@
using namespace Plasma;
#ifndef DECLARATIVE_BINDING
Q_DECLARE_METATYPE(QVariant)
#endif
Q_DECLARE_METATYPE(DataEngine::Dict)
Q_DECLARE_METATYPE(DataEngine::Data)

View file

@ -20,11 +20,20 @@
#include <QGraphicsWidget>
#include <QScriptEngine>
#include <KConfigGroup>
#include <KIO/Job>
#include <KSharedConfig>
#include <Plasma/Applet>
#include <Plasma/Animation>
#include <Plasma/Extender>
//Q_DECLARE_METATYPE(SimpleJavaScriptApplet*)
#include "dataengine.h"
Q_DECLARE_METATYPE(KConfigGroup)
Q_DECLARE_METATYPE(KJob *)
Q_DECLARE_METATYPE(KIO::Job *)
Q_DECLARE_METATYPE(QGraphicsWidget*)
Q_DECLARE_METATYPE(QGraphicsLayout*)
@ -35,6 +44,73 @@ Q_DECLARE_METATYPE(Plasma::Svg*)
Q_DECLARE_METATYPE(Qt::MouseButton)
Q_DECLARE_METATYPE(QList<double>)
typedef KJob* KJobPtr;
QScriptValue qScriptValueFromKJob(QScriptEngine *engine, const KJobPtr &job)
{
return engine->newQObject(const_cast<KJob *>(job), QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject);
}
void qKJobFromQScriptValue(const QScriptValue &scriptValue, KJobPtr &job)
{
QObject *obj = scriptValue.toQObject();
job = static_cast<KJob *>(obj);
}
typedef KIO::Job* KioJobPtr;
QScriptValue qScriptValueFromKIOJob(QScriptEngine *engine, const KioJobPtr &job)
{
return engine->newQObject(const_cast<KIO::Job *>(job), QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject);
}
void qKIOJobFromQScriptValue(const QScriptValue &scriptValue, KioJobPtr &job)
{
QObject *obj = scriptValue.toQObject();
job = static_cast<KIO::Job *>(obj);
}
QScriptValue qScriptValueFromKConfigGroup(QScriptEngine *engine, const KConfigGroup &config)
{
QScriptValue obj = engine->newObject();
if (!config.isValid()) {
return obj;
}
QMap<QString, QString> entryMap = config.entryMap();
QMap<QString, QString>::const_iterator it = entryMap.constBegin();
QMap<QString, QString>::const_iterator begin = it;
QMap<QString, QString>::const_iterator end = entryMap.constEnd();
//setting the group name
obj.setProperty("__file", QScriptValue(engine, config.config()->name()));
obj.setProperty("__name", QScriptValue(engine, config.name()));
//setting the key/value pairs
for (it = begin; it != end; ++it) {
//kDebug() << "setting" << it.key() << "to" << it.value();
QString prop = it.key();
prop.replace(' ', '_');
obj.setProperty(prop, it.value());
}
return obj;
}
void kConfigGroupFromScriptValue(const QScriptValue& obj, KConfigGroup &config)
{
config = KConfigGroup(KSharedConfig::openConfig(obj.property("__file").toString()), obj.property("__name").toString());
QScriptValueIterator it(obj);
while (it.hasNext()) {
it.next();
//kDebug() << it.name() << "is" << it.value().toString();
if (it.name() != "__name") {
config.writeEntry(it.name(), it.value().toString());
}
}
}
typedef Plasma::Animation* AnimationPtr;
QScriptValue qScriptValueFromAnimation(QScriptEngine *engine, const AnimationPtr &anim)
{
@ -93,13 +169,13 @@ void mouseButtonFromScriptValue(const QScriptValue &scriptValue, Qt::MouseButton
button = static_cast<Qt::MouseButton>(scriptValue.toInt32());
}
#include "simplebindings/qscriptnonguibookkeeping.cpp"
using namespace Plasma;
void registerSimpleAppletMetaTypes(QScriptEngine *engine)
{
registerNonGuiMetaTypes(engine);
qScriptRegisterMetaType<KConfigGroup>(engine, qScriptValueFromKConfigGroup, kConfigGroupFromScriptValue);
qScriptRegisterMetaType<KJob *>(engine, qScriptValueFromKJob, qKJobFromQScriptValue);
qScriptRegisterMetaType<KIO::Job *>(engine, qScriptValueFromKIOJob, qKIOJobFromQScriptValue);
registerDataEngineMetaTypes(engine);
qScriptRegisterMetaType<QGraphicsWidget*>(engine, qScriptValueFromQGraphicsWidget, graphicsWidgetFromQScriptValue);
qScriptRegisterMetaType<Plasma::Svg*>(engine, qScriptValueFromSvg, svgFromQScriptValue);

View file

@ -1,11 +0,0 @@
macro_optional_add_subdirectory(ruby)
if(QT_QTWEBKIT_FOUND)
macro_optional_add_subdirectory(webkit)
endif()
if (PYTHONLIBS_FOUND)
macro_optional_add_subdirectory(python)
endif()
macro_optional_add_subdirectory(javascript)

View file

@ -1,164 +0,0 @@
# APPLET
if(QT_QTWEBKIT_FOUND)
add_definitions(-DHAVE_QTWEBKIT)
endif()
set(simple_javascript_engine_SRCS
common/extension_launchapp.cpp
common/extension_io.cpp
common/guiscriptenv.cpp
common/javascriptaddonpackagestructure.cpp
declarative/toolboxproxy.cpp
declarative/appletcontainer.cpp
plasmoid/abstractjsappletscript.cpp
plasmoid/jsappletinterface.cpp
plasmoid/simplejavascriptapplet.cpp
plasmoid/themedsvg.cpp
simplebindings/animationgroup.cpp
simplebindings/anchorlayout.cpp
simplebindings/dataenginereceiver.cpp
simplebindings/bytearrayclass.cpp
simplebindings/bytearrayprototype.cpp
simplebindings/color.cpp
simplebindings/dataengine.cpp
simplebindings/easingcurve.cpp
simplebindings/font.cpp
simplebindings/filedialogproxy.cpp
simplebindings/graphicsitem.cpp
simplebindings/icon.cpp
simplebindings/i18n.cpp
simplebindings/linearlayout.cpp
simplebindings/gridlayout.cpp
simplebindings/painter.cpp
simplebindings/pen.cpp
simplebindings/pixmap.cpp
simplebindings/point.cpp
simplebindings/rect.cpp
simplebindings/qscriptbookkeeping.cpp
simplebindings/size.cpp
simplebindings/sizepolicy.cpp
simplebindings/timer.cpp
simplebindings/uiloader.cpp
simplebindings/url.cpp
)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/common)
kde4_add_plugin(plasma_appletscript_simple_javascript ${simple_javascript_engine_SRCS})
target_link_libraries(plasma_appletscript_simple_javascript
${KDE4_KDECORE_LIBS}
${KDE4_KIO_LIBS}
${KDE4_PLASMA_LIBS}
${QT_QTDECLARATIVE_LIBRARY}
${QT_QTSCRIPT_LIBRARY}
${QT_QTUITOOLS_LIBRARY}
${QT_QTXML_LIBRARY}
)
install(TARGETS plasma_appletscript_simple_javascript DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES data/plasma-scriptengine-applet-simple-javascript.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
# RUNNER
set(javascript_runner_engine_SRCS
common/extension_launchapp.cpp
common/extension_io.cpp
common/javascriptaddonpackagestructure.cpp
common/scriptenv.cpp
runner/javascriptrunner.cpp
simplebindings/i18n.cpp
)
kde4_add_plugin(plasma_runnerscript_javascript ${javascript_runner_engine_SRCS})
target_link_libraries(plasma_runnerscript_javascript
${KDE4_KDECORE_LIBS}
${KDE4_KIO_LIBS}
${KDE4_PLASMA_LIBS}
${QT_QTSCRIPT_LIBRARY})
install(TARGETS plasma_runnerscript_javascript DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES data/plasma-scriptengine-runner-javascript.desktop DESTINATION ${SERVICES_INSTALL_DIR})
# DATAENGINE
set(javascript_dataengine_engine_SRCS
common/extension_launchapp.cpp
common/extension_io.cpp
common/javascriptaddonpackagestructure.cpp
common/scriptenv.cpp
dataengine/javascriptdataengine.cpp
dataengine/javascriptservice.cpp
simplebindings/dataengine.cpp
simplebindings/i18n.cpp
simplebindings/qscriptnonguibookkeeping.cpp
)
kde4_add_plugin(plasma_dataenginescript_javascript ${javascript_dataengine_engine_SRCS})
target_link_libraries(plasma_dataenginescript_javascript
${KDE4_KDECORE_LIBS}
${KDE4_KIO_LIBS}
${KDE4_PLASMA_LIBS}
${QT_QTSCRIPT_LIBRARY})
install(TARGETS plasma_dataenginescript_javascript DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES data/plasma-scriptengine-dataengine-javascript.desktop DESTINATION ${SERVICES_INSTALL_DIR})
# ADDONS
set(javascript_addon_packagestructure_SRCS
common/addonpackageplugin.cpp
common/javascriptaddonpackagestructure.cpp
)
kde4_add_plugin(plasma_packagestructure_javascriptaddon ${javascript_addon_packagestructure_SRCS})
target_link_libraries(plasma_packagestructure_javascriptaddon ${KDE4_PLASMA_LIBS})
install(TARGETS plasma_packagestructure_javascriptaddon DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES data/plasma-packagestructure-javascript-addon.desktop DESTINATION ${SERVICES_INSTALL_DIR})
install(FILES data/plasma-javascriptaddon.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR})
#DECLARATIVE APPLET
set(declarative_appletscript_SRCS
common/extension_launchapp.cpp
common/extension_io.cpp
common/javascriptaddonpackagestructure.cpp
common/declarativescriptenv.cpp
declarative/toolboxproxy.cpp
declarative/appletcontainer.cpp
declarative/declarativeitemcontainer.cpp
plasmoid/abstractjsappletscript.cpp
plasmoid/appletinterface.cpp
plasmoid/declarativeappletscript.cpp
plasmoid/themedsvg.cpp
simplebindings/bytearrayclass.cpp
simplebindings/bytearrayprototype.cpp
simplebindings/dataengine.cpp
simplebindings/dataenginereceiver.cpp
simplebindings/filedialogproxy.cpp
simplebindings/qscriptbookkeeping.cpp
simplebindings/url.cpp
simplebindings/point.cpp
)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/common)
kde4_add_plugin(plasma_appletscript_declarative ${declarative_appletscript_SRCS})
target_link_libraries(plasma_appletscript_declarative
${KDE4_PLASMA_LIBS}
${KDE4_KIO_LIBS}
${QT_QTSCRIPT_LIBRARY}
${QT_QTDECLARATIVE_LIBRARY}
${QT_QTUITOOLS_LIBRARY}
)
install(TARGETS plasma_appletscript_declarative DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES data/plasma-scriptengine-applet-declarative.desktop DESTINATION ${SERVICES_INSTALL_DIR})

View file

@ -1,21 +0,0 @@
/*
* Copyright 2010 Aaron J. 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 version 2 as
* published by the Free Software Foundation
*
* 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.,
*/
#include "javascriptaddonpackagestructure.h"
K_EXPORT_PLASMA_PACKAGESTRUCTURE(javascriptaddon, JavascriptAddonPackageStructure)

View file

@ -1,23 +0,0 @@
/*
* Copyright 2010 Aaron J. 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 version 2 as
* published by the Free Software Foundation
*
* 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.
*/
#define USEGUI
#define DECLARATIVE
#include "scriptenv.cpp"
#include "moc_scriptenv.cpp"

View file

@ -1,22 +0,0 @@
/*
* Copyright 2010 Aaron J. 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 version 2 as
* published by the Free Software Foundation
*
* 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.
*/
#define USEGUI
#include "scriptenv.cpp"
#include "moc_scriptenv.cpp"

View file

@ -1,70 +0,0 @@
[Desktop Entry]
Name=Plasma JavaScript Addon
Name[ar]=إضافة جافا سكربت بلازما
Name[ast]=Complementu de JavaScript pa Plasma
Name[bg]=Добавка за JavaScript на Plasma
Name[bs]=Plazma javaskriptni dodatak
Name[ca]=Complement del JavaScript pel Plasma
Name[ca@valencia]=Complement del JavaScript pel Plasma
Name[cs]=Doplněk Plasmy JavaScript
Name[da]=Plasma JavaScript-tilføjelse
Name[de]=JavaScript-Erweiterung für Plasma
Name[el]=Πρόσθετο Plasma JavaScript
Name[en_GB]=Plasma JavaScript Addon
Name[eo]=Aldonaĵo de Plasmo en Ĝavaskripto
Name[es]=Complemento de JavaScript para Plasma
Name[et]=Plasma JavaScripti lisa
Name[eu]=Plasma JavaScript gehigarria
Name[fa]=افزودنی جاوااسکریپت پلاسما
Name[fi]=Plasma JavaScript -liitännäinen
Name[fr]=Module complémentaire Javascript de Plasma
Name[ga]=Breiseán JavaScript Plasma
Name[gl]=Engadido JavaScript para Plasma
Name[gu]= િ
Name[he]=תוסף עבור JavaScript של Plasma
Name[hi]= -ि
Name[hr]=Dodatak JavaScripta Plasmi
Name[hu]=Plazma JavaScript-bővítmény
Name[ia]=Plasma JavaScript Addon
Name[id]=Addon JavaScript Plasma
Name[is]=Plasma JavaScript viðbót
Name[it]=Aggiunta per Java e JavaScript
Name[ja]=Plasma JavaScript
Name[kk]=Plasma JavaScript қосымшасы
Name[km]= Plasma JavaScript
Name[kn]= ಿ
Name[ko]=Plasma
Name[lt]=Plasma JavaScript priedas
Name[lv]=Plasma JavaScript papildinājums
Name[mr]= ि Addon
Name[nb]=Plasma JavaScript-tillegg
Name[nds]=JavaScript-Verwiedern för Plasma
Name[nl]=Addon voor Plasma JavaScript
Name[nn]=PlasmaJavaScript-tillegg
Name[pa]= ਿ
Name[pl]=Dodatek dla JavaScript
Name[pt]=Extensão de JavaScript do Plasma
Name[pt_BR]=Complementos de JavaScript do Plasma
Name[ro]=Supliment JavaScript Plasma
Name[ru]=Расширение Plasma, использующее JavaScript
Name[si]=
Name[sk]=Doplnok JavaScript pre plasmu
Name[sl]=Dodatek za JavaScript za Plasmo
Name[sr]=Плазма јаваскриптни додатак
Name[sr@ijekavian]=Плазма јаваскриптни додатак
Name[sr@ijekavianlatin]=Plasma JavaScript dodatak
Name[sr@latin]=Plasma JavaScript dodatak
Name[sv]=Plasma Javaskript-tillägg
Name[tg]=Барномаи иловагии Plasma JavaScript
Name[th]=
Name[tr]=Plasma JavaScript Eklentisi
Name[ug]=Plasma JavaScript قوشۇلما
Name[uk]=Додаток JavaScript до Плазми
Name[vi]=Phn b tr JavaScript Plasma
Name[wa]=Pacaedje di rawete Plasma JavaScript
Name[x-test]=xxPlasma JavaScript Addonxx
Name[zh_CN]=Plasma JavaScript
Name[zh_TW]=Plasma JavaScript Addon
Type=ServiceType
X-KDE-ServiceType=Plasma/JavascriptAddon
Icon=plasma

View file

@ -1,146 +0,0 @@
[Desktop Entry]
Name=Javascript Addon
Name[ar]=إضافة جافا سكربت
Name[ast]=Complementu de JavaScript
Name[bg]=Добавка за Javascript
Name[bn]=ি -
Name[bs]=Javaskriptni dodatak
Name[ca]=Complement del Javascript
Name[ca@valencia]=Complement del Javascript
Name[cs]=Doplněk JavaScript
Name[da]=JavaScript-tilføjelse
Name[de]=JavaScript-Erweiterung
Name[el]=Πρόσθετο Javascript
Name[en_GB]=Javascript Addon
Name[eo]=Aldonaĵo de Ĝavaskripto
Name[es]=Complemento de JavaScript
Name[et]=JavaScripti lisa
Name[eu]=Javascript gehigarria
Name[fa]=افزودنی جاوااسکریپت
Name[fi]=Javascript-liitännäinen
Name[fr]=Module complémentaire Javascript
Name[ga]=Breiseán JavaScript
Name[gl]=Engadido JavaScript
Name[gu]=િ
Name[he]=תוסף JavaScript
Name[hi]=ि
Name[hr]=Dodadak za Javascript
Name[hu]=Javascript-bővítmény
Name[ia]=JavaScript Addon
Name[id]=Addon JavaScript
Name[is]=JavaScript viðbót
Name[it]=Aggiunta per JavaScript
Name[ja]=JavaScript
Name[kk]=Javascript қосымшасы
Name[km]= Javascript
Name[kn]=ಿ
Name[ko]=
Name[lt]=Javascript priedas
Name[lv]=JavaScript papildinājums
Name[mr]=ि Addon
Name[nb]=JavaScript-tillegg
Name[nds]=JavaScript-Verwiedern
Name[nl]=Addon voor JavaScript
Name[nn]=JavaScript-tillegg
Name[pa]= ਿ -
Name[pl]=Dodatek dla JavaScript
Name[pt]=Extensão de JavaScript
Name[pt_BR]=Complementos de JavaScript
Name[ro]=Supliment Javascript
Name[ru]=Дополнение, использующее JavaScript
Name[si]=
Name[sk]=Doplnok JavaScript
Name[sl]=Dodatek za JavaScript
Name[sr]=Јаваскриптни додатак
Name[sr@ijekavian]=Јаваскриптни додатак
Name[sr@ijekavianlatin]=JavaScript dodatak
Name[sr@latin]=JavaScript dodatak
Name[sv]=Javaskript-tillägg
Name[tg]=Барномаи иловагии Javascript
Name[th]=
Name[tr]=Javascript Eklentisi
Name[ug]=Javascript قوشۇلما
Name[uk]=Додаток JavaScript
Name[vi]=Phn b tr Javascript
Name[wa]=Pacaedje di rawete Javascript
Name[x-test]=xxJavascript Addonxx
Name[zh_CN]=Javascript
Name[zh_TW]=Javascript Addon
Comment=Addons for Javascript Plasma plugins
Comment[ar]=إضافة لملاحق جافا سكربت بلازما
Comment[ast]=Amestaos pa complementos de JavaScript pa Plasma
Comment[bg]=Добавки за приставките за Javascript на Plasma
Comment[bs]=Dodaci za javaskriptne plazma priključke
Comment[ca]=Complements pels connectors Javascript del Plasma
Comment[ca@valencia]=Complements pels connectors Javascript del Plasma
Comment[cs]=Doplňky pro javascriptové zásuvné moduly plasmy
Comment[da]=Tilføjelse til Plasma-plugins i JavaScript
Comment[de]=Erweiterungen für JavaScript-Module in Plasma
Comment[el]=Πρόσθετο για Plasma JavaScript
Comment[en_GB]=Addons for Javascript Plasma plugins
Comment[eo]=Aldonaĵoj por kromprogramoj de Plasmo en Ĝavaskripto
Comment[es]=Añadidos para complementos de JavaScript para Plasma
Comment[et]=JavaScripti Plasma pluginate lisad
Comment[eu]=Javascript Plasma pluginentzako gehigarriak
Comment[fi]=Lisäosia JavaScript Plasma -liitännäisille
Comment[fr]=Module complémentaire pour les modules externes en Javascript de Plasma
Comment[ga]=Breiseáin le haghaidh forlíontán Javascript Plasma
Comment[gl]=Engadidos para complementos Plasma Javascript
Comment[gu]=િ
Comment[he]=תוספים לתוספי JavaScript של Plasma
Comment[hi]=ि ि ि Addons
Comment[hr]=Dodaci za priključke za Javascript Plasma
Comment[hu]=Bővítmények JavaScript Plazma-modulokhoz
Comment[ia]=Addons (elementos adjuncte) pro plugins de Plasma de javascript
Comment[id]=Addon untuk plugin Javascript Plasma
Comment[is]=Viðbætur fyrir Plasma JavaScript íforrit
Comment[it]=Aggiunte per le estensioni JavaScript di Plasma
Comment[ja]=JavaScript Plasma
Comment[kk]=Javascript Plasma плагиніне қосымшасы
Comment[km]= Javascript Plasma
Comment[ko]= Plasma
Comment[lt]=Javascript Plasma papildinio priedai
Comment[lv]=Papildinājumi Javascript Plasma spraudņiem
Comment[mr]=ि Addon
Comment[nb]=Tillegg for JavaScript Plasma-programtillegg
Comment[nds]=Verwiedern för Plasma sien JavaScript-Modulen
Comment[nl]=Addons voor Javascript Plasma plugins
Comment[nn]=Tillegg for JavaScriptPlasma-programtillegg
Comment[pa]=ਿ
Comment[pl]=Dodatki dla wtyczek Plazmy w JavaScript
Comment[pt]=Extras para os 'plugins' do Plasma em JavaScript
Comment[pt_BR]=Complementos para os plugins do Plasma em JavaScript
Comment[ro]=Suplimente pentru module JavaScript Plasma
Comment[ru]=Модули поддержки дополнений Plasma, использующих JavaScript
Comment[si]=
Comment[sk]=Doplnky pre Javascriptové moduly plasmy
Comment[sl]=Dodatki za vstavke JavaScript za Plasmo
Comment[sr]=Додаци за јаваскриптне плазма прикључке
Comment[sr@ijekavian]=Додаци за јаваскриптне плазма прикључке
Comment[sr@ijekavianlatin]=Dodaci za JavaScript plasma priključke
Comment[sr@latin]=Dodaci za JavaScript plasma priključke
Comment[sv]=Tillägg för Javascript Plasma-insticksprogram
Comment[tg]=Барномаҳои иловагӣ барои плагинҳои Javascript Plasma
Comment[th]=
Comment[tr]=Javascript Plasma eklentileri için ek araçlar
Comment[ug]=Javascript Plasma قىستۇرمىسى ئۈچۈن قوشۇلما
Comment[uk]=Додатки для використання Javascript у Плазмі
Comment[vi]=Phn b tr cho phn b sung Plasma Javascript
Comment[wa]=Pacaedjes di rawete po les tchôkes-divins Plasma Javascript
Comment[x-test]=xxAddons for Javascript Plasma pluginsxx
Comment[zh_CN]=Javascript Plasma
Comment[zh_TW]=Javascript Plasma Addon
Type=Service
X-KDE-ServiceTypes=Plasma/PackageStructure
X-KDE-Library=plasma_packagestructure_javascriptaddon
X-KDE-PluginInfo-Author=Aaron Seigo
X-KDE-PluginInfo-Email=aseigh@kde.org
X-KDE-PluginInfo-Name=Plasma/JavascriptAddon
X-KDE-PluginInfo-Version=0.1
X-KDE-PluginInfo-Website=http://plasma.kde.org/
X-KDE-PluginInfo-License=GPLv2+
X-KDE-PluginInfo-EnabledByDefault=true
X-Plasma-PackageFileFilter=*.plasmaaddon
X-Plasma-PackageFileMimetypes=application/zip

View file

@ -1,158 +0,0 @@
[Desktop Entry]
Name=JavaScript Widget
Name[ar]=ودجة جافا سكربت
Name[ast]=Elementu gráficu JavaScript
Name[be@latin]=Widžet JavaScript
Name[bg]=Джаджа JavaScript
Name[bn]=ি
Name[bn_IN]=JavaScript Widget
Name[bs]=Javascript grafička kontrola
Name[ca]=Estri del JavaScript
Name[ca@valencia]=Estri del JavaScript
Name[cs]=JavaScript Widget
Name[csb]=Interfejs JavaScript
Name[da]=JavaScript-widget
Name[de]=JavaScript-Programm
Name[el]=Συστατικό JavaScript
Name[en_GB]=JavaScript Widget
Name[eo]=Ĝavaskripta fenestraĵo
Name[es]=Elemento gráfico JavaScript
Name[et]=JavaScripti vidin
Name[eu]=JavaScript trepeta
Name[fa]=ویجت جاوااسکریپت
Name[fi]=JavaScript-sovelma
Name[fr]=Composant graphique JavaScript
Name[fy]=JavaSkript Widget
Name[ga]=Giuirléid JavaScript
Name[gl]=Widget de JavaScript
Name[gu]=િ િ
Name[he]=ווידג׳ט JavaScript
Name[hi]=ि ि
Name[hne]=ि ि
Name[hr]=JavaScript widgeti
Name[hu]=JavaScript-objektum
Name[ia]=JavaScript Widget
Name[id]=Widget JavaScript
Name[is]=JavaScript græja
Name[it]=Oggetto JavaScript
Name[ja]=JavaScript
Name[kk]=JavaScript интерфейс бөлшегі
Name[km]= JavaScript
Name[kn]= ಿಿ ಿ (ಿ)
Name[ko]=
Name[ku]=Amîra JavaScriptê
Name[lt]=JavaScript valdiklis
Name[lv]=JavaScript sīkrīks
Name[ml]=ി ി
Name[mr]=ि ि
Name[nb]=JavaScript-skjermelement
Name[nds]=JavaScript-Finster
Name[nl]=JavaScript-widget
Name[nn]=JavaScript-element
Name[or]=JavaScript ି
Name[pa]=-ਿ ਿ
Name[pl]=Element interfejsu w JavaScript
Name[pt]=Elemento de JavaScript
Name[pt_BR]=Widget de JavaScript
Name[ro]=Miniaplicație JavaScript
Name[ru]=Виджет на языке JavaScript
Name[si]=Python
Name[sk]=JavaScript widget
Name[sl]=Gradnik v JavaScriptu
Name[sr]=јаваскриптни виџет
Name[sr@ijekavian]=јаваскриптни виџет
Name[sr@ijekavianlatin]=JavaScript vidžet
Name[sr@latin]=JavaScript vidžet
Name[sv]=Grafisk Javascript-komponent
Name[ta]=JavaScript Widget
Name[te]=ి ి
Name[tg]=Видҷети JavaScript
Name[th]=
Name[tr]=JavaScript Gereci
Name[ug]=JavaScript ۋىجېتى
Name[uk]=Віджет JavaScript
Name[vi]=Widget Javascript
Name[wa]=Ahesse JavaScript
Name[x-test]=xxJavaScript Widgetxx
Name[zh_CN]=JavaScript
Name[zh_TW]=JavaScript
Comment=Native Plasma widget written in JavaScript
Comment[ar]=ودجة بلازما أصلية كتبت بجافا سكربت
Comment[ast]=Elementu gráficu nativu de Plasma escritu en JavaScript
Comment[be@latin]=Widžet systemy Plasma, napisany ŭ movie JavaScript
Comment[bg]=Оригинална джаджа за Plasma, написана с JavaScript
Comment[bs]=Samosvojni plazma grafička kontrola napisana u javaskriptu
Comment[ca]=Estri nadiu del Plasma escrit en JavaScript
Comment[ca@valencia]=Estri nadiu del Plasma escrit en JavaScript
Comment[cs]=Nativní Plasma widget napsaný v JavaScriptu
Comment[csb]=Prôwdzëwi widżet Plasmë napisóny w JavaScript
Comment[da]=Native Plasma-widget skrevet i JavaScript
Comment[de]=Echtes Plasma-Programm, geschrieben in JavaScript
Comment[el]=Εγγενές συστατικό Plasma γραμμένο σε JavaScript
Comment[en_GB]=Native Plasma widget written in JavaScript
Comment[eo]=Indiĝena fenestraĵo de Plasmo programita per Ĝavaskripto
Comment[es]=Elemento gráfico nativo de Plasma escrito en JavaScript
Comment[et]=JavaScriptis kirjutatud Plasma vidin
Comment[eu]=Jatorrizko Plasma trepeta, JavaScript lengoaian idatzia
Comment[fi]=Natiivi, JavaScript-pohjainen Plasma-sovelma
Comment[fr]=Composant graphique natif de Plasma écrit en JavaScript
Comment[fy]=Plasma widget skreaun yn JavaSkript
Comment[ga]=Giuirléid dhúchasach Plasma, scríofa i JavaScript
Comment[gl]=Widget nativo de Plasma escrito en JavaScript
Comment[gu]=િ િ િ
Comment[he]=ווידג׳ט של Plasma הנכתב ב־JavaScript
Comment[hi]=ि ि ि ि
Comment[hne]=ि ि ि ि
Comment[hr]=Izvorna Plasma widget napisana u JavaScriptu
Comment[hu]=Plasma-elem Javascriptben elkészítve
Comment[ia]=Widget native de Plasma scribite in JavaScript
Comment[id]=Widget Plasma asli yang ditulis dalam JavaScript
Comment[is]=Upprunabundin Plasma græja skrifuð í JavaScript
Comment[it]=Oggetto nativo di Plasma scritto in JavaScript
Comment[ja]=JavaScript Plasma
Comment[kk]=JavaScript-те жазылған Plasma тума виджеті
Comment[km]= JavaScript
Comment[kn]= ಿ ಿ ಿ ಿ (ಿ)
Comment[ko]= Plasma
Comment[lt]=Nuosavas Plasma valdiklis parašytas JavaScript kalba
Comment[lv]=Plasma sīkrīks, rakstīts JavaScript
Comment[ml]=ിി ിിി ി
Comment[mr]=ि ि ि
Comment[nb]=Plasmaelement for dette systemet, skrevet i JavaScript
Comment[nds]=En orginaal Plasmaelement, schreven in JavaScript
Comment[nl]=Plasma-widget geschreven in JavaScript
Comment[nn]=Plasma-element skriven i JavaScript
Comment[or]=JavaScript ିି ି
Comment[pa]=-ਿ ਿ ਿ ਿ ਿ
Comment[pl]=Element interfejsu Plazmy napisany w JavaScript
Comment[pt]=Elemento nativo do Plasma feito em JavaScript
Comment[pt_BR]=Widget do Plasma nativo escrito em JavaScript
Comment[ro]=Miniaplicație Plasma scrisă în JavaScript
Comment[ru]=Виджет Plasma, написанный на языке JavaScript
Comment[si]=
Comment[sk]=Natívny plasma widget napísaný v JavaScripte
Comment[sl]=Pravi gradnik za Plasmo, ki je napisan v JavaScriptu
Comment[sr]=Самосвојни плазма виџет написан у јаваскрипту
Comment[sr@ijekavian]=Самосвојни плазма виџет написан у јаваскрипту
Comment[sr@ijekavianlatin]=Samosvojni plasma vidžet napisan u JavaScriptu
Comment[sr@latin]=Samosvojni plasma vidžet napisan u JavaScriptu
Comment[sv]=Inbyggd grafisk Plasma-komponent skriven i Javascript
Comment[ta]=Native Plasma widget written in JavaScript
Comment[te]=ి ి ి ి
Comment[tg]=Ин модули Plasma дар JavaScript навишта шуд
Comment[th]=
Comment[tr]=JavaScript ile yazılmış gerçek Plasma gereci
Comment[ug]=JavaScript بىلەن يېزىلغان ئەسلى Plasma ۋىجېتى
Comment[uk]=Віджет Плазми, написаний на JavaScript
Comment[vi]=Widget Plasma đưc viết bng JavaScript
Comment[wa]=Ahesse askepieye po Plasma eyet scrîte e JavaScript
Comment[x-test]=xxNative Plasma widget written in JavaScriptxx
Comment[zh_CN]=使 JavaScript Plasma
Comment[zh_TW]= JavaScript Plasma
X-KDE-ServiceTypes=Plasma/ScriptEngine
Type=Service
Icon=text-x-script
X-KDE-Library=plasma_appletscript_simple_javascript
X-Plasma-API=javascript
X-Plasma-ComponentTypes=Applet
X-KDE-PluginInfo-Version=5

View file

@ -1,77 +0,0 @@
[Desktop Entry]
Name=JavaScript DataEngine
Name[ar]=مشغل جافا سكربت
Name[ast]=Motor de datos JavaScript
Name[bg]=Ядро за данни на JavaScript
Name[bn]=ি -ি
Name[bs]=Javascript pogon podataka
Name[ca]=Motor de dades de JavaScript
Name[ca@valencia]=Motor de dades de JavaScript
Name[cs]=Datový nástroj JavaScript
Name[csb]=Mòtór JavaScript
Name[da]=JavaScript-datamotor
Name[de]=JavaScript-Datenmodul
Name[el]=Μηχανή δεδομένων JavaScript
Name[en_GB]=JavaScript DataEngine
Name[eo]=Datummodulo de Ĝavaskripto
Name[es]=Motor de datos JavaScript
Name[et]=JavaScripti andmemootor
Name[eu]=JavaScript datu-motorra
Name[fa]=موتور دادهی جاوااسکریپت
Name[fi]=JavaScript-datakone
Name[fr]=Moteur de données JavaScript
Name[fy]=JavaSkript gegevens motor
Name[ga]=Inneall Sonraí JavaScript
Name[gl]=Motor de datos de JavaScript
Name[gu]=િ િિ
Name[he]=מנוע נתונים של JavaScript
Name[hi]=ि
Name[hr]=JavaScript podatkovni mehanizam
Name[hu]=JavaScript-adatmodul
Name[ia]=JavaScript Motor de Datos (Data Engine)
Name[id]=Mesin Data JavaScript
Name[is]=JavaScript gagnavél
Name[it]=Motore di dati JavaScript
Name[ja]=JavaScript
Name[kk]=JavaScript деректер тетігі
Name[km]= JavaScript
Name[kn]=JavaScript DataEngine
Name[ko]=
Name[lt]=JavaScript duomenų variklis
Name[lv]=JavaScript datu dzinējs
Name[ml]=ി ി
Name[mr]=ि ि
Name[nb]=JavaScript datamotor
Name[nds]=JavaScript-Datenkarn
Name[nl]=JavaScript-data-engine
Name[nn]=JavaScript-datamotor
Name[pa]=-ਿ
Name[pl]=Silnik danych JavaScript
Name[pt]=Motor de Dados do JavaScript
Name[pt_BR]=Mecanismo de dados JavaScript
Name[ro]=MotorDate JavaScript
Name[ru]=Поставщик данных (JavaScript)
Name[si]=JavaScript
Name[sk]=Dátový nástroj JavaScript
Name[sl]=Podatkovni pogon za JavaScript
Name[sr]=јаваскриптни датомотор
Name[sr@ijekavian]=јаваскриптни датомотор
Name[sr@ijekavianlatin]=JavaScript datomotor
Name[sr@latin]=JavaScript datomotor
Name[sv]=Javascript-datagränssnitt
Name[tg]=Маълумоти муҳаррики JavaScript
Name[th]=
Name[tr]=JavaScript Veri Motoru
Name[ug]=JavaScript سانلىق-مەلۇمات ماتورى
Name[uk]=Рушій даних JavaScript
Name[vi]=Ngun d liu JavaScript
Name[wa]=Moteur di dnêyes JavaScript
Name[x-test]=xxJavaScript DataEnginexx
Name[zh_CN]=JavaScript
Name[zh_TW]=JavaScript
X-KDE-ServiceTypes=Plasma/ScriptEngine
Type=Service
Icon=text-x-script
X-KDE-Library=plasma_dataenginescript_javascript
X-Plasma-API=javascript
X-Plasma-ComponentTypes=DataEngine

View file

@ -1,163 +0,0 @@
[Desktop Entry]
Name=JavaScript Runner
Name[ar]=مشغل جافا سكربت
Name[ast]=Motor de javascript
Name[be@latin]=Uklučeńnie JavaScript
Name[bg]=Изпълнение на JavaScript
Name[bn]=ি
Name[bn_IN]=JavaScript Runner
Name[bs]=Javascript izvođač
Name[ca]=Executor de JavaScript
Name[ca@valencia]=Executor de JavaScript
Name[cs]=Spouštěč JavaScriptu
Name[csb]=Mòtór JavaScript
Name[da]=JavaScript-runner
Name[de]=JavaScript-Ausführung
Name[el]=Εκτελεστής JavaScript
Name[en_GB]=JavaScript Runner
Name[eo]=Ruligilo de Ĝavaskripto
Name[es]=Lanzador JavaScript
Name[et]=JavaScripti käivitaja
Name[eu]=JavaScript exekutatzailea
Name[fa]=اجراکننده جاوااسکریپت
Name[fi]=JavaScript-suoritusohjelma
Name[fr]=Lanceur JavaScript
Name[fy]=JavaSkript rinner
Name[ga]=Feidhmitheoir JavaScript
Name[gl]=Executor de JavaScript
Name[gu]=િ
Name[he]=מריץ JavaScript
Name[hi]=ि
Name[hne]=ि
Name[hr]=JavaScript Pokretač
Name[hu]=JavaScript-indító
Name[ia]=JavaScript Executor
Name[id]=Pelari JavaScript
Name[is]=JavaScript keyrari
Name[it]=Esecutore JavaScript
Name[ja]=JavaScript Runner
Name[kk]=JavaScript жеккіші
Name[km]= JavaScript
Name[kn]= ಿಿ (ಿ)
Name[ko]=
Name[ku]=Xebatkara JavaScriptê
Name[lt]=JavaScript paleidiklis
Name[lv]=JavaScript darbinātājs
Name[mk]=Извршувач на JavaScript
Name[ml]=ി
Name[mr]=ि
Name[nb]=JavaScript-kjører
Name[nds]=JavaScript-Dreger
Name[nl]=JavaScript-runner
Name[nn]=JavaScript-køyrar
Name[or]=JavaScript
Name[pa]=-ਿ
Name[pl]=Silnik JavaScript
Name[pt]=Execução de JavaScript
Name[pt_BR]=Mecanismo JavaScript
Name[ro]=Executor JavaScript
Name[ru]=JavaScript Runner
Name[si]=JavaScript
Name[sk]=Spúšťač JavaScriptu
Name[sl]=Zaganjalnik JavaScripta
Name[sr]=јаваскриптни извођач
Name[sr@ijekavian]=јаваскриптни извођач
Name[sr@ijekavianlatin]=JavaScript izvođač
Name[sr@latin]=JavaScript izvođač
Name[sv]=Kör Javascript
Name[ta]=JavaScript Runner
Name[te]=ి ి
Name[tg]=Иҷрогари JavaScript
Name[th]=
Name[tr]=JavaScript Çalıştırıcı
Name[ug]=JavaScript ئىجراچىسى
Name[uk]=Механізм запуску JavaScript
Name[vi]=Trình chy JavaScript
Name[wa]=Enondeu JavaScript
Name[x-test]=xxJavaScript Runnerxx
Name[zh_CN]=JavaScript
Name[zh_TW]=JavaScript
Comment=JavaScript Runner
Comment[ar]=مشغل جافا سكربت
Comment[ast]=Motor de javascript
Comment[be@latin]=Uklučeńnie JavaScript.
Comment[bg]=Изпълнение на JavaScript
Comment[bn]=ি
Comment[bn_IN]=JavaScript Runner
Comment[bs]=Javascript izvođač
Comment[ca]=Executor de JavaScript
Comment[ca@valencia]=Executor de JavaScript
Comment[cs]=Spouštěč JavaScriptu
Comment[csb]=Zrëszôcz JavaScript
Comment[da]=JavaScript-runner
Comment[de]=JavaScript-Ausführung
Comment[el]=Εκτελεστής JavaScript
Comment[en_GB]=JavaScript Runner
Comment[eo]=Ruligilo de Ĝavaskripto
Comment[es]=Lanzador JavaScript
Comment[et]=JavaScripti käivitaja
Comment[eu]=JavaScript exekutatzailea
Comment[fa]=اجراکننده جاوااسکریپت
Comment[fi]=JavaScript-suoritusohjelma
Comment[fr]=Lanceur JavaScript
Comment[fy]=JavaSkript rinner
Comment[ga]=Feidhmitheoir JavaScript
Comment[gl]=Executor de JavaScript
Comment[gu]=િ
Comment[he]=מריץ JavaScript
Comment[hi]=ि
Comment[hne]=ि
Comment[hr]=JavaScript pokretač
Comment[hu]=JavaScript-indító
Comment[ia]=JavaScript Executor
Comment[id]=Pelari JavaScript
Comment[is]=JavaScript keyrari
Comment[it]=Esecutore JavaScript
Comment[ja]=JavaScript Runner
Comment[kk]=JavaScript жеккіші
Comment[km]= JavaScript
Comment[kn]= ಿಿ (ಿ)
Comment[ko]=
Comment[ku]=Xebatkara JavaScriptê
Comment[lt]=JavaScript paleidiklis
Comment[lv]=JavaScript darbinātājs
Comment[mk]=Извршувач на JavaScript
Comment[ml]=ി
Comment[mr]=ि
Comment[nb]=JavaScript-kjører
Comment[nds]=JavaScript-Dreger
Comment[nl]=JavaScript-runner
Comment[nn]=JavaScript-køyrar
Comment[or]=JavaScript
Comment[pa]=-ਿ
Comment[pl]=Silnik JavaScript
Comment[pt]=Execução de JavaScript
Comment[pt_BR]=Mecanismo JavaScript
Comment[ro]=Executor JavaScript
Comment[ru]=Модуль запуска, написанный на языке JavaScript
Comment[si]=JavaScript Runner
Comment[sk]=Spúšťač JavaScriptu
Comment[sl]=Zaganjalnik JavaScripta
Comment[sr]=Јаваскриптни извођач
Comment[sr@ijekavian]=Јаваскриптни извођач
Comment[sr@ijekavianlatin]=JavaScript izvođač
Comment[sr@latin]=JavaScript izvođač
Comment[sv]=Kör Javascript
Comment[ta]=JavaScript Runner
Comment[te]=ి ి
Comment[tg]=Иҷрогари JavaScript
Comment[th]=
Comment[tr]=JavaScript Çalıştırıcı
Comment[ug]=JavaScript ئىجراچىسى
Comment[uk]=Механізм запуску JavaScript
Comment[vi]=Trình chy JavaScript
Comment[wa]=Enondeu JavaScript
Comment[x-test]=xxJavaScript Runnerxx
Comment[zh_CN]=JavaScript
Comment[zh_TW]=JavaScript
X-KDE-ServiceTypes=Plasma/ScriptEngine
Type=Service
Icon=text-x-script
X-KDE-Library=plasma_runnerscript_javascript
X-Plasma-API=javascript
X-Plasma-ComponentTypes=Runner

View file

@ -1,350 +0,0 @@
/*
* Copyright 2009 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 "javascriptdataengine.h"
#include <QScriptEngine>
#include <Plasma/Package>
#include "javascriptservice.h"
#include "common/scriptenv.h"
#include "simplebindings/i18n.h"
#include "simplebindings/dataengine.h"
void registerNonGuiMetaTypes(QScriptEngine *engine);
JavaScriptDataEngine::JavaScriptDataEngine(QObject *parent, const QVariantList &args)
: DataEngineScript(parent)
{
Q_UNUSED(args);
m_qscriptEngine = new QScriptEngine(this);
m_env = new ScriptEnv(this, m_qscriptEngine);
connect(m_env, SIGNAL(reportError(ScriptEnv*,bool)), this, SLOT(reportError(ScriptEnv*,bool)));
}
bool JavaScriptDataEngine::init()
{
QScriptValue global = m_qscriptEngine->globalObject();
bindI18N(m_qscriptEngine);
m_iface = m_qscriptEngine->newQObject(this);
m_iface.setScope(global);
m_env->addMainObjectProperties(m_iface);
global.setProperty("engine", m_iface);
global.setProperty("setData", m_qscriptEngine->newFunction(JavaScriptDataEngine::jsSetData));
global.setProperty("removeAllData", m_qscriptEngine->newFunction(JavaScriptDataEngine::jsRemoveAllData));
global.setProperty("removeData", m_qscriptEngine->newFunction(JavaScriptDataEngine::jsRemoveData));
global.setProperty("removeAllSources", m_qscriptEngine->newFunction(JavaScriptDataEngine::jsRemoveAllSources));
global.setProperty("Service", m_qscriptEngine->newFunction(JavaScriptDataEngine::serviceCtor));
registerNonGuiMetaTypes(m_qscriptEngine);
if (!m_env->importExtensions(description(), m_iface)) {
return false;
}
return m_env->include(mainScript());
}
QScriptEngine *JavaScriptDataEngine::engine() const
{
return m_qscriptEngine;
}
void JavaScriptDataEngine::jsSetMaxSourceCount(int count)
{
setMaxSourceCount(count);
}
int JavaScriptDataEngine::maxSourceCount() const
{
return dataEngine()->maxSourceCount();
}
void JavaScriptDataEngine::jsSetMinimumPollingInterval(int interval)
{
setMinimumPollingInterval(interval);
}
int JavaScriptDataEngine::jsMinimumPollingInterval() const
{
return minimumPollingInterval();
}
void JavaScriptDataEngine::jsSetPollingInterval(int interval)
{
m_pollingInterval = interval;
setPollingInterval(interval);
}
int JavaScriptDataEngine::pollingInterval() const
{
return m_pollingInterval;
}
QScriptValue JavaScriptDataEngine::jsSetData(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() < 1) {
return context->throwError(i18n("setData() takes at least one argument"));
}
QString error;
JavaScriptDataEngine *iFace = extractIFace(engine, error);
if (!iFace) {
return context->throwError(error);
}
const QString source = context->argument(0).toString();
if (context->argumentCount() == 1) {
iFace->setData(source, DataEngine::Data());
} else if (context->argument(1).isArray() || context->argument(1).isObject()) {
kDebug( )<< "array or object";
QScriptValueIterator it(context->argument(1));
DataEngine::Data data;
while (it.hasNext()) {
it.next();
data.insert(it.name(), it.value().toVariant());
}
iFace->setData(source, data);
} else {
const QString value = context->argument(1).toString();
if (context->argumentCount() > 2) {
if (context->argument(2).isArray() || context->argument(2).isObject()) {
QScriptValueIterator it(context->argument(2));
DataEngine::Data data;
while (it.hasNext()) {
it.next();
data.insert(it.name(), it.value().toVariant());
}
iFace->setData(source, value, data);
} else {
iFace->setData(source, value, context->argument(2).toString());
}
} else {
iFace->setData(source, value);
}
}
return engine->newVariant(true);
}
JavaScriptDataEngine *JavaScriptDataEngine::extractIFace(QScriptEngine *engine, QString &error)
{
JavaScriptDataEngine *interface = 0;
QScriptValue engineValue = engine->globalObject().property("engine");
QObject *engineObject = engineValue.toQObject();
if (!engineObject) {
error = i18n("Could not extract the DataEngineObject");
} else {
interface = qobject_cast<JavaScriptDataEngine *>(engineObject);
if (!interface) {
error = i18n("Could not extract the DataEngine");
}
}
return interface;
}
QScriptValue JavaScriptDataEngine::jsRemoveAllData(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() < 1) {
return context->throwError(i18n("removeAllData() takes at least one argument (the source name)"));
}
QString source = context->argument(0).toString();
QString error;
JavaScriptDataEngine *iFace = extractIFace(engine, error);
if (iFace) {
iFace->removeAllData(source);
return engine->newVariant(true);
}
return context->throwError(error);
}
QScriptValue JavaScriptDataEngine::jsRemoveData(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() < 2) {
return context->throwError(i18n("removeData() takes at least two arguments (the source and key names)"));
}
QString source = context->argument(0).toString();
QString key = context->argument(1).toString();
QString error;
JavaScriptDataEngine *iFace = extractIFace(engine, error);
if (iFace) {
iFace->removeData(source, key);
return engine->newVariant(true);
}
return context->throwError(error);
}
QScriptValue JavaScriptDataEngine::jsRemoveAllSources(QScriptContext *context, QScriptEngine *engine)
{
QString error;
JavaScriptDataEngine *iFace = extractIFace(engine, error);
if (iFace) {
iFace->removeAllSources();
return engine->newVariant(true);
}
return context->throwError(error);
}
QScriptValue JavaScriptDataEngine::serviceCtor(QScriptContext *context, QScriptEngine *engine)
{
QString error;
JavaScriptDataEngine *iFace = extractIFace(engine, error);
if (!iFace) {
return context->throwError(error);
}
if (context->argumentCount() < 1) {
return context->throwError(i18n("Service requires at least one parameter: the name of the service"));
}
const QString &serviceName = context->argument(0).toString();
if (serviceName.isEmpty()) {
return context->throwError(i18n("Service requires at least one parameter: the name of the service"));
}
JavaScriptService *service = new JavaScriptService(serviceName, iFace);
if (service->wasFound()) {
QScriptValue v = engine->newQObject(service, QScriptEngine::QtOwnership, QScriptEngine::ExcludeSuperClassContents);
return v;
}
delete service;
return context->throwError(i18n("Requested service %1 was not found in the Package.", serviceName));
}
QScriptValue JavaScriptDataEngine::callFunction(const QString &functionName, const QScriptValueList &args)
{
QScriptValue func = m_iface.property(functionName);
return m_env->callFunction(func, args, m_iface);
}
void JavaScriptDataEngine::reportError(ScriptEnv *env, bool fatal) const
{
Q_UNUSED(fatal)
kDebug() << "Error: " << env->engine()->uncaughtException().toString()
<< " at line " << env->engine()->uncaughtExceptionLineNumber() << endl;
kDebug() << env->engine()->uncaughtExceptionBacktrace();
}
QStringList JavaScriptDataEngine::sources() const
{
JavaScriptDataEngine *unconst = const_cast<JavaScriptDataEngine *>(this);
QScriptValueList args;
QScriptValue rv = unconst->callFunction("sources", args);
if (rv.isValid() && (rv.isVariant() || rv.isArray())) {
return rv.toVariant().toStringList();
}
return DataEngineScript::sources();
}
bool JavaScriptDataEngine::sourceRequestEvent(const QString &name)
{
QScriptValueList args;
args << name;
m_env->callEventListeners("sourceRequestEvent", args);
QScriptValue rv = callFunction("sourceRequestEvent", args);
if (rv.isValid() && rv.isBool()) {
return rv.toBool();
}
return false;
}
bool JavaScriptDataEngine::updateSourceEvent(const QString &source)
{
QScriptValueList args;
args << source;
m_env->callEventListeners("updateSourcEvent", args);
QScriptValue rv = callFunction("updateSourceEvent", args);
if (rv.isValid() && rv.isBool()) {
return rv.toBool();
}
return false;
}
Plasma::Service *JavaScriptDataEngine::serviceForSource(const QString &source)
{
QScriptValueList args;
args << source;
QScriptValue rv = callFunction("serviceForSource", args);
if (rv.isValid() && rv.isQObject()) {
Plasma::Service *service = qobject_cast<Plasma::Service *>(rv.toQObject());
if (service) {
if (service->destination().isEmpty()) {
service->setDestination(source);
}
return service;
} else {
delete rv.toQObject();
}
}
return 0;
}
QString JavaScriptDataEngine::filePath(const char *type, const QString &file) const
{
const QString path = m_env->filePathFromScriptContext(type, file);
if (!path.isEmpty()) {
return path;
}
return package()->filePath(type, file);
}
bool JavaScriptDataEngine::include(const QString &script)
{
const QString path = filePath("scripts", script);
if (path.isEmpty()) {
return false;
}
return m_env->include(path);
}
K_EXPORT_PLASMA_DATAENGINESCRIPTENGINE(javascriptdataengine, JavaScriptDataEngine)
#include "moc_javascriptdataengine.cpp"

View file

@ -1,79 +0,0 @@
/*
* Copyright 2009 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.
*/
#ifndef JAVASCRIPTDATAENGINE_H
#define JAVASCRIPTDATAENGINE_H
#include <Plasma/DataEngineScript>
#include <QScriptValue>
class ScriptEnv;
class QScriptContext;
class QScriptEngine;
class JavaScriptDataEngine : public Plasma::DataEngineScript
{
Q_OBJECT
Q_PROPERTY(int sourceCount WRITE jsSetMaxSourceCount READ maxSourceCount)
Q_PROPERTY(int minimumPollingInterval WRITE jsSetMinimumPollingInterval READ jsMinimumPollingInterval)
Q_PROPERTY(int pollingInterval WRITE jsSetPollingInterval READ pollingInterval)
public:
JavaScriptDataEngine(QObject *parent, const QVariantList &args);
bool init();
QScriptEngine *engine() const;
QString filePath(const char *type, const QString &file) const;
QStringList sources() const;
bool sourceRequestEvent(const QString &name);
bool updateSourceEvent(const QString &source);
Plasma::Service *serviceForSource(const QString &source);
int maxSourceCount() const;
void jsSetMaxSourceCount(int count);
void jsSetMinimumPollingInterval(int interval);
int jsMinimumPollingInterval() const;
void jsSetPollingInterval(int interval);
int pollingInterval() const;
public Q_SLOTS:
bool include(const QString &file);
private Q_SLOTS:
void reportError(ScriptEnv *engine, bool fatal) const;
private:
static JavaScriptDataEngine *extractIFace(QScriptEngine *engine, QString &error);
static QScriptValue jsSetData(QScriptContext *context, QScriptEngine *engine);
static QScriptValue jsRemoveAllData(QScriptContext *context, QScriptEngine *engine);
static QScriptValue jsRemoveData(QScriptContext *context, QScriptEngine *engine);
static QScriptValue jsRemoveAllSources(QScriptContext *context, QScriptEngine *engine);
static QScriptValue serviceCtor(QScriptContext *context, QScriptEngine *engine);
QScriptValue callFunction(const QString &functionName, const QScriptValueList &args);
QScriptEngine *m_qscriptEngine;
ScriptEnv *m_env;
QScriptValue m_iface;
int m_pollingInterval;
};
#endif

View file

@ -1,119 +0,0 @@
/*
* Copyright 2010 Aaron J. 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 version 2 as
* published by the Free Software Foundation
*
* 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 "javascriptservice.h"
#include <QFile>
#include <KDebug>
#include <Plasma/ServiceJob>
#include "common/scriptenv.h"
#include "javascriptdataengine.h"
JavaScriptServiceJob::JavaScriptServiceJob(QScriptEngine *engine, const QString &destination, const QString &operation,
const QMap<QString, QVariant> &parameters, QObject *parent)
: Plasma::ServiceJob(destination, operation, parameters, parent),
m_thisObject(engine->newQObject(this, QScriptEngine::QtOwnership, QScriptEngine::ExcludeSuperClassContents))
{
}
void JavaScriptServiceJob::start()
{
if (!m_startFunction.isFunction()) {
setResult(false);
return;
}
m_startFunction.call(m_thisObject);
}
QScriptValue JavaScriptServiceJob::scriptValue() const
{
return m_thisObject;
}
QScriptValue JavaScriptServiceJob::startFunction() const
{
return m_startFunction;
}
void JavaScriptServiceJob::setStartFunction(const QScriptValue &v)
{
m_startFunction = v;
}
JavaScriptService::JavaScriptService(const QString &serviceName, JavaScriptDataEngine *engine)
: Plasma::Service(engine),
m_dataEngine(engine)
{
setName(serviceName);
}
JavaScriptService::~JavaScriptService()
{
// kDebug();
}
Plasma::ServiceJob *JavaScriptService::createJob(const QString &operation, QMap<QString, QVariant> &parameters)
{
if (m_setupFunc.isFunction() && m_dataEngine && isOperationEnabled(operation)) {
JavaScriptServiceJob *job = new JavaScriptServiceJob(m_dataEngine.data()->engine(), destination(), operation, parameters, this);
QScriptValueList args;
args << job->scriptValue();
m_setupFunc.call(QScriptValue(), args);
return job;
}
return 0;
}
bool JavaScriptService::wasFound() const
{
return m_dataEngine;
}
void JavaScriptService::registerOperationsScheme()
{
if (!m_dataEngine) {
return;
}
const QString path = m_dataEngine.data()->filePath("services", name() + ".operations");
if (path.isEmpty()) {
kDebug() << "Cannot find operations description:" << name() << ".operations";
m_dataEngine.clear();
return;
}
QFile file(path);
setOperationsScheme(&file);
}
QScriptValue JavaScriptService::setupJobFunction() const
{
return m_setupFunc;
}
void JavaScriptService::setSetupJobFunction(const QScriptValue &v)
{
m_setupFunc = v;
}
#include "moc_javascriptservice.cpp"

View file

@ -1,90 +0,0 @@
/*
* Copyright 2010 Aaron J. 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 version 2 as
* published by the Free Software Foundation
*
* 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.
*/
#ifndef JAVASCRIPTSERVICE_H
#define JAVASCRIPTSERVICE_H
#include <QtCore/qsharedpointer.h>
#include <QScriptValue>
#include <Plasma/Package>
#include <Plasma/Service>
#include <Plasma/ServiceJob>
namespace Plasma
{
class Package;
} // namespace Plasma
class JavaScriptDataEngine;
class JavaScriptServiceJob : public Plasma::ServiceJob
{
Q_OBJECT
Q_PROPERTY(QString destination READ destination)
Q_PROPERTY(QString operationName READ operationName)
Q_PROPERTY(QVariantMap parameters READ parameters)
Q_PROPERTY(QVariant result READ result WRITE setResult)
Q_PROPERTY(int error READ error WRITE setError)
Q_PROPERTY(QString errorText READ errorText WRITE setErrorText)
Q_PROPERTY(QScriptValue start READ startFunction WRITE setStartFunction)
public:
JavaScriptServiceJob(QScriptEngine *engine, const QString &destination, const QString &operation,
const QMap<QString, QVariant> &parameters, QObject *parent = 0);
void start();
QScriptValue startFunction() const;
void setStartFunction(const QScriptValue &v);
QScriptValue scriptValue() const;
private:
QScriptValue m_startFunction;
QScriptValue m_thisObject;
};
class JavaScriptService : public Plasma::Service
{
Q_OBJECT
Q_PROPERTY(QString destination READ destination WRITE setDestination)
Q_PROPERTY(QStringList operationNames READ operationNames)
Q_PROPERTY(QString name READ name)
Q_PROPERTY(QScriptValue setupJob READ setupJobFunction WRITE setSetupJobFunction)
public:
JavaScriptService(const QString &serviceName, JavaScriptDataEngine *engine);
~JavaScriptService();
bool wasFound() const;
QScriptValue setupJobFunction() const;
void setSetupJobFunction(const QScriptValue &v);
protected:
Plasma::ServiceJob *createJob(const QString &operation, QMap<QString, QVariant> &parameters);
void registerOperationsScheme();
private:
QWeakPointer<JavaScriptDataEngine> m_dataEngine;
QScriptValue m_setupFunc;
};
#endif

View file

@ -1,22 +0,0 @@
/*
* Copyright 2010 Marco Martin <mart@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 version 2 as
* published by the Free Software Foundation
*
* 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.
*/
#define USE_JS_SCRIPTENGINE
#include "appletinterface.cpp"
#include "moc_appletinterface.cpp"

View file

@ -1,889 +0,0 @@
/*
* Copyright 2007-2008,2010 Richard J. Moore <rich@kde.org>
* Copyright 2009 Aaron J. 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 version 2 as
* published by the Free Software Foundation
*
* 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 "simplejavascriptapplet.h"
#include <iostream>
#include <QFile>
#include <QtGui/qevent.h>
#include <QGraphicsLayout>
#include <QtGui/qgraphicssceneevent.h>
#include <QtGui/qgraphicssceneevent.h>
#include <QtGui/qgraphicssceneevent.h>
#include <QParallelAnimationGroup>
#include <QPauseAnimation>
#include <QSequentialAnimationGroup>
#include <QUiLoader>
#include <QWidget>
#include <QScriptEngine>
#include <KConfigGroup>
#include <KDebug>
#include <KFileDialog>
#include <KIcon>
#include <KIO/Job>
#include <KMimeType>
#include <KShell>
#include <KStandardDirs>
#include <KLocale>
#include <KRun>
#include <Plasma/Animation>
#include <Plasma/Applet>
#include <Plasma/Extender>
#include <Plasma/ExtenderItem>
#include <Plasma/FrameSvg>
#include <Plasma/Package>
#include <Plasma/PopupApplet>
#include <Plasma/Svg>
#define USE_JS_SCRIPTENGINE
#include "appletinterface.h"
#include "scriptenv.h"
#include "simplebindings/animationgroup.h"
#include "simplebindings/bytearrayclass.h"
#include "simplebindings/dataengine.h"
#include "simplebindings/dataenginereceiver.h"
#include "simplebindings/i18n.h"
#include "themedsvg.h"
using namespace Plasma;
Q_DECLARE_METATYPE(QKeyEvent*)
Q_DECLARE_METATYPE(QPainter*)
Q_DECLARE_METATYPE(QStyleOptionGraphicsItem*)
Q_DECLARE_METATYPE(QGraphicsSceneHoverEvent *)
Q_DECLARE_METATYPE(QGraphicsSceneMouseEvent *)
Q_DECLARE_METATYPE(QGraphicsSceneWheelEvent *)
QScriptValue constructColorClass(QScriptEngine *engine);
QScriptValue constructEasingCurveClass(QScriptEngine *engine);
QScriptValue constructFontClass(QScriptEngine *engine);
QScriptValue constructGraphicsItemClass(QScriptEngine *engine);
QScriptValue constructIconClass(QScriptEngine *engine);
QScriptValue constructKUrlClass(QScriptEngine *engine);
QScriptValue constructLinearLayoutClass(QScriptEngine *engine);
QScriptValue constructGridLayoutClass(QScriptEngine *engine);
QScriptValue constructAnchorLayoutClass(QScriptEngine *engine);
QScriptValue constructPainterClass(QScriptEngine *engine);
QScriptValue constructPenClass(QScriptEngine *engine);
QScriptValue constructQPixmapClass(QScriptEngine *engine);
QScriptValue constructQPointClass(QScriptEngine *engine);
QScriptValue constructQRectFClass(QScriptEngine *engine);
QScriptValue constructQSizeFClass(QScriptEngine *engine);
QScriptValue constructQSizePolicyClass(QScriptEngine *engine);
QScriptValue constructTimerClass(QScriptEngine *engine);
void registerSimpleAppletMetaTypes(QScriptEngine *engine);
KSharedPtr<UiLoader> SimpleJavaScriptApplet::s_widgetLoader;
QHash<QString, Plasma::Animator::Animation> SimpleJavaScriptApplet::s_animationDefs;
SimpleJavaScriptApplet::SimpleJavaScriptApplet(QObject *parent, const QVariantList &args)
: AbstractJsAppletScript(parent),
m_interface(0)
{
Q_UNUSED(args);
// kDebug() << "Script applet launched, args" << applet()->startupArguments();
// TODO this will be set to the engine we get from QML
m_engine = new QScriptEngine(this);
m_env = new ScriptEnv(this, m_engine);
connect(m_env, SIGNAL(reportError(ScriptEnv*,bool)), this, SLOT(reportError(ScriptEnv*,bool)));
}
SimpleJavaScriptApplet::~SimpleJavaScriptApplet()
{
delete m_interface;
if (s_widgetLoader.count() == 1) {
s_widgetLoader.clear();
}
}
void SimpleJavaScriptApplet::reportError(ScriptEnv *env, bool fatal)
{
const QScriptValue error = env->engine()->uncaughtException();
QString file = error.property("fileName").toString();
file.remove(package()->path());
const QString failureMsg = i18n("Error in %1 on line %2.<br><br>%3",
file, error.property("lineNumber").toString(),
error.toString());
if (fatal) {
setFailedToLaunch(true, failureMsg);
} else {
showMessage(KIcon("dialog-error"), failureMsg, Plasma::ButtonOk);
}
kDebug() << failureMsg;
kDebug() << env->engine()->uncaughtExceptionBacktrace();
}
void SimpleJavaScriptApplet::configChanged()
{
ScriptEnv *env = ScriptEnv::findScriptEnv(m_engine);
if (!env || !env->callEventListeners("configchanged")) {
callPlasmoidFunction("configChanged", QScriptValueList(), env);
}
}
void SimpleJavaScriptApplet::dataUpdated(const QString &name, const DataEngine::Data &data)
{
ScriptEnv *env = ScriptEnv::findScriptEnv(m_engine);
if (!env) {
return;
}
QScriptValueList args;
args << m_engine->toScriptValue(name) << m_engine->toScriptValue(data);
if (!env->callEventListeners("dataUpdated", args)) {
callPlasmoidFunction("dataUpdated", args, env);
}
}
void SimpleJavaScriptApplet::extenderItemRestored(Plasma::ExtenderItem* item)
{
ScriptEnv *env = ScriptEnv::findScriptEnv(m_engine);
if (!env) {
return;
}
QScriptValueList args;
args << m_engine->newQObject(item, QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject);
if (!env->callEventListeners("initExtenderItem", args)) {
callPlasmoidFunction("initExtenderItem", args, env);
}
}
void SimpleJavaScriptApplet::activate()
{
ScriptEnv *env = ScriptEnv::findScriptEnv(m_engine);
if (!env || !env->callEventListeners("activate")) {
callPlasmoidFunction("activate", QScriptValueList(), env);
}
}
void SimpleJavaScriptApplet::popupEvent(bool popped)
{
ScriptEnv *env = ScriptEnv::findScriptEnv(m_engine);
if (!env) {
return;
}
QScriptValueList args;
args << popped;
if (!env->callEventListeners("popupEvent", args)) {
callPlasmoidFunction("popupEvent", args, env);
}
}
void SimpleJavaScriptApplet::executeAction(const QString &name)
{
ScriptEnv *env = ScriptEnv::findScriptEnv(m_engine);
if (!env) {
return;
}
const QString func("action_" + name);
if (!env->callEventListeners(func)) {
callPlasmoidFunction(func, QScriptValueList(), env);
}
}
void SimpleJavaScriptApplet::paintInterface(QPainter *p, const QStyleOptionGraphicsItem *option, const QRect &contentsRect)
{
ScriptEnv *env = ScriptEnv::findScriptEnv(m_engine);
if (!env) {
return;
}
QScriptValueList args;
args << m_engine->toScriptValue(p);
args << m_engine->toScriptValue(const_cast<QStyleOptionGraphicsItem*>(option));
args << m_engine->toScriptValue(QRectF(contentsRect));
if (!env->callEventListeners("paintInterface")) {
callPlasmoidFunction("paintInterface", args, env);
}
}
QList<QAction*> SimpleJavaScriptApplet::contextualActions()
{
if (!m_interface) {
return QList<QAction *>();
}
return m_interface->contextualActions();
}
void SimpleJavaScriptApplet::callPlasmoidFunction(const QString &functionName, const QScriptValueList &args, ScriptEnv *env)
{
if (!env) {
env = ScriptEnv::findScriptEnv(m_engine);
}
if (env) {
QScriptValue func = m_self.property(functionName);
env->callFunction(func, args, m_self);
}
}
void SimpleJavaScriptApplet::constraintsEvent(Plasma::Constraints constraints)
{
ScriptEnv *env = ScriptEnv::findScriptEnv(m_engine);
if (!env) {
return;
}
if (constraints & Plasma::FormFactorConstraint) {
if (!env->callEventListeners("formFactorChanged")) {
callPlasmoidFunction("formFactorChanged", QScriptValueList(), env);
}
}
if (constraints & Plasma::LocationConstraint) {
if (!env->callEventListeners("locationChanged")) {
callPlasmoidFunction("locationChanged", QScriptValueList(), env);
}
}
if (constraints & Plasma::SizeConstraint) {
if (!env || !env->callEventListeners("sizeChanged")) {
callPlasmoidFunction("sizeChanged", QScriptValueList(), env);
}
}
if (constraints & Plasma::ImmutableConstraint) {
if (!env->callEventListeners("immutabilityChanged")) {
callPlasmoidFunction("immutabilityChanged", QScriptValueList(), env);
}
}
}
bool SimpleJavaScriptApplet::include(const QString &path)
{
return m_env->include(path);
}
void SimpleJavaScriptApplet::populateAnimationsHash()
{
if (s_animationDefs.isEmpty()) {
s_animationDefs.insert("fade", Plasma::Animator::FadeAnimation);
s_animationDefs.insert("geometry", Plasma::Animator::GeometryAnimation);
s_animationDefs.insert("grow", Plasma::Animator::GrowAnimation);
s_animationDefs.insert("pulse", Plasma::Animator::PulseAnimation);
s_animationDefs.insert("rotate", Plasma::Animator::RotationAnimation);
s_animationDefs.insert("rotateStacked", Plasma::Animator::RotationStackedAnimation);
s_animationDefs.insert("slide", Plasma::Animator::SlideAnimation);
s_animationDefs.insert("zoom", Plasma::Animator::ZoomAnimation);
}
}
bool SimpleJavaScriptApplet::init()
{
connect(applet(), SIGNAL(extenderItemRestored(Plasma::ExtenderItem*)),
this, SLOT(extenderItemRestored(Plasma::ExtenderItem*)));
connect(applet(), SIGNAL(activate()),
this, SLOT(activate()));
KGlobal::locale()->insertCatalog("plasma_applet_" % description().pluginName());
setupObjects();
if (!m_env->importExtensions(description(), m_self)) {
return false;
}
kDebug() << "ScriptName:" << applet()->name();
kDebug() << "ScriptCategory:" << applet()->category();
applet()->installEventFilter(this);
return m_env->include(mainScript());
}
QScriptValue SimpleJavaScriptApplet::createKeyEventObject(QKeyEvent *event)
{
QScriptValue v = m_env->engine()->newObject();
v.setProperty("count", event->count());
v.setProperty("key", event->key());
v.setProperty("modifiers", static_cast<int>(event->modifiers()));
v.setProperty("text", event->text());
return v;
}
QScriptValue SimpleJavaScriptApplet::createHoverEventObject(QGraphicsSceneHoverEvent *event)
{
QScriptEngine *engine = m_env->engine();
QScriptValue v = engine->newObject();
v.setProperty("pos", engine->toScriptValue<QPoint>(event->pos().toPoint()));
v.setProperty("scenePos", engine->toScriptValue<QPoint>(event->scenePos().toPoint()));
v.setProperty("screenPos", engine->toScriptValue<QPoint>(event->screenPos()));
v.setProperty("lastPos", engine->toScriptValue<QPoint>(event->lastPos().toPoint()));
v.setProperty("lastScenePos", engine->toScriptValue<QPoint>(event->lastScenePos().toPoint()));
v.setProperty("lastScreenPos", engine->toScriptValue<QPoint>(event->lastScreenPos()));
v.setProperty("modifiers", static_cast<int>(event->modifiers()));
return v;
}
QScriptValue SimpleJavaScriptApplet::createMouseEventObject(QGraphicsSceneMouseEvent *event)
{
QScriptEngine *engine = m_env->engine();
QScriptValue v = engine->newObject();
v.setProperty("button", static_cast<int>(event->button()));
v.setProperty("buttons", static_cast<int>(event->buttons()));
v.setProperty("modifiers", static_cast<int>(event->modifiers()));
v.setProperty("pos", engine->toScriptValue<QPoint>(event->pos().toPoint()));
v.setProperty("scenePos", engine->toScriptValue<QPoint>(event->scenePos().toPoint()));
v.setProperty("screenPos", engine->toScriptValue<QPoint>(event->screenPos()));
v.setProperty("lastPos", engine->toScriptValue<QPoint>(event->lastPos().toPoint()));
v.setProperty("lastScenePos", engine->toScriptValue<QPoint>(event->lastScenePos().toPoint()));
v.setProperty("lastScreenPos", engine->toScriptValue<QPoint>(event->lastScreenPos()));
return v;
}
QScriptValue SimpleJavaScriptApplet::createWheelEventObject(QGraphicsSceneWheelEvent *event)
{
QScriptEngine *engine = m_env->engine();
QScriptValue v = engine->newObject();
v.setProperty("delta", event->delta());
v.setProperty("buttons", static_cast<int>(event->buttons()));
v.setProperty("modifiers", static_cast<int>(event->modifiers()));
v.setProperty("orientation", static_cast<int>(event->orientation()));
v.setProperty("pos", engine->toScriptValue<QPoint>(event->pos().toPoint()));
v.setProperty("scenePos", engine->toScriptValue<QPoint>(event->scenePos().toPoint()));
v.setProperty("screenPos", engine->toScriptValue<QPoint>(event->screenPos()));
return v;
}
bool SimpleJavaScriptApplet::eventFilter(QObject *watched, QEvent *event)
{
switch (event->type()) {
case QEvent::KeyPress: {
ScriptEnv *env = ScriptEnv::findScriptEnv(m_engine);
if (env && env->hasEventListeners("keypress")) {
QScriptValueList args;
args << createKeyEventObject(static_cast<QKeyEvent *>(event));
env->callEventListeners("keypress", args);
return true;
}
}
case QEvent::KeyRelease: {
ScriptEnv *env = ScriptEnv::findScriptEnv(m_engine);
if (env && env->hasEventListeners("keyrelease")) {
QScriptValueList args;
args << createKeyEventObject(static_cast<QKeyEvent *>(event));
env->callEventListeners("keyrelease", args);
return true;
}
}
break;
case QEvent::GraphicsSceneHoverEnter: {
ScriptEnv *env = ScriptEnv::findScriptEnv(m_engine);
if (env && env->hasEventListeners("hoverenter")) {
QScriptValueList args;
args << createHoverEventObject(static_cast<QGraphicsSceneHoverEvent *>(event));
env->callEventListeners("hoverenter", args);
return true;
}
}
break;
case QEvent::GraphicsSceneHoverLeave: {
ScriptEnv *env = ScriptEnv::findScriptEnv(m_engine);
if (env && env->hasEventListeners("hoverleave")) {
QScriptValueList args;
args << createHoverEventObject(static_cast<QGraphicsSceneHoverEvent *>(event));
env->callEventListeners("hoverleave", args);
return true;
}
}
break;
case QEvent::GraphicsSceneHoverMove: {
ScriptEnv *env = ScriptEnv::findScriptEnv(m_engine);
if (env && env->hasEventListeners("hovermove")) {
QScriptValueList args;
args << createHoverEventObject(static_cast<QGraphicsSceneHoverEvent *>(event));
env->callEventListeners("hovermove", args);
return true;
}
}
break;
case QEvent::GraphicsSceneMousePress: {
ScriptEnv *env = ScriptEnv::findScriptEnv(m_engine);
if (env && env->hasEventListeners("mousepress")) {
QScriptValueList args;
args << createMouseEventObject(static_cast<QGraphicsSceneMouseEvent *>(event));
env->callEventListeners("mousepress", args);
return true;
}
}
break;
case QEvent::GraphicsSceneMouseRelease: {
ScriptEnv *env = ScriptEnv::findScriptEnv(m_engine);
if (env && env->hasEventListeners("mouserelease")) {
QScriptValueList args;
args << createMouseEventObject(static_cast<QGraphicsSceneMouseEvent *>(event));
env->callEventListeners("mouserelease", args);
return true;
}
}
break;
case QEvent::GraphicsSceneMouseMove: {
ScriptEnv *env = ScriptEnv::findScriptEnv(m_engine);
if (env && env->hasEventListeners("mousemove")) {
QScriptValueList args;
args << createMouseEventObject(static_cast<QGraphicsSceneMouseEvent *>(event));
env->callEventListeners("mousemove", args);
return true;
}
}
break;
case QEvent::GraphicsSceneMouseDoubleClick: {
ScriptEnv *env = ScriptEnv::findScriptEnv(m_engine);
if (env && env->hasEventListeners("mousedoubleclick")) {
QScriptValueList args;
args << createMouseEventObject(static_cast<QGraphicsSceneMouseEvent *>(event));
env->callEventListeners("mousedoubleclick", args);
return true;
}
}
break;
case QEvent::GraphicsSceneWheel: {
ScriptEnv *env = ScriptEnv::findScriptEnv(m_engine);
if (env && env->hasEventListeners("wheel")) {
QScriptValueList args;
args << createWheelEventObject(static_cast<QGraphicsSceneWheelEvent *>(event));
env->callEventListeners("wheel", args);
return true;
}
}
break;
default:
break;
}
return Plasma::AppletScript::eventFilter(watched, event);
}
void SimpleJavaScriptApplet::setupObjects()
{
QScriptValue global = m_engine->globalObject();
// Bindings for animations
global.setProperty("animation", m_engine->newFunction(SimpleJavaScriptApplet::animation));
global.setProperty("AnimationGroup", m_engine->newFunction(SimpleJavaScriptApplet::animationGroup));
global.setProperty("ParallelAnimationGroup", m_engine->newFunction(SimpleJavaScriptApplet::parallelAnimationGroup));
QScriptValue v = m_engine->newVariant(QVariant::fromValue(*applet()->package()));
global.setProperty("__plasma_package", v,
QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
// Bindings for data engine
bindI18N(m_engine);
global.setProperty("dataEngine", m_engine->newFunction(SimpleJavaScriptApplet::dataEngine));
global.setProperty("service", m_engine->newFunction(SimpleJavaScriptApplet::service));
global.setProperty("loadService", m_engine->newFunction(SimpleJavaScriptApplet::loadService));
// Expose applet interface
const bool isPopupApplet = qobject_cast<Plasma::PopupApplet *>(applet());
m_interface = isPopupApplet ? new PopupAppletInterface(this) : new JsAppletInterface(this);
m_self = m_engine->newQObject(m_interface, QScriptEngine::QtOwnership, QScriptEngine::ExcludeDeleteLater);
m_env->addMainObjectProperties(m_self);
m_self.setScope(global);
global.setProperty("plasmoid", m_self);
if (isPopupApplet) {
connect(applet(), SIGNAL(popupEvent(bool)), this, SLOT(popupEvent(bool)));
}
QScriptValue args = m_engine->newArray();
int i = 0;
foreach (const QVariant &arg, applet()->startupArguments()) {
args.setProperty(i, m_engine->newVariant(arg));
++i;
}
global.setProperty("startupArguments", args);
ScriptEnv::registerEnums(global, AppletInterface::staticMetaObject);
// Add a global loadui method for ui files
QScriptValue fun = m_engine->newFunction(SimpleJavaScriptApplet::loadui);
global.setProperty("loadui", fun);
// Work around bug in 4.3.0
qMetaTypeId<QVariant>();
// Add stuff from Qt
global.setProperty("QPainter", constructPainterClass(m_engine));
global.setProperty("QGraphicsItem", constructGraphicsItemClass(m_engine));
global.setProperty("QIcon", constructIconClass(m_engine));
global.setProperty("QTimer", constructTimerClass(m_engine));
global.setProperty("QFont", constructFontClass(m_engine));
global.setProperty("QColor", constructColorClass(m_engine));
global.setProperty("QEasingCurve", constructEasingCurveClass(m_engine));
global.setProperty("QRectF", constructQRectFClass(m_engine));
global.setProperty("QPen", constructPenClass(m_engine));
global.setProperty("QPixmap", constructQPixmapClass(m_engine));
global.setProperty("QSizeF", constructQSizeFClass(m_engine));
global.setProperty("QSizePolicy", constructQSizePolicyClass(m_engine));
global.setProperty("QPoint", constructQPointClass(m_engine));
global.setProperty("LinearLayout", constructLinearLayoutClass(m_engine));
global.setProperty("GridLayout", constructGridLayoutClass(m_engine));
global.setProperty("AnchorLayout", constructAnchorLayoutClass(m_engine));
ByteArrayClass *baClass = new ByteArrayClass(m_engine);
global.setProperty("ByteArray", baClass->constructor());
// Add stuff from KDE libs
qScriptRegisterSequenceMetaType<KUrl::List>(m_engine);
global.setProperty("Url", constructKUrlClass(m_engine));
// Add stuff from Plasma
global.setProperty("PlasmaSvg", m_engine->newFunction(SimpleJavaScriptApplet::newPlasmaSvg));
global.setProperty("PlasmaFrameSvg", m_engine->newFunction(SimpleJavaScriptApplet::newPlasmaFrameSvg));
global.setProperty("Svg", m_engine->newFunction(SimpleJavaScriptApplet::newPlasmaSvg));
global.setProperty("FrameSvg", m_engine->newFunction(SimpleJavaScriptApplet::newPlasmaFrameSvg));
global.setProperty("ExtenderItem", m_engine->newFunction(SimpleJavaScriptApplet::newPlasmaExtenderItem));
registerSimpleAppletMetaTypes(m_engine);
installWidgets(m_engine);
}
QScriptValue SimpleJavaScriptApplet::dataEngine(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() != 1) {
return context->throwError(i18n("dataEngine() takes one argument"));
}
AppletInterface *interface = AppletInterface::extract(engine);
if (!interface) {
return context->throwError(i18n("Could not extract the Applet"));
}
const QString dataEngineName = context->argument(0).toString();
DataEngine *dataEngine = interface->dataEngine(dataEngineName);
QScriptValue v = engine->newQObject(dataEngine, QScriptEngine::QtOwnership, QScriptEngine::PreferExistingWrapperObject);
v.setProperty("connectSource", engine->newFunction(DataEngineReceiver::connectSource));
v.setProperty("connectAllSources", engine->newFunction(DataEngineReceiver::connectAllSources));
v.setProperty("disconnectSource", engine->newFunction(DataEngineReceiver::disconnectSource));
return v;
}
QScriptValue SimpleJavaScriptApplet::service(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() != 2) {
return context->throwError(i18n("service() takes two arguments"));
}
QString dataEngine = context->argument(0).toString();
AppletInterface *interface = AppletInterface::extract(engine);
if (!interface) {
return context->throwError(i18n("Could not extract the Applet"));
}
DataEngine *data = interface->dataEngine(dataEngine);
QString source = context->argument(1).toString();
Service *service = data->serviceForSource(source);
//kDebug( )<< "lets try to get" << source << "from" << dataEngine;
return engine->newQObject(service, QScriptEngine::AutoOwnership);
}
QScriptValue SimpleJavaScriptApplet::loadService(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() != 1) {
return context->throwError(i18n("service() takes one argument"));
}
QString pluginName = context->argument(0).toString();
AppletInterface *interface = AppletInterface::extract(engine);
if (!interface) {
return context->throwError(i18n("Could not extract the Applet"));
}
Plasma::Service *service = Plasma::Service::load(pluginName, interface);
//kDebug( )<< "lets try to get" << source << "from" << dataEngine;
return engine->newQObject(service, QScriptEngine::AutoOwnership);
}
QScriptValue SimpleJavaScriptApplet::animation(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() != 1) {
return context->throwError(i18n("animation() takes one argument"));
}
populateAnimationsHash();
QString name = context->argument(0).toString();
QString animName = name.toLower();
const bool isPause = animName == "pause";
const bool isProperty = animName == "property";
bool parentIsApplet = false;
QGraphicsWidget *parent = extractParent(context, engine, 0, &parentIsApplet);
QAbstractAnimation *anim = 0;
Plasma::Animation *plasmaAnim = 0;
if (isPause) {
anim = new QPauseAnimation(parent);
} else if (isProperty) {
anim = new QPropertyAnimation(parent);
} else if (s_animationDefs.contains(animName)) {
plasmaAnim = Plasma::Animator::create(s_animationDefs.value(animName), parent);
} else {
SimpleJavaScriptApplet *jsApplet = qobject_cast<SimpleJavaScriptApplet *>(engine->parent());
if (jsApplet) {
//kDebug() << "trying to load it from the package";
plasmaAnim = jsApplet->loadAnimationFromPackage(name, parent);
}
if (!plasmaAnim) {
plasmaAnim = Plasma::Animator::create(animName, parent);
}
}
if (plasmaAnim) {
if (!parentIsApplet) {
plasmaAnim->setTargetWidget(parent);
}
anim = plasmaAnim;
}
if (anim) {
QScriptValue value = engine->newQObject(anim);
ScriptEnv::registerEnums(value, *anim->metaObject());
return value;
}
context->throwError(i18n("%1 is not a known animation type", animName));
ScriptEnv *env = ScriptEnv::findScriptEnv(engine);
if (env) {
env->checkForErrors(false);
}
return engine->undefinedValue();
}
QScriptValue SimpleJavaScriptApplet::animationGroup(QScriptContext *context, QScriptEngine *engine)
{
QGraphicsWidget *parent = extractParent(context, engine);
SequentialAnimationGroup *group = new SequentialAnimationGroup(parent);
return engine->newQObject(group);
}
QScriptValue SimpleJavaScriptApplet::parallelAnimationGroup(QScriptContext *context, QScriptEngine *engine)
{
QGraphicsWidget *parent = extractParent(context, engine);
ParallelAnimationGroup *group = new ParallelAnimationGroup(parent);
return engine->newQObject(group);
}
QScriptValue SimpleJavaScriptApplet::loadui(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() != 1) {
return context->throwError(i18n("loadui() takes one argument"));
}
QString filename = context->argument(0).toString();
QFile f(filename);
if (!f.open(QIODevice::ReadOnly)) {
return context->throwError(i18n("Unable to open '%1'",filename));
}
QUiLoader loader;
QWidget *w = loader.load(&f);
f.close();
return engine->newQObject(w, QScriptEngine::AutoOwnership);
}
QScriptValue SimpleJavaScriptApplet::newPlasmaSvg(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() == 0) {
return context->throwError(i18n("Constructor takes at least 1 argument"));
}
const QString filename = context->argument(0).toString();
bool parentedToApplet = false;
QGraphicsWidget *parent = extractParent(context, engine, 1, &parentedToApplet);
Svg *svg = new ThemedSvg(parent);
svg->setImagePath(ThemedSvg::findSvg(engine, filename));
QScriptValue obj = engine->newQObject(svg);
ScriptEnv::registerEnums(obj, *svg->metaObject());
return obj;
}
QScriptValue SimpleJavaScriptApplet::newPlasmaFrameSvg(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() == 0) {
return context->throwError(i18n("Constructor takes at least 1 argument"));
}
QString filename = context->argument(0).toString();
bool parentedToApplet = false;
QGraphicsWidget *parent = extractParent(context, engine, 1, &parentedToApplet);
FrameSvg *frameSvg = new ThemedFrameSvg(parent);
frameSvg->setImagePath(ThemedSvg::findSvg(engine, filename));
QScriptValue obj = engine->newQObject(frameSvg);
ScriptEnv::registerEnums(obj, *frameSvg->metaObject());
return obj;
}
QScriptValue SimpleJavaScriptApplet::newPlasmaExtenderItem(QScriptContext *context, QScriptEngine *engine)
{
Plasma::Extender *extender = 0;
if (context->argumentCount() > 0) {
extender = qobject_cast<Plasma::Extender *>(context->argument(0).toQObject());
}
if (!extender) {
AppletInterface *interface = AppletInterface::extract(engine);
if (!interface) {
engine->undefinedValue();
}
extender = interface->extender();
}
Plasma::ExtenderItem *extenderItem = new Plasma::ExtenderItem(extender);
QScriptValue fun = engine->newQObject(extenderItem);
ScriptEnv::registerEnums(fun, *extenderItem->metaObject());
return fun;
}
QScriptValue SimpleJavaScriptApplet::widgetAdjustSize(QScriptContext *context, QScriptEngine *engine)
{
QGraphicsWidget *widget = qobject_cast<QGraphicsWidget*>(context->thisObject().toQObject());
if (widget) {
widget->adjustSize();
}
return engine->undefinedValue();
}
void SimpleJavaScriptApplet::installWidgets(QScriptEngine *engine)
{
QScriptValue globalObject = engine->globalObject();
if (!s_widgetLoader) {
s_widgetLoader = new UiLoader;
}
foreach (const QString &widget, s_widgetLoader->availableWidgets()) {
QScriptValue fun = engine->newFunction(createWidget);
QScriptValue name = engine->toScriptValue(widget);
fun.setProperty(QString("functionName"), name,
QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
fun.setProperty(QString("prototype"), engine->newObject());
globalObject.setProperty(widget, fun);
}
}
QScriptEngine *SimpleJavaScriptApplet::engine() const
{
return m_engine;
}
QGraphicsWidget *SimpleJavaScriptApplet::extractParent(QScriptContext *context, QScriptEngine *engine,
int argIndex, bool *parentedToApplet)
{
if (parentedToApplet) {
*parentedToApplet = false;
}
QGraphicsWidget *parent = 0;
if (context->argumentCount() >= argIndex) {
parent = qobject_cast<QGraphicsWidget*>(context->argument(argIndex).toQObject());
}
if (!parent) {
AppletInterface *interface = AppletInterface::extract(engine);
if (!interface) {
return 0;
}
//kDebug() << "got the applet!";
parent = interface->applet();
if (parentedToApplet) {
*parentedToApplet = true;
}
}
return parent;
}
QScriptValue SimpleJavaScriptApplet::createWidget(QScriptContext *context, QScriptEngine *engine)
{
QGraphicsWidget *parent = extractParent(context, engine);
QString self = context->callee().property("functionName").toString();
if (!s_widgetLoader) {
s_widgetLoader = new UiLoader;
}
QGraphicsWidget *w = s_widgetLoader->createWidget(self, parent);
if (!w) {
return QScriptValue();
}
QScriptValue fun = engine->newQObject(w);
fun.setPrototype(context->callee().property("prototype"));
fun.setProperty("adjustSize", engine->newFunction(widgetAdjustSize));
//register enums will be accessed for instance as frame.Sunken for Frame shadow...
ScriptEnv::registerEnums(fun, *w->metaObject());
return fun;
}
void SimpleJavaScriptApplet::collectGarbage()
{
m_engine->collectGarbage();
}
QString SimpleJavaScriptApplet::filePath(const QString &type, const QString &file) const
{
const QString path = m_env->filePathFromScriptContext(type.toLocal8Bit().constData(), file);
if (!path.isEmpty()) {
return path;
}
return package()->filePath(type.toLocal8Bit().constData(), file);
}
QScriptValue SimpleJavaScriptApplet::variantToScriptValue(QVariant var)
{
return m_engine->newVariant(var);
}
K_EXPORT_PLASMA_APPLETSCRIPTENGINE(qscriptapplet, SimpleJavaScriptApplet)

View file

@ -1,121 +0,0 @@
/*
* Copyright 2007, 2010 Richard J. Moore <rich@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 version 2 as
* published by the Free Software Foundation
*
* 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.
*/
#ifndef SCRIPT_H
#define SCRIPT_H
#include <QScriptValue>
#include <Plasma/Animator>
#include <Plasma/DataEngine>
#include "simplebindings/uiloader.h"
#include "abstractjsappletscript.h"
class QScriptContext;
class QScriptEngine;
class AppletInterface;
class ScriptEnv;
namespace Plasma
{
class ExtenderItem;
} // namespace Plasma
class SimpleJavaScriptApplet : public AbstractJsAppletScript
{
Q_OBJECT
public:
SimpleJavaScriptApplet(QObject *parent, const QVariantList &args);
~SimpleJavaScriptApplet();
bool init();
void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option, const QRect &contentsRect);
QList<QAction*> contextualActions();
void constraintsEvent(Plasma::Constraints constraints);
bool include(const QString &path);
QSet<QString> loadedExtensions() const;
QScriptValue variantToScriptValue(QVariant var);
QString filePath(const QString &type, const QString &file) const;
bool eventFilter(QObject *watched, QEvent *event);
QScriptEngine *engine() const;
public Q_SLOTS:
void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
void configChanged();
void executeAction(const QString &name);
void collectGarbage();
void extenderItemRestored(Plasma::ExtenderItem* item);
void popupEvent(bool popped);
void activate();
private Q_SLOTS:
void reportError(ScriptEnv *error, bool fatal);
private:
void setupObjects();
void callPlasmoidFunction(const QString &functionName, const QScriptValueList &args = QScriptValueList(), ScriptEnv *env = 0);
QScriptValue createKeyEventObject(QKeyEvent *event);
QScriptValue createHoverEventObject(QGraphicsSceneHoverEvent *event);
QScriptValue createMouseEventObject(QGraphicsSceneMouseEvent *event);
QScriptValue createWheelEventObject(QGraphicsSceneWheelEvent *event);
static void populateAnimationsHash();
static QString findSvg(QScriptContext *context, QScriptEngine *engine, const QString &file);
static QScriptValue animation(QScriptContext *context, QScriptEngine *engine);
static QScriptValue animationGroup(QScriptContext *context, QScriptEngine *engine);
static QScriptValue parallelAnimationGroup(QScriptContext *context, QScriptEngine *engine);
static QScriptValue jsi18n(QScriptContext *context, QScriptEngine *engine);
static QScriptValue jsi18nc(QScriptContext *context, QScriptEngine *engine);
static QScriptValue jsi18np(QScriptContext *context, QScriptEngine *engine);
static QScriptValue jsi18ncp(QScriptContext *context, QScriptEngine *engine);
static QScriptValue dataEngine(QScriptContext *context, QScriptEngine *engine);
static QScriptValue service(QScriptContext *context, QScriptEngine *engine);
static QScriptValue loadService(QScriptContext *context, QScriptEngine *engine);
static QScriptValue loadui(QScriptContext *context, QScriptEngine *engine);
static QScriptValue newPlasmaSvg(QScriptContext *context, QScriptEngine *engine);
static QScriptValue newPlasmaFrameSvg(QScriptContext *context, QScriptEngine *engine);
static QScriptValue newPlasmaExtenderItem(QScriptContext *context, QScriptEngine *engine);
void installWidgets(QScriptEngine *engine);
static QScriptValue createWidget(QScriptContext *context, QScriptEngine *engine);
static QScriptValue widgetAdjustSize(QScriptContext *context, QScriptEngine *engine);
static QGraphicsWidget *extractParent(QScriptContext *context,
QScriptEngine *engine,
int parentIndex = 0,
bool *parentedToApplet = 0);
private:
static KSharedPtr<UiLoader> s_widgetLoader;
static QHash<QString, Plasma::Animator::Animation> s_animationDefs;
ScriptEnv *m_env;
QScriptEngine *m_engine;
QScriptValue m_self;
QVariantList m_args;
AppletInterface *m_interface;
friend class AppletInterface;
};
#endif // SCRIPT_H

View file

@ -1,170 +0,0 @@
/*
* Copyright 2008 Richard J. Moore <rich@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 version 2 as
* published by the Free Software Foundation
*
* 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 "javascriptrunner.h"
#include <QFile>
#include <KDebug>
#include <Plasma/AbstractRunner>
#include <Plasma/Package>
#include <Plasma/QueryMatch>
#include "scriptenv.h"
typedef const Plasma::RunnerContext* ConstRunnerContextStar;
typedef const Plasma::QueryMatch* ConstSearchMatchStar;
Q_DECLARE_METATYPE(Plasma::QueryMatch*)
Q_DECLARE_METATYPE(Plasma::RunnerContext*)
Q_DECLARE_METATYPE(ConstRunnerContextStar)
Q_DECLARE_METATYPE(ConstSearchMatchStar)
JavaScriptRunner::JavaScriptRunner(QObject *parent, const QVariantList &args)
: RunnerScript(parent)
{
Q_UNUSED(args);
m_engine = new QScriptEngine(this);
m_env = new ScriptEnv(this, m_engine);
connect(m_engine, SIGNAL(reportError(ScriptEnv*,bool)), this, SLOT(reportError(ScriptEnv*,bool)));
}
JavaScriptRunner::~JavaScriptRunner()
{
}
Plasma::AbstractRunner* JavaScriptRunner::runner() const
{
return RunnerScript::runner();
}
bool JavaScriptRunner::init()
{
setupObjects();
if (!m_env->importExtensions(description(), m_self)) {
return false;
}
QFile file(mainScript());
if (!file.open(QIODevice::ReadOnly | QIODevice::Text) ) {
kWarning() << "Unable to load script file";
return false;
}
QString script = file.readAll();
kDebug() << "Script says" << script;
m_engine->evaluate(script);
if (m_engine->hasUncaughtException()) {
reportError(m_env, true);
return false;
}
return m_env->include(mainScript());
}
void JavaScriptRunner::match(Plasma::RunnerContext &search)
{
QScriptValue fun = m_self.property("match");
if (!fun.isFunction()) {
kDebug() << "Script: match is not a function, " << fun.toString();
return;
}
QScriptValueList args;
args << m_engine->toScriptValue(&search);
QScriptContext *ctx = m_engine->pushContext();
ctx->setActivationObject(m_self);
fun.call(m_self, args);
m_engine->popContext();
if (m_engine->hasUncaughtException()) {
reportError(m_env, false);
m_engine->clearExceptions();
}
}
void JavaScriptRunner::exec(const Plasma::RunnerContext *search, const Plasma::QueryMatch *action)
{
QScriptValue fun = m_self.property("exec");
if (!fun.isFunction()) {
kDebug() << "Script: exec is not a function, " << fun.toString();
return;
}
QScriptValueList args;
args << m_engine->toScriptValue(search);
args << m_engine->toScriptValue(action);
QScriptContext *ctx = m_engine->pushContext();
ctx->setActivationObject(m_self);
fun.call(m_self, args);
m_engine->popContext();
if (m_engine->hasUncaughtException()) {
reportError(m_env, false);
m_engine->clearExceptions();
}
}
void JavaScriptRunner::setupObjects()
{
QScriptValue global = m_engine->globalObject();
// Expose the runner
m_self = m_engine->newQObject(this);
m_self.setScope(global);
m_env->addMainObjectProperties(m_self);
global.setProperty("runner", m_self);
}
void JavaScriptRunner::reportError(ScriptEnv *env, bool fatal)
{
Q_UNUSED(fatal)
kDebug() << "Error: " << env->engine()->uncaughtException().toString()
<< " at line " << env->engine()->uncaughtExceptionLineNumber() << endl;
kDebug() << env->engine()->uncaughtExceptionBacktrace();
}
QString JavaScriptRunner::filePath(const char *type, const QString &file) const
{
const QString path = m_env->filePathFromScriptContext(type, file);
if (!path.isEmpty()) {
return path;
}
return package()->filePath(type, file);
}
bool JavaScriptRunner::include(const QString &script)
{
const QString path = filePath("scripts", script);
if (path.isEmpty()) {
return false;
}
return m_env->include(path);
}
#include "moc_javascriptrunner.cpp"

View file

@ -1,67 +0,0 @@
// -*- c++ -*-
/*
* Copyright 2008 Richard J. Moore <rich@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 version 2 as
* published by the Free Software Foundation
*
* 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.
*/
#ifndef JAVASCRIPTRUNNER_H
#define JAVASCRIPTRUNNER_H
#include <QScriptValue>
#include <Plasma/RunnerScript>
class QScriptEngine;
class ScriptEnv;
class JavaScriptRunner : public Plasma::RunnerScript
{
Q_OBJECT
public:
JavaScriptRunner(QObject *parent, const QVariantList &args);
~JavaScriptRunner();
bool init();
/** Reimplemented to add Q_INVOKABLE. */
Q_INVOKABLE Plasma::AbstractRunner* runner() const;
/** Reimplemented to forward to script. */
void match(Plasma::RunnerContext &search);
/** Reimplemented to forward to script. */
void exec(const Plasma::RunnerContext *search, const Plasma::QueryMatch *action);
public Q_SLOTS:
bool include(const QString &script);
private:
void setupObjects();
void importExtensions();
void reportError(ScriptEnv *engine, bool fatal);
QString filePath(const char *type, const QString &file) const;
QScriptEngine *m_engine;
ScriptEnv *m_env;
QScriptValue m_self;
};
K_EXPORT_PLASMA_RUNNERSCRIPTENGINE(qscriptrunner, JavaScriptRunner)
#endif // JAVASCRIPTRUNNER_H

View file

@ -1,154 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@kde.org>
* Copyright 2009 Artur Duque de Souza <asouza@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 version 2 as
* published by the Free Software Foundation
*
* 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 <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QGraphicsWidget>
#include <QGraphicsAnchorLayout>
#include <Plasma/Applet>
#include "backportglobal.h"
Q_DECLARE_METATYPE(QScript::Pointer<QGraphicsItem>::wrapped_pointer_type)
Q_DECLARE_METATYPE(QGraphicsWidget*)
Q_DECLARE_METATYPE(QGraphicsAnchor*)
Q_DECLARE_METATYPE(QGraphicsLayoutItem*)
DECLARE_POINTER_METATYPE(QGraphicsAnchorLayout)
// QGraphicsAnchorLayout
DECLARE_VOID_NUMBER_METHOD(QGraphicsAnchorLayout, setSpacing)
DECLARE_NUMBER_GET_SET_METHODS(QGraphicsAnchorLayout, horizontalSpacing, setHorizontalSpacing)
DECLARE_NUMBER_GET_SET_METHODS(QGraphicsAnchorLayout, verticalSpacing, setVerticalSpacing)
DECLARE_VOID_NUMBER_METHOD(QGraphicsAnchorLayout, removeAt)
/////////////////////////////////////////////////////////////
QGraphicsLayoutItem *extractLayoutItem(QScriptContext *ctx, int index = 0, bool noExistingLayout = false);
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
QGraphicsLayoutItem *parent = extractLayoutItem(ctx, 0, true);
//FIXME: don't leak memory when parent is 0
return qScriptValueFromValue(eng, new QGraphicsAnchorLayout(parent));
}
BEGIN_DECLARE_METHOD(QGraphicsAnchorLayout, addAnchor) {
QGraphicsLayoutItem *item1 = extractLayoutItem(ctx, 0);
QGraphicsLayoutItem *item2 = extractLayoutItem(ctx, 2);
if (!item1 || !item2) {
return eng->undefinedValue();
}
QGraphicsAnchor *anchor = self->addAnchor(item1, static_cast<Qt::AnchorPoint>(ctx->argument(1).toInt32()),
item2, static_cast<Qt::AnchorPoint>(ctx->argument(3).toInt32()));
return eng->newQObject(anchor, QScriptEngine::QtOwnership);
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsAnchorLayout, anchor) {
QGraphicsLayoutItem *item1 = extractLayoutItem(ctx, 0);
QGraphicsLayoutItem *item2 = extractLayoutItem(ctx, 2);
if (!item1 || !item2) {
return eng->undefinedValue();
}
QGraphicsAnchor *anchor = self->anchor(item1, static_cast<Qt::AnchorPoint>(ctx->argument(1).toInt32()),
item2, static_cast<Qt::AnchorPoint>(ctx->argument(3).toInt32()));
return eng->newQObject(anchor, QScriptEngine::QtOwnership);
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsAnchorLayout, addCornerAnchors) {
QGraphicsLayoutItem *item1 = extractLayoutItem(ctx, 0);
QGraphicsLayoutItem *item2 = extractLayoutItem(ctx, 2);
if (!item1 || !item2) {
return eng->undefinedValue();
}
self->addCornerAnchors(item1, static_cast<Qt::Corner>(ctx->argument(1).toInt32()),
item2, static_cast<Qt::Corner>(ctx->argument(3).toInt32()));
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsAnchorLayout, addAnchors) {
QGraphicsLayoutItem *item1 = extractLayoutItem(ctx, 0);
QGraphicsLayoutItem *item2 = extractLayoutItem(ctx, 1);
if (!item1 || !item2) {
return eng->undefinedValue();
}
self->addAnchors(item1, item2, static_cast<Qt::Orientation>(ctx->argument(2).toInt32()));
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsAnchorLayout, toString) {
return QScriptValue(eng, "QGraphicsAnchorLayout");
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsAnchorLayout, activate) {
self->activate();
return eng->undefinedValue();
} END_DECLARE_METHOD
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
class PrototypeAnchorLayout : public QGraphicsAnchorLayout
{
public:
PrototypeAnchorLayout()
{ }
};
QScriptValue constructAnchorLayoutClass(QScriptEngine *eng)
{
QScriptValue proto =
QScript::wrapPointer<QGraphicsAnchorLayout>(eng,
new QGraphicsAnchorLayout(),
QScript::UserOwnership);
const QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
const QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
proto.setProperty("horizontalSpacing", eng->newFunction(horizontalSpacing), getter);
proto.setProperty("horizontalSpacing", eng->newFunction(setHorizontalSpacing), setter);
proto.setProperty("verticalSpacing", eng->newFunction(verticalSpacing), getter);
proto.setProperty("verticalSpacing", eng->newFunction(setVerticalSpacing), setter);
ADD_METHOD(proto, setSpacing);
ADD_METHOD(proto, removeAt);
ADD_METHOD(proto, addAnchor);
ADD_METHOD(proto, anchor);
ADD_METHOD(proto, addAnchors);
ADD_METHOD(proto, addCornerAnchors);
ADD_METHOD(proto, toString);
ADD_METHOD(proto, activate);
QScript::registerPointerMetaType<QGraphicsAnchorLayout>(eng, proto);
QScriptValue ctorFun = eng->newFunction(ctor, proto);
return ctorFun;
}

View file

@ -1,102 +0,0 @@
/*
* Copyright 2009 Aaron J. 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 version 2 as
* published by the Free Software Foundation
*
* 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 "animationgroup.h"
ParallelAnimationGroup::ParallelAnimationGroup(QObject *parent)
: QParallelAnimationGroup(parent)
{
}
void ParallelAnimationGroup::addAnimation(QAbstractAnimation *animation)
{
QParallelAnimationGroup::addAnimation(animation);
}
QAbstractAnimation *ParallelAnimationGroup::animationAt(int index) const
{
return QParallelAnimationGroup::animationAt(index);
}
int ParallelAnimationGroup::animationCount() const
{
return QParallelAnimationGroup::animationCount();
}
void ParallelAnimationGroup::clear()
{
QParallelAnimationGroup::clear();
}
int ParallelAnimationGroup::indexOfAnimation(QAbstractAnimation *animation) const
{
return QParallelAnimationGroup::indexOfAnimation(animation);
}
void ParallelAnimationGroup::insertAnimation(int index, QAbstractAnimation *animation)
{
QParallelAnimationGroup::insertAnimation(index, animation);
}
void ParallelAnimationGroup::removeAnimation(QAbstractAnimation *animation)
{
QParallelAnimationGroup::removeAnimation(animation);
}
SequentialAnimationGroup::SequentialAnimationGroup(QObject *parent)
: QSequentialAnimationGroup(parent)
{
}
void SequentialAnimationGroup::addAnimation(QAbstractAnimation *animation)
{
QSequentialAnimationGroup::addAnimation(animation);
}
QAbstractAnimation *SequentialAnimationGroup::animationAt(int index) const
{
return QSequentialAnimationGroup::animationAt(index);
}
int SequentialAnimationGroup::animationCount() const
{
return QSequentialAnimationGroup::animationCount();
}
void SequentialAnimationGroup::clear()
{
QSequentialAnimationGroup::clear();
}
int SequentialAnimationGroup::indexOfAnimation(QAbstractAnimation *animation) const
{
return QSequentialAnimationGroup::indexOfAnimation(animation);
}
void SequentialAnimationGroup::insertAnimation(int index, QAbstractAnimation *animation)
{
QSequentialAnimationGroup::insertAnimation(index, animation);
}
void SequentialAnimationGroup::removeAnimation(QAbstractAnimation *animation)
{
QSequentialAnimationGroup::removeAnimation(animation);
}
#include "moc_animationgroup.cpp"

View file

@ -1,348 +0,0 @@
/****************************************************************************
**
** This file is part of the Qt Script Generator.
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation info@qt.nokia.com
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging of
** this file. Please review the following information to ensure the GNU
** Lesser General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** Copyright (C) 2011 Nokia. All rights reserved
****************************************************************************/
#ifndef QTSCRIPTEXTENSIONS_GLOBAL_H
#define QTSCRIPTEXTENSIONS_GLOBAL_H
#include <QtCore/QSharedData>
#include <QPixmap>
Q_DECLARE_METATYPE(QPixmap*)
Q_DECLARE_METATYPE(QPixmap)
#define DECLARE_SELF(Class, __fn__) \
Class* self = qscriptvalue_cast<Class*>(ctx->thisObject()); \
if (!self) { \
return ctx->throwError(QScriptContext::TypeError, \
QString::fromLatin1("%0.prototype.%1: this object is not a %0") \
.arg(#Class).arg(#__fn__)); \
}
#define DECLARE_SELF2(Class, __fn__, __ret__) \
Class* self = qscriptvalue_cast<Class*>(thisObject()); \
if (!self) { \
context()->throwError(QScriptContext::TypeError, \
QString::fromLatin1("%0.prototype.%1: this object is not a %0") \
.arg(#Class).arg(#__fn__)); \
return __ret__; \
}
#define ADD_METHOD(__p__, __f__) \
__p__.setProperty(#__f__, __p__.engine()->newFunction(__f__))
#define ADD_GET_METHOD(__p__, __get__) \
ADD_METHOD(__p__, __get__)
#define ADD_GET_SET_METHODS(__p__, __get__, __set__) \
do { \
ADD_METHOD(__p__, __get__); \
ADD_METHOD(__p__, __set__); \
} while (0);
#define ADD_CTOR_FUNCTION(__c__, __f__) ADD_METHOD(__c__, __f__)
#define ADD_ENUM_VALUE(__c__, __ns__, __v__) \
__c__.setProperty(#__v__, QScriptValue(__c__.engine(), __ns__::__v__))
#define BEGIN_DECLARE_METHOD(Class, __mtd__) \
static QScriptValue __mtd__(QScriptContext *ctx, QScriptEngine *eng) \
{ \
DECLARE_SELF(Class, __mtd__);
#define END_DECLARE_METHOD \
}
#define DECLARE_GET_METHOD(Class, __get__) \
BEGIN_DECLARE_METHOD(Class, __get__) { \
return qScriptValueFromValue(eng, self->__get__()); \
} END_DECLARE_METHOD
#define DECLARE_SET_METHOD(Class, T, __set__) \
BEGIN_DECLARE_METHOD(Class, __set__) { \
self->__set__(qscriptvalue_cast<T>(ctx->argument(0))); \
return eng->undefinedValue(); \
} END_DECLARE_METHOD
#define DECLARE_GET_SET_METHODS(Class, T, __get__, __set__) \
DECLARE_GET_METHOD(Class, /*T,*/ __get__) \
DECLARE_SET_METHOD(Class, T, __set__)
#define DECLARE_SIMPLE_GET_METHOD(Class, __get__) \
BEGIN_DECLARE_METHOD(Class, __get__) { \
return QScriptValue(eng, self->__get__()); \
} END_DECLARE_METHOD
#define DECLARE_SIMPLE_SET_METHOD(Class, ToType, __set__) \
BEGIN_DECLARE_METHOD(Class, __set__) { \
self->__set__(ctx->argument(0).ToType()); \
return eng->undefinedValue(); \
} END_DECLARE_METHOD
#define DECLARE_BOOLEAN_GET_METHOD(Class, __set__) \
DECLARE_SIMPLE_GET_METHOD(Class, __set__)
#define DECLARE_BOOLEAN_SET_METHOD(Class, __set__) \
DECLARE_SIMPLE_SET_METHOD(Class, toBoolean, __set__)
#define DECLARE_INT_GET_METHOD(Class, __set__) \
DECLARE_SIMPLE_GET_METHOD(Class, __set__)
#define DECLARE_INT_SET_METHOD(Class, __set__) \
DECLARE_SIMPLE_SET_METHOD(Class, toInt32, __set__)
#define DECLARE_NUMBER_GET_METHOD(Class, __set__) \
DECLARE_SIMPLE_GET_METHOD(Class, __set__)
#define DECLARE_NUMBER_SET_METHOD(Class, __set__) \
DECLARE_SIMPLE_SET_METHOD(Class, toNumber, __set__)
#define DECLARE_STRING_GET_METHOD(Class, __set__) \
DECLARE_SIMPLE_GET_METHOD(Class, __set__)
#define DECLARE_STRING_SET_METHOD(Class, __set__) \
DECLARE_SIMPLE_SET_METHOD(Class, toString, __set__)
#define DECLARE_QOBJECT_GET_METHOD(Class, __get__) \
BEGIN_DECLARE_METHOD(Class, __get__) { \
return eng->newQObject(self->__get__()); \
} END_DECLARE_METHOD
#define DECLARE_QOBJECT_SET_METHOD(Class, __set__) \
DECLARE_SIMPLE_SET_METHOD(Class, toQObject, __set__)
#define DECLARE_BOOLEAN_GET_SET_METHODS(Class, __get__, __set__) \
DECLARE_BOOLEAN_GET_METHOD(Class, __get__) \
DECLARE_BOOLEAN_SET_METHOD(Class, __set__)
#define DECLARE_NUMBER_GET_SET_METHODS(Class, __get__, __set__) \
DECLARE_NUMBER_GET_METHOD(Class, __get__) \
DECLARE_NUMBER_SET_METHOD(Class, __set__)
#define DECLARE_INT_GET_SET_METHODS(Class, __get__, __set__) \
DECLARE_INT_GET_METHOD(Class, __get__) \
DECLARE_INT_SET_METHOD(Class, __set__)
#define DECLARE_STRING_GET_SET_METHODS(Class, __get__, __set__) \
DECLARE_STRING_GET_METHOD(Class, __get__) \
DECLARE_STRING_SET_METHOD(Class, __set__)
#define DECLARE_QOBJECT_GET_SET_METHODS(Class, __get__, __set__) \
DECLARE_QOBJECT_GET_METHOD(Class, __get__) \
DECLARE_QOBJECT_SET_METHOD(Class, __set__)
#define DECLARE_VOID_METHOD(Class, __fun__) \
BEGIN_DECLARE_METHOD(Class, __fun__) { \
self->__fun__(); \
return eng->undefinedValue(); \
} END_DECLARE_METHOD
#define DECLARE_VOID_NUMBER_METHOD(Class, __fun__) \
BEGIN_DECLARE_METHOD(Class, __fun__) { \
self->__fun__(ctx->argument(0).toNumber()); \
return eng->undefinedValue(); \
} END_DECLARE_METHOD
#define DECLARE_VOID_NUMBER_NUMBER_METHOD(Class, __fun__) \
BEGIN_DECLARE_METHOD(Class, __fun__) { \
self->__fun__(ctx->argument(0).toNumber(), ctx->argument(1).toNumber()); \
return eng->undefinedValue(); \
} END_DECLARE_METHOD
#define DECLARE_VOID_QUAD_NUMBER_METHOD(Class, __fun__) \
BEGIN_DECLARE_METHOD(Class, __fun__) { \
self->__fun__(ctx->argument(0).toNumber(), ctx->argument(1).toNumber(), ctx->argument(2).toNumber(), ctx->argument(3).toNumber()); \
return eng->undefinedValue(); \
} END_DECLARE_METHOD
#define DECLARE_VOID_1ARG_METHOD(Class, ArgType, __fun__) \
BEGIN_DECLARE_METHOD(Class, __fun__) { \
self->__fun__(qscriptvalue_cast<ArgType>(ctx->argument(0))); \
return eng->undefinedValue(); \
} END_DECLARE_METHOD
#define DECLARE_BOOLEAN_1ARG_METHOD(Class, ArgType, __fun__) \
BEGIN_DECLARE_METHOD(Class, __fun__) { \
return QScriptValue(eng, self->__fun__(qscriptvalue_cast<ArgType>(ctx->argument(0)))); \
} END_DECLARE_METHOD
#define DECLARE_POINTER_METATYPE(T) \
Q_DECLARE_METATYPE(T*) \
Q_DECLARE_METATYPE(QScript::Pointer<T>::wrapped_pointer_type)
namespace QScript
{
enum {
UserOwnership = 1
};
template <typename T>
class Pointer : public QSharedData
{
public:
typedef T* pointer_type;
typedef QExplicitlySharedDataPointer<Pointer<T> > wrapped_pointer_type;
~Pointer()
{
if (!(m_flags & UserOwnership))
delete m_value;
}
operator T*()
{
return m_value;
}
operator const T*() const
{
return m_value;
}
static wrapped_pointer_type create(T *value, uint flags = 0)
{
return wrapped_pointer_type(new Pointer(value, flags));
}
static QScriptValue toScriptValue(QScriptEngine *engine, T* const &source)
{
if (!source)
return engine->nullValue();
return engine->newVariant(QVariant::fromValue(source));
}
static void fromScriptValue(const QScriptValue &value, T* &target)
{
if (value.isVariant()) {
QVariant var = value.toVariant();
if (var.canConvert<T*>()) {
target = qvariant_cast<T*>(var);
} else if (var.canConvert<wrapped_pointer_type>()) {
target = qvariant_cast<wrapped_pointer_type>(var)->operator T*();
} else {
// look in prototype chain
target = 0;
int type = qMetaTypeId<T*>();
int pointerType = qMetaTypeId<wrapped_pointer_type>();
QScriptValue proto = value.prototype();
while (proto.isObject() && proto.isVariant()) {
int protoType = proto.toVariant().userType();
if ((type == protoType) || (pointerType == protoType)) {
QByteArray name = QMetaType::typeName(var.userType());
if (name.startsWith("QScript::Pointer<")) {
target = (*reinterpret_cast<wrapped_pointer_type*>(var.data()))->operator T*();
break;
} else {
target = static_cast<T*>(var.data());
break;
}
}
proto = proto.prototype();
}
}
} else if (value.isQObject()) {
QObject *qobj = value.toQObject();
QByteArray typeName = QMetaType::typeName(qMetaTypeId<T*>());
target = reinterpret_cast<T*>(qobj->qt_metacast(typeName.left(typeName.size()-1)));
} else {
target = 0;
}
}
uint flags() const
{ return m_flags; }
void setFlags(uint flags)
{ m_flags = flags; }
void unsetFlags(uint flags)
{ m_flags &= ~flags; }
protected:
Pointer(T* value, uint flags)
: m_flags(flags), m_value(value)
{}
private:
uint m_flags;
T* m_value;
};
template <typename T>
int registerPointerMetaType(
QScriptEngine *eng,
const QScriptValue &prototype = QScriptValue(),
T * /* dummy */ = 0
)
{
QScriptValue (*mf)(QScriptEngine *, T* const &) = Pointer<T>::toScriptValue;
void (*df)(const QScriptValue &, T* &) = Pointer<T>::fromScriptValue;
const int id = qMetaTypeId<T*>();
qScriptRegisterMetaType_helper(
eng, id, reinterpret_cast<QScriptEngine::MarshalFunction>(mf),
reinterpret_cast<QScriptEngine::DemarshalFunction>(df),
prototype);
eng->setDefaultPrototype(qMetaTypeId<typename Pointer<T>::wrapped_pointer_type>(), prototype);
return id;
}
inline void maybeReleaseOwnership(const QScriptValue &value)
{
if (value.isVariant()) {
QVariant var = value.toVariant();
QByteArray name = QMetaType::typeName(var.userType());
if (name.startsWith("QScript::Pointer<"))
(*reinterpret_cast<Pointer<void*>::wrapped_pointer_type *>(var.data()))->setFlags(UserOwnership);
}
}
inline void maybeTakeOwnership(const QScriptValue &value)
{
if (value.isVariant()) {
QVariant var = value.toVariant();
QByteArray name = QMetaType::typeName(var.userType());
if (name.startsWith("QScript::Pointer<"))
(*reinterpret_cast<Pointer<void*>::wrapped_pointer_type *>(var.data()))->unsetFlags(UserOwnership);
}
}
template <class T>
inline QScriptValue wrapPointer(QScriptEngine *eng, T *ptr, uint flags = 0)
{
return eng->newVariant(QVariant::fromValue(Pointer<T>::create(ptr, flags)));
}
} // namespace QScript
#ifdef QGRAPHICSITEM_H
namespace QScript {
template <class T>
inline QScriptValue wrapGVPointer(QScriptEngine *eng, T *item)
{
uint flags = item->parentItem() ? UserOwnership : 0;
return wrapPointer<T>(eng, item, flags);
}
} // namespace QScript
#endif // QGRAPHICSITEM_H
#endif // QTSCRIPTEXTENSIONS_GLOBAL_H

View file

@ -1,146 +0,0 @@
/*
* Copyright (c) 2009 Aaron J. 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 version 2 as
* published by the Free Software Foundation
*
* 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 <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QColor>
#include <KDebug>
#include <Plasma/Theme>
#include "backportglobal.h"
Q_DECLARE_METATYPE(QColor*)
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
if (ctx->argumentCount() == 0) {
return qScriptValueFromValue(eng, QColor());
} else if (ctx->argumentCount() == 1) {
QString namedColor = ctx->argument(0).toString();
return qScriptValueFromValue(eng, QColor(namedColor));
}
int r = 0;
int g = 0;
int b = 0;
int a = 255;
if (ctx->argumentCount() == 3) {
r = ctx->argument(0).toInt32();
g = ctx->argument(1).toInt32();
b = ctx->argument(2).toInt32();
}
if (ctx->argumentCount() == 4) {
a = ctx->argument(3).toInt32();
}
return qScriptValueFromValue(eng, QColor(r, g, b, a));
}
// red, green, blue, alpha, setRed, setGreen, setBlue, setAlpha, isValid, toString, name
static QScriptValue red(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QColor, red);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setRed(arg.toInt32());
}
return QScriptValue(eng, self->red());
}
static QScriptValue green(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QColor, green);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setGreen(arg.toInt32());
}
return QScriptValue(eng, self->green());
}
static QScriptValue blue(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QColor, blue);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setBlue(arg.toInt32());
}
return QScriptValue(eng, self->blue());
}
static QScriptValue alpha(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QColor, alpha);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setAlpha(arg.toInt32());
}
return QScriptValue(eng, self->alpha());
}
static QScriptValue valid(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QColor, valid);
return QScriptValue(eng, self->isValid());
}
static QScriptValue setThemeColor(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QColor, themeColor);
if (ctx->argumentCount() > 0) {
const qint32 arg = ctx->argument(0).toInt32();
if (arg >= 0 && arg <= Plasma::Theme::VisitedLinkColor) {
kDebug() << "setting to: " << static_cast<Plasma::Theme::ColorRole>(arg);
kDebug() << "color is: " << Plasma::Theme::defaultTheme()->color(static_cast<Plasma::Theme::ColorRole>(arg));
self->setRgba(Plasma::Theme::defaultTheme()->color(static_cast<Plasma::Theme::ColorRole>(arg)).rgba());
}
}
return ctx->thisObject();//.property("themeColor");
}
QScriptValue constructColorClass(QScriptEngine *eng)
{
QScriptValue proto = qScriptValueFromValue(eng, QColor());
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
proto.setProperty("red", eng->newFunction(red), getter | setter);
proto.setProperty("green", eng->newFunction(green), getter | setter);
proto.setProperty("blue", eng->newFunction(blue), getter | setter);
proto.setProperty("alpha", eng->newFunction(alpha), getter | setter);
proto.setProperty("valid", eng->newFunction(valid), getter);
ADD_METHOD(proto, setThemeColor);
eng->setDefaultPrototype(qMetaTypeId<QColor>(), proto);
eng->setDefaultPrototype(qMetaTypeId<QColor*>(), proto);
return eng->newFunction(ctor, proto);
}

View file

@ -1,160 +0,0 @@
/*
* Copyright 2010 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 version 2 as
* published by the Free Software Foundation
*
* 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 <QEasingCurve>
#include <QtCore/qmetaobject.h>
#include <QScriptValue>
#include <QScriptEngine>
#include <QScriptContext>
#include <QScriptable>
#include "backportglobal.h"
Q_DECLARE_METATYPE(QEasingCurve)
Q_DECLARE_METATYPE(QEasingCurve*)
#include <KDebug>
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
if (arg.isNumber()) {
qint32 type = arg.toInt32();
if (type > -1 && type < QEasingCurve::Custom) {
return qScriptValueFromValue(eng, QEasingCurve(static_cast<QEasingCurve::Type>(type)));
}
}
}
return qScriptValueFromValue(eng, QEasingCurve());
}
static QScriptValue toString(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QEasingCurve, toString);
return QScriptValue(eng, QString::fromLatin1("QEasingCurve(type=%0)").arg(self->type()));
}
static QScriptValue type(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QEasingCurve, type);
if (ctx->argumentCount()) {
QScriptValue arg = ctx->argument(0);
qint32 type = -1;
if (arg.isNumber()) {
type = arg.toInt32();
} else if (arg.isString()) {
QMetaObject meta = QEasingCurve::staticMetaObject;
QMetaEnum easingCurveEnum = meta.enumerator(meta.indexOfEnumerator("Type"));
type = easingCurveEnum.keyToValue(arg.toString().toAscii().data());
}
if (type > -1 && type < QEasingCurve::Custom) {
self->setType(static_cast<QEasingCurve::Type>(type));
}
}
return QScriptValue(eng, self->type());
}
static QScriptValue valueForProgress(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QEasingCurve, valueForProgress);
if (ctx->argumentCount() < 1 || !ctx->argument(0).isNumber()) {
return eng->undefinedValue();
}
return self->valueForProgress(ctx->argument(0).toNumber());
}
QScriptValue constructEasingCurveClass(QScriptEngine *eng)
{
QScriptValue proto = qScriptValueFromValue(eng, QEasingCurve());
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
proto.setProperty("type", eng->newFunction(type), getter | setter);
proto.setProperty("toString", eng->newFunction(toString), getter);
proto.setProperty("valueForProgress", eng->newFunction(valueForProgress), getter);
QScriptValue ctorFun = eng->newFunction(ctor, proto);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, Linear);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InQuad);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutQuad);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutQuad);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInQuad);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InCubic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutCubic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutCubic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInCubic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InQuart);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutQuart);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutQuart);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInQuart);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InQuint);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutQuint);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutQuint);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInQuint);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InSine);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutSine);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutSine);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInSine);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InExpo);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutExpo);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutExpo);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInExpo);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InCirc);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutCirc);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutCirc);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInCirc);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InElastic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutElastic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutElastic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInElastic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InBack);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutBack);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutBack);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInBack);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InBounce);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutBounce);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutBounce);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InCurve);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutCurve);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, SineCurve);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, CosineCurve);
eng->setDefaultPrototype(qMetaTypeId<QEasingCurve>(), proto);
eng->setDefaultPrototype(qMetaTypeId<QEasingCurve*>(), proto);
return ctorFun;
}

View file

@ -1,303 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@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 version 2 as
* published by the Free Software Foundation
*
* 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 <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QFont>
#include "backportglobal.h"
Q_DECLARE_METATYPE(QFont*)
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
if (ctx->argumentCount() == 0)
return qScriptValueFromValue(eng, QFont());
QString family = ctx->argument(0).toString();
if (ctx->argumentCount() == 1) {
QFont *other = qscriptvalue_cast<QFont*>(ctx->argument(0));
if (other)
return qScriptValueFromValue(eng, QFont(*other));
return qScriptValueFromValue(eng, QFont(family));
}
int pointSize = ctx->argument(1).toInt32();
if (ctx->argumentCount() == 2)
return qScriptValueFromValue(eng, QFont(family, pointSize));
int weight = ctx->argument(2).toInt32();
if (ctx->argumentCount() == 3)
return qScriptValueFromValue(eng, QFont(family, pointSize, weight));
bool italic = ctx->argument(3).toBoolean();
return qScriptValueFromValue(eng, QFont(family, pointSize, weight, italic));
}
static QScriptValue bold(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, bold);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setBold(arg.toBoolean());
}
return QScriptValue(eng, self->bold());
}
static QScriptValue defaultFamily(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, defaultFamily);
return QScriptValue(eng, self->defaultFamily());
}
static QScriptValue exactMatch(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, exactMatch);
return QScriptValue(eng, self->exactMatch());
}
static QScriptValue family(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, family);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setFamily(arg.toString());
}
return QScriptValue(eng, self->family());
}
static QScriptValue fixedPitch(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, fixedPitch);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setFixedPitch(arg.toBoolean());
}
return QScriptValue(eng, self->fixedPitch());
}
static QScriptValue fromString(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, fromString);
return QScriptValue(eng, self->fromString(ctx->argument(0).toString()));
}
static QScriptValue isCopyOf(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, isCopyOf);
QFont *other = qscriptvalue_cast<QFont*>(ctx->argument(0));
if (!other) {
return ctx->throwError(QScriptContext::TypeError,
"QFont.prototype.isCopyOf: argument is not a Font");
}
return QScriptValue(eng, self->isCopyOf(*other));
}
static QScriptValue italic(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, italic);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setItalic(arg.toBoolean());
}
return QScriptValue(eng, self->italic());
}
static QScriptValue kerning(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, kerning);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setKerning(arg.toBoolean());
}
return QScriptValue(eng, self->kerning());
}
static QScriptValue key(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, key);
return QScriptValue(eng, self->key());
}
static QScriptValue lastResortFamily(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, lastResortFamily);
return QScriptValue(eng, self->lastResortFamily());
}
static QScriptValue lastResortFont(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, lastResortFont);
return QScriptValue(eng, self->lastResortFont());
}
static QScriptValue overline(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, overline);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setOverline(arg.toBoolean());
}
return QScriptValue(eng, self->overline());
}
static QScriptValue pixelSize(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, pixelSize);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setPixelSize(arg.toInt32());
}
return QScriptValue(eng, self->pixelSize());
}
static QScriptValue pointSize(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, pointSize);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setPointSize(arg.toInt32());
}
return QScriptValue(eng, self->pointSize());
}
static QScriptValue pointSizeF(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, pointSizeF);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setPointSizeF(arg.toNumber());
}
return QScriptValue(eng, self->pointSizeF());
}
static QScriptValue resolve(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, resolve);
QFont *other = qscriptvalue_cast<QFont*>(ctx->argument(0));
if (!other) {
return ctx->throwError(QScriptContext::TypeError,
"QFont.prototype.isCopyOf: argument is not a Font");
}
return qScriptValueFromValue(eng, self->resolve(*other));
}
static QScriptValue stretch(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, stretch);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setStretch(arg.toInt32());
}
return QScriptValue(eng, self->stretch());
}
static QScriptValue strikeOut(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, strikeOut);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setStrikeOut(arg.toBoolean());
}
return QScriptValue(eng, self->strikeOut());
}
static QScriptValue toString(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, toString);
return QScriptValue(eng, self->toString());
}
static QScriptValue underline(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, underline);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setUnderline(arg.toBoolean());
}
return QScriptValue(eng, self->underline());
}
static QScriptValue weight(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, weight);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setWeight(arg.toInt32());
}
return QScriptValue(eng, self->weight());
}
QScriptValue constructFontClass(QScriptEngine *eng)
{
QScriptValue proto = qScriptValueFromValue(eng, QFont());
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
proto.setProperty("key", eng->newFunction(key), getter);
proto.setProperty("lastResortFamily", eng->newFunction(lastResortFamily), getter);
proto.setProperty("lastResortFont", eng->newFunction(lastResortFont), getter);
proto.setProperty("defaultFamily", eng->newFunction(defaultFamily), getter);
proto.setProperty("exactMatch", eng->newFunction(exactMatch), getter);
proto.setProperty("toString", eng->newFunction(toString), getter);
proto.setProperty("bold", eng->newFunction(bold), getter | setter);
proto.setProperty("family", eng->newFunction(family), getter|setter);
proto.setProperty("fixedPitch", eng->newFunction(fixedPitch), getter);
proto.setProperty("fromString", eng->newFunction(fromString), setter);
proto.setProperty("italic", eng->newFunction(italic), getter | setter);
proto.setProperty("kerning", eng->newFunction(kerning), getter | setter);
proto.setProperty("overline", eng->newFunction(overline), getter | setter);
proto.setProperty("pixelSize", eng->newFunction(pixelSize), getter | setter);
proto.setProperty("pointSize", eng->newFunction(pointSize), getter | setter);
proto.setProperty("pointSizeF", eng->newFunction(pointSizeF), getter | setter);
proto.setProperty("strikeOut", eng->newFunction(strikeOut), getter | setter);
proto.setProperty("stretch", eng->newFunction(stretch), getter | setter);
proto.setProperty("underline", eng->newFunction(underline), getter | setter);
proto.setProperty("weight", eng->newFunction(weight), getter | setter);
proto.setProperty("isCopyOf", eng->newFunction(isCopyOf));
proto.setProperty("resolve", eng->newFunction(resolve));
eng->setDefaultPrototype(qMetaTypeId<QFont>(), proto);
eng->setDefaultPrototype(qMetaTypeId<QFont*>(), proto);
return eng->newFunction(ctor, proto);
}

View file

@ -1,412 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@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 version 2 as
* published by the Free Software Foundation
*
* 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 <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QCursor>
#include <QGraphicsItem>
#include <QGraphicsScene>
#include "backportglobal.h"
Q_DECLARE_METATYPE(QScript::Pointer<QGraphicsItem>::wrapped_pointer_type)
Q_DECLARE_METATYPE(QList<QGraphicsItem*>)
Q_DECLARE_METATYPE(QPainterPath)
#ifndef QT_NO_CURSOR
Q_DECLARE_METATYPE(QCursor)
#endif
Q_DECLARE_METATYPE(QGraphicsItemGroup*)
Q_DECLARE_METATYPE(QPainter*)
Q_DECLARE_METATYPE(QStyleOptionGraphicsItem*)
Q_DECLARE_METATYPE(QGraphicsPathItem*)
Q_DECLARE_METATYPE(QGraphicsRectItem*)
Q_DECLARE_METATYPE(QGraphicsEllipseItem*)
Q_DECLARE_METATYPE(QGraphicsPolygonItem*)
Q_DECLARE_METATYPE(QGraphicsLineItem*)
Q_DECLARE_METATYPE(QGraphicsPixmapItem*)
Q_DECLARE_METATYPE(QGraphicsTextItem*)
Q_DECLARE_METATYPE(QGraphicsSimpleTextItem*)
DECLARE_BOOLEAN_GET_SET_METHODS(QGraphicsItem, acceptDrops, setAcceptDrops)
DECLARE_BOOLEAN_GET_SET_METHODS(QGraphicsItem, acceptHoverEvents, setAcceptHoverEvents)
DECLARE_GET_METHOD(QGraphicsItem, boundingRect)
DECLARE_GET_METHOD(QGraphicsItem, childItems)
DECLARE_GET_METHOD(QGraphicsItem, childrenBoundingRect)
#ifndef QT_NO_CURSOR
DECLARE_GET_SET_METHODS(QGraphicsItem, QCursor, cursor, setCursor)
DECLARE_BOOLEAN_GET_METHOD(QGraphicsItem, hasCursor)
#endif
DECLARE_GET_SET_METHODS(QGraphicsItem, QGraphicsItemGroup*, group, setGroup)
DECLARE_BOOLEAN_GET_SET_METHODS(QGraphicsItem, handlesChildEvents, setHandlesChildEvents)
DECLARE_BOOLEAN_GET_METHOD(QGraphicsItem, hasFocus)
DECLARE_BOOLEAN_GET_SET_METHODS(QGraphicsItem, isEnabled, setEnabled)
DECLARE_BOOLEAN_GET_SET_METHODS(QGraphicsItem, isSelected, setSelected)
DECLARE_BOOLEAN_GET_SET_METHODS(QGraphicsItem, isVisible, setVisible)
DECLARE_GET_METHOD(QGraphicsItem, opaqueArea)
DECLARE_GET_METHOD(QGraphicsItem, pos)
DECLARE_QOBJECT_GET_METHOD(QGraphicsItem, scene)
DECLARE_GET_METHOD(QGraphicsItem, sceneBoundingRect)
DECLARE_GET_METHOD(QGraphicsItem, scenePos)
DECLARE_GET_METHOD(QGraphicsItem, sceneTransform)
DECLARE_GET_METHOD(QGraphicsItem, shape)
#ifndef QT_NO_TOOLTIP
DECLARE_STRING_GET_SET_METHODS(QGraphicsItem, toolTip, setToolTip)
#endif
DECLARE_GET_METHOD(QGraphicsItem, topLevelItem)
DECLARE_GET_SET_METHODS(QGraphicsItem, QTransform, transform, setTransform)
DECLARE_NUMBER_GET_METHOD(QGraphicsItem, type)
DECLARE_NUMBER_GET_METHOD(QGraphicsItem, x)
DECLARE_NUMBER_GET_METHOD(QGraphicsItem, y)
DECLARE_NUMBER_GET_SET_METHODS(QGraphicsItem, zValue, setZValue)
DECLARE_BOOLEAN_1ARG_METHOD(QGraphicsItem, QPointF, contains)
DECLARE_VOID_METHOD(QGraphicsItem, clearFocus)
DECLARE_VOID_METHOD(QGraphicsItem, hide)
DECLARE_BOOLEAN_1ARG_METHOD(QGraphicsItem, QGraphicsItem*, isAncestorOf)
DECLARE_BOOLEAN_1ARG_METHOD(QGraphicsItem, QGraphicsItem*, isObscuredBy)
DECLARE_VOID_NUMBER_NUMBER_METHOD(QGraphicsItem, moveBy)
DECLARE_VOID_METHOD(QGraphicsItem, resetTransform)
#ifndef QT_NO_CURSOR
DECLARE_VOID_METHOD(QGraphicsItem, unsetCursor)
#endif
DECLARE_VOID_METHOD(QGraphicsItem, show)
DECLARE_VOID_NUMBER_NUMBER_METHOD(QGraphicsItem, translate)
DECLARE_VOID_NUMBER_NUMBER_METHOD(QGraphicsItem, scale)
DECLARE_VOID_NUMBER_NUMBER_METHOD(QGraphicsItem, shear)
DECLARE_VOID_1ARG_METHOD(QGraphicsItem, QGraphicsItem*, installSceneEventFilter)
DECLARE_VOID_1ARG_METHOD(QGraphicsItem, QGraphicsItem*, removeSceneEventFilter)
DECLARE_VOID_NUMBER_METHOD(QGraphicsItem, rotate)
/////////////////////////////////////////////////////////////
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *)
{
return ctx->throwError("QGraphicsItem cannot be instantiated");
}
BEGIN_DECLARE_METHOD(QGraphicsItem, acceptedMouseButtons) {
return QScriptValue(eng, static_cast<int>(self->acceptedMouseButtons()));
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, advance) {
self->advance(ctx->argument(0).toInt32());
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, collidesWithItem) {
QGraphicsItem *other = qscriptvalue_cast<QGraphicsItem*>(ctx->argument(0));
if (!other) {
return ctx->throwError(QScriptContext::TypeError,
"QGraphicsItem.prototype.collidesWithItem: argument is not a GraphicsItem");
}
if (ctx->argument(1).isUndefined())
return QScriptValue(eng, self->collidesWithItem(other));
else
return QScriptValue(eng, self->collidesWithItem(other, static_cast<Qt::ItemSelectionMode>(ctx->argument(1).toInt32())));
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, collidesWithPath) {
QPainterPath path = qscriptvalue_cast<QPainterPath>(ctx->argument(0));
if (ctx->argument(1).isUndefined())
return QScriptValue(eng, self->collidesWithPath(path));
else
return QScriptValue(eng, self->collidesWithPath(path, static_cast<Qt::ItemSelectionMode>(ctx->argument(1).toInt32())));
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, collidingItems) {
if (ctx->argument(0).isUndefined())
return qScriptValueFromValue(eng, self->collidingItems());
else
return qScriptValueFromValue(eng, self->collidingItems(static_cast<Qt::ItemSelectionMode>(ctx->argument(0).toInt32())));
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, data) {
return eng->newVariant(self->data(ctx->argument(0).toInt32()));
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, ensureVisible) {
Q_UNUSED(eng);
return ctx->throwError("QGraphicsItem.prototype.ensureVisible is not implemented");
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, flags) {
return QScriptValue(eng, static_cast<int>(self->flags()));
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, isObscured) {
if (ctx->argumentCount() == 0) {
return QScriptValue(eng, self->isObscured());
} else if (ctx->argumentCount() > 1) {
return QScriptValue(eng, self->isObscured(ctx->argument(0).toInt32(),
ctx->argument(1).toInt32(),
ctx->argument(2).toInt32(),
ctx->argument(3).toInt32()));
} else {
return QScriptValue(eng, self->isObscured(qscriptvalue_cast<QRectF>(ctx->argument(0))));
}
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, mapFromItem) {
Q_UNUSED(eng);
return ctx->throwError("QGraphicsItem.prototype.mapFromItem is not implemented");
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, mapFromParent) {
Q_UNUSED(eng);
return ctx->throwError("QGraphicsItem.prototype.mapFromParent is not implemented");
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, mapFromScene) {
Q_UNUSED(eng);
return ctx->throwError("QGraphicsItem.prototype.mapFromScene is not implemented");
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, mapToItem) {
Q_UNUSED(eng);
return ctx->throwError("QGraphicsItem.prototype.mapToItem is not implemented");
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, mapToParent) {
Q_UNUSED(eng);
return ctx->throwError("QGraphicsItem.prototype.mapToParent is not implemented");
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, mapToScene) {
Q_UNUSED(eng);
return ctx->throwError("QGraphicsItem.prototype.mapToScene is not implemented");
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, paint) {
self->paint(qscriptvalue_cast<QPainter*>(ctx->argument(0)),
qscriptvalue_cast<QStyleOptionGraphicsItem*>(ctx->argument(1)),
qscriptvalue_cast<QWidget*>(ctx->argument(2)));
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, parentItem) {
QGraphicsItem *parent = self->parentItem();
if (!parent)
return eng->nullValue();
QScriptValue ret = qScriptValueFromValue(eng, parent);
QScriptValue proto;
switch (parent->type()) {
case 2:
proto = eng->defaultPrototype(qMetaTypeId<QGraphicsPathItem*>());
break;
case 3:
proto = eng->defaultPrototype(qMetaTypeId<QGraphicsRectItem*>());
break;
case 4:
proto = eng->defaultPrototype(qMetaTypeId<QGraphicsEllipseItem*>());
break;
case 5:
proto = eng->defaultPrototype(qMetaTypeId<QGraphicsPolygonItem*>());
break;
case 6:
proto = eng->defaultPrototype(qMetaTypeId<QGraphicsLineItem*>());
break;
case 7:
proto = eng->defaultPrototype(qMetaTypeId<QGraphicsPixmapItem*>());
break;
case 8:
proto = eng->defaultPrototype(qMetaTypeId<QGraphicsTextItem*>());
break;
case 9:
proto = eng->defaultPrototype(qMetaTypeId<QGraphicsSimpleTextItem*>());
break;
case 10:
proto = eng->defaultPrototype(qMetaTypeId<QGraphicsItemGroup*>());
break;
}
if (proto.isValid())
ret.setPrototype(proto);
return ret;
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, setAcceptedMouseButtons) {
self->setAcceptedMouseButtons(static_cast<Qt::MouseButtons>(ctx->argument(0).toInt32()));
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, setData) {
self->setData(ctx->argument(0).toInt32(), ctx->argument(1).toVariant());
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, setFlag) {
QGraphicsItem::GraphicsItemFlag flag = static_cast<QGraphicsItem::GraphicsItemFlag>(ctx->argument(0).toInt32());
if (ctx->argument(1).isUndefined())
self->setFlag(flag);
else
self->setFlag(flag, ctx->argument(1).toBoolean());
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, setFlags) {
self->setFlags(static_cast<QGraphicsItem::GraphicsItemFlags>(ctx->argument(0).toInt32()));
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, setFocus) {
if (ctx->argument(0).isUndefined())
self->setFocus();
else
self->setFocus(static_cast<Qt::FocusReason>(ctx->argument(0).toInt32()));
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, setParentItem) {
QScriptValue arg = ctx->argument(0);
QGraphicsItem *item = qscriptvalue_cast<QGraphicsItem*>(arg);
self->setParentItem(item);
if (item)
QScript::maybeReleaseOwnership(ctx->thisObject());
else if (!self->scene())
QScript::maybeTakeOwnership(ctx->thisObject());
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, setPos) {
if (ctx->argumentCount() > 1)
self->setPos(ctx->argument(0).toNumber(), ctx->argument(1).toNumber());
else
self->setPos(qscriptvalue_cast<QPointF>(ctx->argument(0)));
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, update) {
if (ctx->argumentCount() > 1) {
self->update(ctx->argument(0).toNumber(),
ctx->argument(1).toNumber(),
ctx->argument(2).toNumber(),
ctx->argument(3).toNumber());
} else {
self->update(qscriptvalue_cast<QRectF>(ctx->argument(0)));
}
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, toString) {
return QScriptValue(eng, "QGraphicsItem");
} END_DECLARE_METHOD
/////////////////////////////////////////////////////////////
class PrototypeGraphicsItem : public QGraphicsItem
{
public:
PrototypeGraphicsItem()
{ }
QRectF boundingRect() const
{ return QRectF(); }
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)
{ }
};
QScriptValue constructGraphicsItemClass(QScriptEngine *eng)
{
QScriptValue proto = QScript::wrapGVPointer<QGraphicsItem>(eng, new PrototypeGraphicsItem());
ADD_GET_SET_METHODS(proto, acceptDrops, setAcceptDrops);
ADD_GET_SET_METHODS(proto, acceptHoverEvents, setAcceptHoverEvents);
ADD_GET_METHOD(proto, boundingRect);
ADD_GET_METHOD(proto, childItems);
ADD_GET_METHOD(proto, childrenBoundingRect);
#ifndef QT_NO_CURSOR
ADD_GET_SET_METHODS(proto, cursor, setCursor);
ADD_GET_METHOD(proto, hasCursor);
#endif
ADD_GET_SET_METHODS(proto, group, setGroup);
ADD_GET_SET_METHODS(proto, handlesChildEvents, setHandlesChildEvents);
ADD_GET_METHOD(proto, hasFocus);
ADD_GET_SET_METHODS(proto, isEnabled, setEnabled);
ADD_GET_SET_METHODS(proto, isSelected, setSelected);
ADD_GET_SET_METHODS(proto, isVisible, setVisible);
ADD_GET_METHOD(proto, opaqueArea);
ADD_GET_METHOD(proto, pos);
ADD_GET_METHOD(proto, scene);
ADD_GET_METHOD(proto, sceneBoundingRect);
ADD_GET_METHOD(proto, scenePos);
ADD_GET_METHOD(proto, sceneTransform);
ADD_GET_METHOD(proto, shape);
#ifndef QT_NO_TOOLTIP
ADD_GET_SET_METHODS(proto, toolTip, setToolTip);
#endif
ADD_GET_METHOD(proto, topLevelItem);
ADD_GET_SET_METHODS(proto, transform, setTransform);
ADD_GET_METHOD(proto, type);
ADD_GET_METHOD(proto, x);
ADD_GET_METHOD(proto, y);
ADD_GET_SET_METHODS(proto, zValue, setZValue);
ADD_METHOD(proto, acceptedMouseButtons);
ADD_METHOD(proto, advance);
ADD_METHOD(proto, clearFocus);
ADD_METHOD(proto, collidesWithItem);
ADD_METHOD(proto, collidesWithPath);
ADD_METHOD(proto, collidingItems);
ADD_METHOD(proto, contains);
ADD_METHOD(proto, data);
ADD_METHOD(proto, ensureVisible);
ADD_METHOD(proto, flags);
ADD_METHOD(proto, hide);
ADD_METHOD(proto, installSceneEventFilter);
ADD_METHOD(proto, isAncestorOf);
ADD_METHOD(proto, isObscured);
ADD_METHOD(proto, isObscuredBy);
ADD_METHOD(proto, mapFromItem);
ADD_METHOD(proto, mapFromParent);
ADD_METHOD(proto, mapFromScene);
ADD_METHOD(proto, mapToItem);
ADD_METHOD(proto, mapToParent);
ADD_METHOD(proto, mapToScene);
ADD_METHOD(proto, moveBy);
ADD_METHOD(proto, paint);
ADD_METHOD(proto, parentItem);
ADD_METHOD(proto, removeSceneEventFilter);
ADD_METHOD(proto, resetTransform);
ADD_METHOD(proto, rotate);
ADD_METHOD(proto, scale);
ADD_METHOD(proto, setAcceptedMouseButtons);
ADD_METHOD(proto, setData);
ADD_METHOD(proto, setFlag);
ADD_METHOD(proto, setFlags);
ADD_METHOD(proto, setFocus);
ADD_METHOD(proto, setParentItem);
ADD_METHOD(proto, setPos);
ADD_METHOD(proto, shear);
ADD_METHOD(proto, show);
ADD_METHOD(proto, toString);
ADD_METHOD(proto, translate);
#ifndef QT_NO_CURSOR
ADD_METHOD(proto, unsetCursor);
#endif
ADD_METHOD(proto, update);
QScript::registerPointerMetaType<QGraphicsItem>(eng, proto);
QScriptValue ctorFun = eng->newFunction(ctor, proto);
ADD_ENUM_VALUE(ctorFun, QGraphicsItem, ItemIsMovable);
ADD_ENUM_VALUE(ctorFun, QGraphicsItem, ItemIsSelectable);
ADD_ENUM_VALUE(ctorFun, QGraphicsItem, ItemIsFocusable);
ADD_ENUM_VALUE(ctorFun, QGraphicsItem, ItemClipsToShape);
ADD_ENUM_VALUE(ctorFun, QGraphicsItem, ItemClipsChildrenToShape);
ADD_ENUM_VALUE(ctorFun, QGraphicsItem, ItemIgnoresTransformations);
return ctorFun;
}

View file

@ -1,182 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@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 version 2 as
* published by the Free Software Foundation
*
* 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 <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QGraphicsWidget>
#include <QGraphicsGridLayout>
#include <QGraphicsLayout>
#include <Plasma/Applet>
#include "backportglobal.h"
#define DECLARE_INT_NUMBER_GET_METHOD(Class, __get__) \
BEGIN_DECLARE_METHOD(Class, __get__) { \
return QScriptValue(eng, self->__get__(ctx->argument(0).toInt32())); \
} END_DECLARE_METHOD
#define DECLARE_INT_NUMBER_SET_METHOD(Class, __set__) \
BEGIN_DECLARE_METHOD(Class, __set__) { \
self->__set__(ctx->argument(0).toInt32(), ctx->argument(1).toNumber()); \
return eng->undefinedValue(); \
} END_DECLARE_METHOD
#define DECLARE_INT_NUMBER_GET_SET_METHODS(Class, __get__, __set__) \
DECLARE_INT_NUMBER_GET_METHOD(Class, __get__) \
DECLARE_INT_NUMBER_SET_METHOD(Class, __set__)
Q_DECLARE_METATYPE(QScript::Pointer<QGraphicsItem>::wrapped_pointer_type)
Q_DECLARE_METATYPE(QGraphicsWidget*)
Q_DECLARE_METATYPE(QGraphicsLayout*)
Q_DECLARE_METATYPE(QGraphicsLayoutItem*)
DECLARE_POINTER_METATYPE(QGraphicsGridLayout)
DECLARE_VOID_NUMBER_METHOD(QGraphicsGridLayout, removeAt)
DECLARE_VOID_NUMBER_METHOD(QGraphicsGridLayout, setSpacing)
DECLARE_VOID_QUAD_NUMBER_METHOD(QGraphicsGridLayout, setContentsMargins)
DECLARE_NUMBER_GET_SET_METHODS(QGraphicsGridLayout, horizontalSpacing, setHorizontalSpacing)
DECLARE_NUMBER_GET_SET_METHODS(QGraphicsGridLayout, verticalSpacing, setVerticalSpacing)
DECLARE_INT_NUMBER_GET_SET_METHODS(QGraphicsGridLayout, rowSpacing, setRowSpacing)
DECLARE_INT_NUMBER_GET_SET_METHODS(QGraphicsGridLayout, columnSpacing, setColumnSpacing)
DECLARE_INT_NUMBER_GET_SET_METHODS(QGraphicsGridLayout, rowMinimumHeight, setRowMinimumHeight)
DECLARE_INT_NUMBER_GET_SET_METHODS(QGraphicsGridLayout, rowPreferredHeight, setRowPreferredHeight)
DECLARE_INT_NUMBER_GET_SET_METHODS(QGraphicsGridLayout, rowMaximumHeight, setRowMaximumHeight)
DECLARE_INT_NUMBER_SET_METHOD(QGraphicsGridLayout, setRowFixedHeight)
DECLARE_INT_NUMBER_GET_SET_METHODS(QGraphicsGridLayout, columnMinimumWidth, setColumnMinimumWidth)
DECLARE_INT_NUMBER_GET_SET_METHODS(QGraphicsGridLayout, columnPreferredWidth, setColumnPreferredWidth)
DECLARE_INT_NUMBER_GET_SET_METHODS(QGraphicsGridLayout, columnMaximumWidth, setColumnMaximumWidth)
DECLARE_INT_NUMBER_SET_METHOD(QGraphicsGridLayout, setColumnFixedWidth)
/////////////////////////////////////////////////////////////
QGraphicsLayoutItem *extractLayoutItem(QScriptContext *ctx, int index = 0, bool noExistingLayout = false);
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
QGraphicsLayoutItem *parent = extractLayoutItem(ctx, 0, true);
//FIXME: don't leak memory when parent is 0
return qScriptValueFromValue(eng, new QGraphicsGridLayout(parent));
}
BEGIN_DECLARE_METHOD(QGraphicsGridLayout, setAlignment) {
QGraphicsLayoutItem *item = extractLayoutItem(ctx);
if (!item) {
return eng->undefinedValue();
}
self->setAlignment(item, static_cast<Qt::Alignment>(ctx->argument(1).toInt32()));
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsGridLayout, addItem) {
QGraphicsLayoutItem *item = extractLayoutItem(ctx);
if (!item) {
return eng->undefinedValue();
}
int rowSpan = 1;
int colSpan = 1;
Qt::Alignment alignment = 0;
const int argCount = ctx->argumentCount();
if (argCount > 3) {
rowSpan = ctx->argument(3).toInt32();
if (argCount > 4) {
colSpan = ctx->argument(4).toInt32();
if (argCount > 5) {
alignment = static_cast<Qt::Alignment>(ctx->argument(5).toInt32());
}
}
}
self->addItem(item, ctx->argument(1).toInt32(), ctx->argument(2).toInt32(),
rowSpan, colSpan, alignment);
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsGridLayout, toString) {
return QScriptValue(eng, "QGraphicsGridLayout");
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsGridLayout, activate) {
self->activate();
return eng->undefinedValue();
} END_DECLARE_METHOD
/////////////////////////////////////////////////////////////
class PrototypeGridLayout : public QGraphicsGridLayout
{
public:
PrototypeGridLayout()
{ }
};
QScriptValue constructGridLayoutClass(QScriptEngine *eng)
{
QScriptValue proto = QScript::wrapPointer<QGraphicsGridLayout>(eng, new QGraphicsGridLayout(), QScript::UserOwnership);
const QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
const QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
proto.setProperty("horizontalSpacing", eng->newFunction(horizontalSpacing), getter);
proto.setProperty("horizontalSpacing", eng->newFunction(setHorizontalSpacing), setter);
proto.setProperty("verticalSpacing", eng->newFunction(verticalSpacing), getter);
proto.setProperty("verticalSpacing", eng->newFunction(setVerticalSpacing), setter);
ADD_METHOD(proto, rowSpacing);
ADD_METHOD(proto, setRowSpacing);
ADD_METHOD(proto, columnSpacing);
ADD_METHOD(proto, setColumnSpacing);
ADD_METHOD(proto, rowMinimumHeight);
ADD_METHOD(proto, setRowMinimumHeight);
ADD_METHOD(proto, rowPreferredHeight);
ADD_METHOD(proto, setRowPreferredHeight);
ADD_METHOD(proto, rowMaximumHeight);
ADD_METHOD(proto, setRowMaximumHeight);
ADD_METHOD(proto, setRowFixedHeight);
ADD_METHOD(proto, columnMinimumWidth);
ADD_METHOD(proto, setColumnMinimumWidth);
ADD_METHOD(proto, columnPreferredWidth);
ADD_METHOD(proto, setColumnPreferredWidth);
ADD_METHOD(proto, columnMaximumWidth);
ADD_METHOD(proto, setColumnMaximumWidth);
ADD_METHOD(proto, setColumnFixedWidth);
ADD_METHOD(proto, removeAt);
ADD_METHOD(proto, setAlignment);
ADD_METHOD(proto, setSpacing);
ADD_METHOD(proto, setContentsMargins);
ADD_METHOD(proto, addItem);
ADD_METHOD(proto, toString);
ADD_METHOD(proto, activate);
QScript::registerPointerMetaType<QGraphicsGridLayout>(eng, proto);
QScriptValue ctorFun = eng->newFunction(ctor, proto);
return ctorFun;
}

View file

@ -1,121 +0,0 @@
/*
* Copyright 2009 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 "i18n.h"
#include <QScriptContext>
#include <QScriptEngine>
#include <KDebug>
#include <KLocalizedString>
QScriptValue jsi18n(QScriptContext *context, QScriptEngine *engine)
{
Q_UNUSED(engine)
if (context->argumentCount() < 1) {
kDebug() << i18n("i18n() takes at least one argument");
return engine->undefinedValue();
}
KLocalizedString message = ki18n(context->argument(0).toString().toUtf8());
const int numArgs = context->argumentCount();
for (int i = 1; i < numArgs; ++i) {
message = message.subs(context->argument(i).toString());
}
return message.toString();
}
QScriptValue jsi18nc(QScriptContext *context, QScriptEngine *engine)
{
Q_UNUSED(engine)
if (context->argumentCount() < 2) {
kDebug() << i18n("i18nc() takes at least two arguments");
return engine->undefinedValue();
}
KLocalizedString message = ki18nc(context->argument(0).toString().toUtf8(),
context->argument(1).toString().toUtf8());
const int numArgs = context->argumentCount();
for (int i = 2; i < numArgs; ++i) {
message = message.subs(context->argument(i).toString());
}
return message.toString();
}
QScriptValue jsi18np(QScriptContext *context, QScriptEngine *engine)
{
Q_UNUSED(engine)
if (context->argumentCount() < 2) {
kDebug() << i18n("i18np() takes at least two arguments");
return engine->undefinedValue();
}
KLocalizedString message = ki18np(context->argument(0).toString().toUtf8(),
context->argument(1).toString().toUtf8());
const int numArgs = context->argumentCount();
for (int i = 2; i < numArgs; ++i) {
QScriptValue v = context->argument(i);
if (v.isNumber()) {
message = message.subs(v.toInt32());
} else {
message = message.subs(v.toString());
}
}
return message.toString();
}
QScriptValue jsi18ncp(QScriptContext *context, QScriptEngine *engine)
{
Q_UNUSED(engine)
if (context->argumentCount() < 3) {
kDebug() << i18n("i18ncp() takes at least three arguments");
return engine->undefinedValue();
}
KLocalizedString message = ki18ncp(context->argument(0).toString().toUtf8(),
context->argument(1).toString().toUtf8(),
context->argument(2).toString().toUtf8());
const int numArgs = context->argumentCount();
for (int i = 3; i < numArgs; ++i) {
message = message.subs(context->argument(i).toString());
}
return message.toString();
}
void bindI18N(QScriptEngine *engine)
{
QScriptValue global = engine->globalObject();
global.setProperty("i18n", engine->newFunction(jsi18n));
global.setProperty("i18nc", engine->newFunction(jsi18nc));
global.setProperty("i18np", engine->newFunction(jsi18np));
global.setProperty("i18ncp", engine->newFunction(jsi18ncp));
}

View file

@ -1,35 +0,0 @@
/*
* Copyright 2009 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.
*/
#ifndef JAVASCRIPTBINDI18N_H
#define JAVASCRIPTBINDI18N_H
#include <QScriptValue>
class QScriptContext;
class QScriptEngine;
QScriptValue jsi18n(QScriptContext *context, QScriptEngine *engine);
QScriptValue jsi18nc(QScriptContext *context, QScriptEngine *engine);
QScriptValue jsi18np(QScriptContext *context, QScriptEngine *engine);
QScriptValue jsi18ncp(QScriptContext *context, QScriptEngine *engine);
void bindI18N(QScriptEngine *engine);
#endif

View file

@ -1,111 +0,0 @@
/*
* Copyright (c) 2009 Aaron J. 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 version 2 as
* published by the Free Software Foundation
*
* 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 <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <KIcon>
#include "backportglobal.h"
Q_DECLARE_METATYPE(QIcon)
Q_DECLARE_METATYPE(QIcon*)
Q_DECLARE_METATYPE(KIcon)
Q_DECLARE_METATYPE(KIcon*)
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
if (ctx->argumentCount() > 0) {
QScriptValue v = ctx->argument(0);
if (v.isString()) {
QIcon icon = KIcon(v.toString());
return qScriptValueFromValue(eng, icon);
} else if (v.isVariant()) {
QVariant variant = v.toVariant();
QPixmap p = variant.value<QPixmap>();
if (!p.isNull()) {
return qScriptValueFromValue(eng, QIcon(p));
}
}
}
return qScriptValueFromValue(eng, QIcon());
}
static QScriptValue addPixmap(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QIcon, addPixmap);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
if (arg.isVariant()) {
QVariant variant = arg.toVariant();
QPixmap p = variant.value<QPixmap>();
if (!p.isNull()) {
self->addPixmap(p);
}
}
}
return eng->undefinedValue();
}
static QScriptValue addFile(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QIcon, addFile);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
if (arg.isString()) {
self->addFile(arg.toString());
}
}
return eng->undefinedValue();
}
static QScriptValue isNull(QScriptContext *ctx, QScriptEngine *eng)
{
Q_UNUSED(eng)
DECLARE_SELF(QIcon, isNull);
return self->isNull();
}
QScriptValue constructIconClass(QScriptEngine *eng)
{
QScriptValue proto = qScriptValueFromValue(eng, QIcon());
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
proto.setProperty("addPixmap", eng->newFunction(addPixmap));
proto.setProperty("addFile", eng->newFunction(addFile));
proto.setProperty("null", eng->newFunction(isNull), getter);
QScriptValue ctorFun = eng->newFunction(ctor, proto);
ADD_ENUM_VALUE(ctorFun, QIcon, Normal);
ADD_ENUM_VALUE(ctorFun, QIcon, Disabled);
ADD_ENUM_VALUE(ctorFun, QIcon, Active);
ADD_ENUM_VALUE(ctorFun, QIcon, Selected);
ADD_ENUM_VALUE(ctorFun, QIcon, Off);
ADD_ENUM_VALUE(ctorFun, QIcon, On);
eng->setDefaultPrototype(qMetaTypeId<QIcon>(), proto);
return ctorFun;
}

View file

@ -1,244 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@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 version 2 as
* published by the Free Software Foundation
*
* 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 <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QGraphicsAnchorLayout>
#include <QGraphicsLayout>
#include <QGraphicsLinearLayout>
#include <QGraphicsGridLayout>
#include <QGraphicsWidget>
#include <Plasma/Applet>
#include "backportglobal.h"
#include "plasmoid/appletinterface.h"
Q_DECLARE_METATYPE(QScript::Pointer<QGraphicsItem>::wrapped_pointer_type)
Q_DECLARE_METATYPE(QGraphicsWidget*)
Q_DECLARE_METATYPE(QGraphicsLayout*)
Q_DECLARE_METATYPE(QGraphicsLayoutItem*)
Q_DECLARE_METATYPE(QGraphicsAnchorLayout*)
Q_DECLARE_METATYPE(QGraphicsGridLayout*)
DECLARE_POINTER_METATYPE(QGraphicsLinearLayout)
DECLARE_VOID_NUMBER_METHOD(QGraphicsLinearLayout, removeAt)
DECLARE_VOID_NUMBER_NUMBER_METHOD(QGraphicsLinearLayout, insertStretch)
DECLARE_VOID_NUMBER_NUMBER_METHOD(QGraphicsLinearLayout, setItemSpacing)
DECLARE_VOID_QUAD_NUMBER_METHOD(QGraphicsLinearLayout, setContentsMargins)
/////////////////////////////////////////////////////////////
// Q_DECLARE_METATYPE(QGraphicsLayoutItem*)
QGraphicsLayoutItem *extractLayoutItem(QScriptContext *ctx, int index = 0, bool noExistingLayout = false)
{
QScriptValue v = ctx->argument(index);
if (ctx->argumentCount() == 0 || v.isQObject()) {
QObject *object = v.toQObject();
QGraphicsWidget *w = qobject_cast<QGraphicsWidget *>(object);
if (!w) {
AppletInterface *interface = qobject_cast<AppletInterface*>(object);
if (!interface) {
interface = qobject_cast<AppletInterface*>(ctx->engine()->globalObject().property("plasmoid").toQObject());
}
if (interface) {
w = interface->applet();
}
}
if (noExistingLayout && w->layout()) {
return 0;
}
return w;
}
QVariant variant = v.toVariant();
QGraphicsLayoutItem *item = variant.value<QGraphicsLayoutItem *>();
//this is horribly ugly code, but when a QLinearLayout* is stuffed into a QVariant,
//QVariant does not know that it is a QGraphicsLayoutItem. repeat for all subclasses
//of same
if (!item) {
item = variant.value<QGraphicsLayout *>();
if (!item) {
item = variant.value<QGraphicsLinearLayout *>();
if (!item) {
item = variant.value<QGraphicsGridLayout *>();
if (!item) {
item = variant.value<QGraphicsAnchorLayout *>();
}
}
}
}
QGraphicsWidget *w = dynamic_cast<QGraphicsWidget *>(item);
if (noExistingLayout && w && w->layout()) {
return 0;
}
return item;
}
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
QGraphicsLayoutItem *parent = extractLayoutItem(ctx, 0, true);
//FIXME: don't leak memory when parent is 0
return qScriptValueFromValue(eng, new QGraphicsLinearLayout(parent));
}
BEGIN_DECLARE_METHOD(QGraphicsLinearLayout, orientation) {
if (ctx->argumentCount() > 0) {
self->setOrientation(static_cast<Qt::Orientation>(ctx->argument(0).toInt32()));
}
return QScriptValue(eng, static_cast<int>(self->orientation()));
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsLinearLayout, setAlignment) {
QGraphicsLayoutItem *item = extractLayoutItem(ctx);
if (!item) {
return eng->undefinedValue();
}
self->setAlignment(item, static_cast<Qt::Alignment>(ctx->argument(1).toInt32()));
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsLinearLayout, insertItem) {
QGraphicsLayoutItem *item = extractLayoutItem(ctx, 1);
if (!item) {
return eng->undefinedValue();
}
self->insertItem(ctx->argument(0).toInt32(), item);
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsLinearLayout, removeItem) {
QGraphicsLayoutItem *item = extractLayoutItem(ctx);
if (!item) {
return eng->undefinedValue();
}
self->removeItem(item);
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsLinearLayout, addStretch) {
self->addStretch(qMax(1, ctx->argument(0).toInt32()));
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsLinearLayout, setStretchFactor) {
QGraphicsLayoutItem *item = ctx->argument(0).toVariant().value<QGraphicsLayoutItem*>();
if (!item) {
return eng->undefinedValue();
}
self->setStretchFactor(item, static_cast<Qt::Orientation>(ctx->argument(1).toInt32()));
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsLinearLayout, addItem) {
QGraphicsLayoutItem *item = extractLayoutItem(ctx);
if (!item) {
return ctx->throwError(QScriptContext::TypeError,
"QGraphicsLinearLayout.prototype.addItem: argument is not a GraphicsLayoutItem");
}
self->addItem(item);
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, toString) {
return QScriptValue(eng, "QGraphicsLinearLayout");
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsLinearLayout, count) {
return QScriptValue(eng, self->count());
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsLinearLayout, itemAt) {
if (ctx->argumentCount() < 1) {
return eng->undefinedValue();
}
int index = ctx->argument(0).toInt32();
return qScriptValueFromValue(eng, self->itemAt(index));
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsLinearLayout, spacing) {
if (ctx->argumentCount() > 0) {
int pixels = ctx->argument(0).toInt32();
self->setSpacing(pixels);
}
return QScriptValue(eng, self->spacing());
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsLinearLayout, activate) {
self->activate();
return eng->undefinedValue();
} END_DECLARE_METHOD
/////////////////////////////////////////////////////////////
QScriptValue constructLinearLayoutClass(QScriptEngine *eng)
{
// QScriptValue proto = QScript::wrapGVPointer<QGraphicsLinearLayout>(eng, new QGraphicsLinearLayout(), );
qRegisterMetaType<QGraphicsLayoutItem*>();
QGraphicsLayoutItem * i = new QGraphicsLinearLayout;
QVariant v;
///v.setValue<QGraphicsLayoutItem*>(i);
v.setValue<void*>(i);
QScriptValue proto = QScript::wrapPointer<QGraphicsLinearLayout>(eng, new QGraphicsLinearLayout(), QScript::UserOwnership);
const QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
const QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
proto.setProperty("count", eng->newFunction(count), getter);
proto.setProperty("spacing", eng->newFunction(spacing), getter | setter);
proto.setProperty("orientation", eng->newFunction(orientation), getter | setter);
ADD_METHOD(proto, itemAt);
ADD_METHOD(proto, removeAt);
ADD_METHOD(proto, addStretch);
ADD_METHOD(proto, setStretchFactor);
ADD_METHOD(proto, setAlignment);
ADD_METHOD(proto, insertStretch);
ADD_METHOD(proto, setItemSpacing);
ADD_METHOD(proto, setContentsMargins);
ADD_METHOD(proto, addItem);
ADD_METHOD(proto, removeItem);
ADD_METHOD(proto, insertItem);
ADD_METHOD(proto, toString);
ADD_METHOD(proto, activate);
QScript::registerPointerMetaType<QGraphicsLinearLayout>(eng, proto);
QScriptValue ctorFun = eng->newFunction(ctor, proto);
//ADD_ENUM_VALUE(ctorFun, QGraphicsItem, ItemIsMovable);
return ctorFun;
}

File diff suppressed because it is too large Load diff

View file

@ -1,170 +0,0 @@
/*
* Copyright (c) 2009 Aaron J. 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 version 2 as
* published by the Free Software Foundation
*
* 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 <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QPen>
#include "backportglobal.h"
Q_DECLARE_METATYPE(QPen*)
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
Q_UNUSED(ctx)
return qScriptValueFromValue(eng, QPen());
}
static QScriptValue brush(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPen, brush);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setBrush(qscriptvalue_cast<QBrush>(arg));
}
return qScriptValueFromValue(eng, self->brush());
}
static QScriptValue color(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPen, color);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setColor(qscriptvalue_cast<QColor>(arg));
}
return qScriptValueFromValue(eng, self->color());
}
static QScriptValue style(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPen, style);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setStyle(Qt::PenStyle(arg.toInt32()));
}
return QScriptValue(eng, self->style());
}
static QScriptValue capStyle(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPen, capStyle);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setCapStyle(Qt::PenCapStyle(arg.toInt32()));
}
return QScriptValue(eng, self->capStyle());
}
static QScriptValue joinStyle(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPen, joinStyle);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setJoinStyle(Qt::PenJoinStyle(arg.toInt32()));
}
return QScriptValue(eng, self->joinStyle());
}
static QScriptValue dashOffset(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPen, dashOffset);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setDashOffset(arg.toInt32());
}
return QScriptValue(eng, self->dashOffset());
}
static QScriptValue miterLimit(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPen, miterLimit);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setMiterLimit(arg.toInt32());
}
return QScriptValue(eng, self->miterLimit());
}
static QScriptValue width(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPen, width);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setWidth(arg.toInt32());
}
return QScriptValue(eng, self->width());
}
static QScriptValue solid(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPen, solid);
return QScriptValue(eng, self->isSolid());
}
QScriptValue constructPenClass(QScriptEngine *eng)
{
QScriptValue proto = qScriptValueFromValue(eng, QColor());
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
proto.setProperty("brush", eng->newFunction(brush), getter | setter);
proto.setProperty("color", eng->newFunction(color), getter | setter);
proto.setProperty("capStyle", eng->newFunction(capStyle), getter | setter);
proto.setProperty("joinStyle", eng->newFunction(joinStyle), getter | setter);
proto.setProperty("style", eng->newFunction(style), getter | setter);
proto.setProperty("dashOffset", eng->newFunction(dashOffset), getter | setter);
proto.setProperty("miterLimit", eng->newFunction(miterLimit), getter | setter);
proto.setProperty("width", eng->newFunction(width), getter | setter);
proto.setProperty("solid", eng->newFunction(solid), getter);
QScriptValue ctorFun = eng->newFunction(ctor, proto);
ADD_ENUM_VALUE(ctorFun, Qt, FlatCap);
ADD_ENUM_VALUE(ctorFun, Qt, SquareCap);
ADD_ENUM_VALUE(ctorFun, Qt, RoundCap);
ADD_ENUM_VALUE(ctorFun, Qt, RoundCap);
ADD_ENUM_VALUE(ctorFun, Qt, BevelJoin);
ADD_ENUM_VALUE(ctorFun, Qt, MiterJoin);
ADD_ENUM_VALUE(ctorFun, Qt, RoundJoin);
ADD_ENUM_VALUE(ctorFun, Qt, SolidLine);
ADD_ENUM_VALUE(ctorFun, Qt, DashLine);
ADD_ENUM_VALUE(ctorFun, Qt, DotLine);
ADD_ENUM_VALUE(ctorFun, Qt, DashDotLine);
ADD_ENUM_VALUE(ctorFun, Qt, DashDotDotLine);
ADD_ENUM_VALUE(ctorFun, Qt, CustomDashLine);
eng->setDefaultPrototype(qMetaTypeId<QPen>(), proto);
eng->setDefaultPrototype(qMetaTypeId<QPen*>(), proto);
return ctorFun;
}

View file

@ -1,76 +0,0 @@
/*
* Copyright 2009 Aaron J. 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 version 2 as
* published by the Free Software Foundation
*
* 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 <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QPixmap>
#include "backportglobal.h"
#include "plasmoid/appletinterface.h"
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
if (ctx->argumentCount() == 1 && ctx->argument(0).isString()) {
// a path on disk in the package
AppletInterface *interface = AppletInterface::extract(eng);
const QString path = interface ? interface->file("images", ctx->argument(0).toString()) : QString();
return qScriptValueFromValue(eng, QPixmap(path));
}
if (ctx->argumentCount() == 2) {
qreal x = ctx->argument(0).toNumber();
qreal y = ctx->argument(1).toNumber();
return qScriptValueFromValue(eng, QPixmap(x, y));
}
return qScriptValueFromValue(eng, QPixmap());
}
static QScriptValue rect(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPixmap, rect)
return qScriptValueFromValue(eng, QRectF(self->rect()));
}
static QScriptValue null(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPixmap, null);
return QScriptValue(eng, self->isNull());
}
static QScriptValue scaled(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPixmap, scaled);
qreal x = ctx->argument(0).toNumber();
qreal y = ctx->argument(1).toNumber();
return qScriptValueFromValue(eng, self->scaled(x, y));
}
QScriptValue constructQPixmapClass(QScriptEngine *eng)
{
QScriptValue proto = qScriptValueFromValue(eng, QPixmap());
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
proto.setProperty("null", eng->newFunction(null), getter);
proto.setProperty("rect", eng->newFunction(rect), getter);
proto.setProperty("scaled", eng->newFunction(scaled));
eng->setDefaultPrototype(qMetaTypeId<QPixmap>(), proto);
eng->setDefaultPrototype(qMetaTypeId<QPixmap*>(), proto);
return eng->newFunction(ctor, proto);
}

View file

@ -1,108 +0,0 @@
/*
* Copyright 2007-2008 Richard J. Moore <rich@kde.org>
* Copyright 2009 Aaron J. 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 version 2 as
* published by the Free Software Foundation
*
* 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 <QScriptEngine>
#include <KConfigGroup>
#include <KIO/Job>
#include <KSharedConfig>
#include "dataengine.h"
Q_DECLARE_METATYPE(KConfigGroup)
Q_DECLARE_METATYPE(KJob *)
typedef KJob* KJobPtr;
QScriptValue qScriptValueFromKJob(QScriptEngine *engine, const KJobPtr &job)
{
return engine->newQObject(const_cast<KJob *>(job), QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject);
}
void qKJobFromQScriptValue(const QScriptValue &scriptValue, KJobPtr &job)
{
QObject *obj = scriptValue.toQObject();
job = static_cast<KJob *>(obj);
}
Q_DECLARE_METATYPE(KIO::Job *)
typedef KIO::Job* KioJobPtr;
QScriptValue qScriptValueFromKIOJob(QScriptEngine *engine, const KioJobPtr &job)
{
return engine->newQObject(const_cast<KIO::Job *>(job), QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject);
}
void qKIOJobFromQScriptValue(const QScriptValue &scriptValue, KioJobPtr &job)
{
QObject *obj = scriptValue.toQObject();
job = static_cast<KIO::Job *>(obj);
}
QScriptValue qScriptValueFromKConfigGroup(QScriptEngine *engine, const KConfigGroup &config)
{
QScriptValue obj = engine->newObject();
if (!config.isValid()) {
return obj;
}
QMap<QString, QString> entryMap = config.entryMap();
QMap<QString, QString>::const_iterator it = entryMap.constBegin();
QMap<QString, QString>::const_iterator begin = it;
QMap<QString, QString>::const_iterator end = entryMap.constEnd();
//setting the group name
obj.setProperty("__file", QScriptValue(engine, config.config()->name()));
obj.setProperty("__name", QScriptValue(engine, config.name()));
//setting the key/value pairs
for (it = begin; it != end; ++it) {
//kDebug() << "setting" << it.key() << "to" << it.value();
QString prop = it.key();
prop.replace(' ', '_');
obj.setProperty(prop, it.value());
}
return obj;
}
void kConfigGroupFromScriptValue(const QScriptValue& obj, KConfigGroup &config)
{
config = KConfigGroup(KSharedConfig::openConfig(obj.property("__file").toString()), obj.property("__name").toString());
QScriptValueIterator it(obj);
while (it.hasNext()) {
it.next();
//kDebug() << it.name() << "is" << it.value().toString();
if (it.name() != "__name") {
config.writeEntry(it.name(), it.value().toString());
}
}
}
using namespace Plasma;
void registerNonGuiMetaTypes(QScriptEngine *engine)
{
qScriptRegisterMetaType<KConfigGroup>(engine, qScriptValueFromKConfigGroup, kConfigGroupFromScriptValue);
qScriptRegisterMetaType<KJob *>(engine, qScriptValueFromKJob, qKJobFromQScriptValue);
qScriptRegisterMetaType<KIO::Job *>(engine, qScriptValueFromKIOJob, qKIOJobFromQScriptValue);
registerDataEngineMetaTypes(engine);
}

View file

@ -1,330 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@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 version 2 as
* published by the Free Software Foundation
*
* 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 <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QtCore/qrect.h>
#include "backportglobal.h"
Q_DECLARE_METATYPE(QRectF*)
Q_DECLARE_METATYPE(QRectF)
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
if (ctx->argumentCount() == 4)
{
qreal x = ctx->argument(0).toNumber();
qreal y = ctx->argument(1).toNumber();
qreal width = ctx->argument(2).toNumber();
qreal height = ctx->argument(3).toNumber();
return qScriptValueFromValue(eng, QRectF(x, y, width, height));
}
return qScriptValueFromValue(eng, QRectF());
}
static QScriptValue adjust(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, adjust);
qreal dx1 = ctx->argument(0).toNumber();
qreal dy1 = ctx->argument(1).toNumber();
qreal dx2 = ctx->argument(2).toNumber();
qreal dy2 = ctx->argument(3).toNumber();
self->adjust(dx1, dy1, dx2, dy2);
return QScriptValue();
}
static QScriptValue adjusted(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, adjusted);
qreal dx1 = ctx->argument(0).toNumber();
qreal dy1 = ctx->argument(1).toNumber();
qreal dx2 = ctx->argument(2).toNumber();
qreal dy2 = ctx->argument(3).toNumber();
QRectF tmp = self->adjusted(dx1, dy1, dx2, dy2);
return qScriptValueFromValue(eng, tmp);
}
static QScriptValue bottom(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, bottom);
if (ctx->argumentCount() > 0) {
int bottom = ctx->argument(0).toInt32();
self->setBottom(bottom);
}
return QScriptValue(eng, self->bottom());
}
static QScriptValue top(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, top);
if (ctx->argumentCount() > 0) {
int top = ctx->argument(0).toInt32();
self->setTop(top);
}
return QScriptValue(eng, self->top());
}
static QScriptValue contains(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, contains);
qreal x = ctx->argument(0).toNumber();
qreal y = ctx->argument(1).toNumber();
return QScriptValue(eng, self->contains(x, y));
}
static QScriptValue height(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, height);
if (ctx->argumentCount() > 0) {
int height = ctx->argument(0).toInt32();
self->setHeight(height);
}
return QScriptValue(eng, self->height());
}
static QScriptValue empty(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, empty);
return QScriptValue(eng, self->isEmpty());
}
static QScriptValue null(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, null);
return QScriptValue(eng, self->isNull());
}
static QScriptValue valid(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, valid);
return QScriptValue(eng, self->isValid());
}
static QScriptValue left(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, left);
if (ctx->argumentCount() > 0) {
int left = ctx->argument(0).toInt32();
self->setLeft(left);
}
return QScriptValue(eng, self->left());
}
static QScriptValue moveBottom(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, moveBottom);
qreal bottom = ctx->argument(0).toNumber();
self->moveBottom(bottom);
return QScriptValue();
}
static QScriptValue moveLeft(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, moveLeft);
qreal left = ctx->argument(0).toNumber();
self->moveLeft(left);
return QScriptValue();
}
static QScriptValue moveRight(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, moveRight);
qreal right = ctx->argument(0).toNumber();
self->moveRight(right);
return QScriptValue();
}
static QScriptValue moveTo(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, moveTo);
qreal x = ctx->argument(0).toNumber();
qreal y = ctx->argument(1).toNumber();
self->moveTo(x, y);
return QScriptValue();
}
static QScriptValue moveTop(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, moveTop);
qreal top = ctx->argument(0).toNumber();
self->moveTop(top);
return QScriptValue();
}
static QScriptValue right(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, right);
if (ctx->argumentCount() > 0) {
int right = ctx->argument(0).toInt32();
self->setRight(right);
}
return QScriptValue(eng, self->right());
}
static QScriptValue setCoords(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, setCoords);
qreal x1 = ctx->argument(0).toNumber();
qreal y1 = ctx->argument(1).toNumber();
qreal x2 = ctx->argument(2).toNumber();
qreal y2 = ctx->argument(3).toNumber();
self->setCoords(x1, y1, x2, y2);
return QScriptValue();
}
static QScriptValue setRect(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, setRect);
qreal x = ctx->argument(0).toNumber();
qreal y = ctx->argument(1).toNumber();
qreal width = ctx->argument(2).toNumber();
qreal height = ctx->argument(3).toNumber();
self->setRect(x, y, width, height);
return QScriptValue();
}
static QScriptValue translate(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, translate);
qreal dx = ctx->argument(0).toNumber();
qreal dy = ctx->argument(1).toNumber();
self->translate(dx, dy);
return QScriptValue();
}
static QScriptValue width(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, width);
if (ctx->argumentCount() > 0) {
int width = ctx->argument(0).toInt32();
self->setWidth(width);
}
return QScriptValue(eng, self->width());
}
static QScriptValue x(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, x);
if (ctx->argumentCount() > 0) {
int x = ctx->argument(0).toInt32();
self->setX(x);
}
return QScriptValue(eng, self->x());
}
static QScriptValue y(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, y);
if (ctx->argumentCount() > 0) {
int y = ctx->argument(0).toInt32();
self->setY(y);
}
return QScriptValue(eng, self->y());
}
/* Not Implemented Yet */
// QPointF bottomLeft () const
// QPointF bottomRight () const
// QPointF center () const
// bool contains ( const QPointF & point ) const
// bool contains ( const QRectF & rectangle ) const
// void getCoords ( qreal * x1, qreal * y1, qreal * x2, qreal * y2 ) const
// void getRect ( qreal * x, qreal * y, qreal * width, qreal * height ) const
// QRectF intersected ( const QRectF & rectangle ) const
// bool intersects ( const QRectF & rectangle ) const
// void moveBottomLeft ( const QPointF & position )
// void moveBottomRight ( const QPointF & position )
// void moveCenter ( const QPointF & position )
// void moveTo ( const QPointF & position )
// void moveTopLeft ( const QPointF & position )
// void moveTopRight ( const QPointF & position )
// QRectF normalized () const
// void setBottomLeft ( const QPointF & position )
// void setBottomRight ( const QPointF & position )
// void setSize ( const QSizeF & size )
// void setTopLeft ( const QPointF & position )
// void setTopRight ( const QPointF & position )
// QSizeF size () const
// QRect toAlignedRect () const
// QRect toRect () const
// QPointF topLeft () const
// QPointF topRight () const
// void translate ( const QPointF & offset )
// QRectF translated ( qreal dx, qreal dy ) const
// QRectF translated ( const QPointF & offset ) const
// QRectF united ( const QRectF & rectangle ) const
QScriptValue constructQRectFClass(QScriptEngine *eng)
{
QScriptValue proto = qScriptValueFromValue(eng, QRectF());
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
proto.setProperty("adjust", eng->newFunction(adjust));
proto.setProperty("adjusted", eng->newFunction(adjusted));
proto.setProperty("translate", eng->newFunction(translate));
proto.setProperty("setCoords", eng->newFunction(setCoords));
proto.setProperty("setRect", eng->newFunction(setRect));
proto.setProperty("contains", eng->newFunction(contains));
proto.setProperty("moveBottom", eng->newFunction(moveBottom));
proto.setProperty("moveLeft", eng->newFunction(moveLeft));
proto.setProperty("moveRight", eng->newFunction(moveRight));
proto.setProperty("moveTo", eng->newFunction(moveTo));
proto.setProperty("moveTop", eng->newFunction(moveTop));
proto.setProperty("empty", eng->newFunction(empty), getter);
proto.setProperty("null", eng->newFunction(null), getter);
proto.setProperty("valid", eng->newFunction(valid), getter);
proto.setProperty("left", eng->newFunction(left), getter | setter);
proto.setProperty("top", eng->newFunction(top), getter | setter);
proto.setProperty("bottom", eng->newFunction(bottom), getter | setter);
proto.setProperty("right", eng->newFunction(right), getter | setter);
proto.setProperty("height", eng->newFunction(height), getter | setter);
proto.setProperty("width", eng->newFunction(width), getter | setter);
proto.setProperty("x", eng->newFunction(x), getter | setter);
proto.setProperty("y", eng->newFunction(y), getter | setter);
eng->setDefaultPrototype(qMetaTypeId<QRectF>(), proto);
eng->setDefaultPrototype(qMetaTypeId<QRectF*>(), proto);
return eng->newFunction(ctor, proto);
}

View file

@ -1,74 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@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 version 2 as
* published by the Free Software Foundation
*
* 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 <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QtCore/qsize.h>
#include "backportglobal.h"
Q_DECLARE_METATYPE(QSizeF*)
Q_DECLARE_METATYPE(QSizeF)
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
if (ctx->argumentCount() == 2) {
qreal width = ctx->argument(1).toNumber();
qreal height = ctx->argument(1).toNumber();
return qScriptValueFromValue(eng, QSizeF(width, height));
}
return qScriptValueFromValue(eng, QSizeF());
}
static QScriptValue width(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QSizeF, width);
if (ctx->argumentCount() > 0) {
qreal width = ctx->argument(0).toNumber();
self->setWidth(width);
}
return QScriptValue(eng, self->width());
}
static QScriptValue height(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QSizeF, height);
if (ctx->argumentCount() > 0) {
qreal height = ctx->argument(0).toNumber();
self->setHeight(height);
}
return QScriptValue(eng, self->height());
}
QScriptValue constructQSizeFClass(QScriptEngine *eng)
{
QScriptValue proto = qScriptValueFromValue(eng, QSizeF());
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
proto.setProperty("width", eng->newFunction(width), getter | setter);
proto.setProperty("height", eng->newFunction(height), getter | setter);
eng->setDefaultPrototype(qMetaTypeId<QSizeF>(), proto);
eng->setDefaultPrototype(qMetaTypeId<QSizeF*>(), proto);
return eng->newFunction(ctor, proto);
}

View file

@ -1,102 +0,0 @@
/*
* Copyright (c) 2010 Aaron J. 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 version 2 as
* published by the Free Software Foundation
*
* 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 <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QSizePolicy>
#include "backportglobal.h"
Q_DECLARE_METATYPE(QSizePolicy*)
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
QSizePolicy::Policy h(QSizePolicy::Fixed);
QSizePolicy::Policy v(QSizePolicy::Fixed);
if (ctx->argumentCount() > 1) {
h = static_cast<QSizePolicy::Policy>(ctx->argument(0).toInt32());
v = static_cast<QSizePolicy::Policy>(ctx->argument(1).toInt32());
}
QScriptValue value = qScriptValueFromValue(eng, QSizePolicy(h, v));
return value;
}
static QScriptValue horizontalPolicy(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QSizePolicy, horizontalPolicy);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setHorizontalPolicy(static_cast<QSizePolicy::Policy>(arg.toInt32()));
}
return QScriptValue(eng, self->horizontalPolicy());
}
static QScriptValue verticalPolicy(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QSizePolicy, vertialPolicy);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setVerticalPolicy(static_cast<QSizePolicy::Policy>(arg.toInt32()));
}
return QScriptValue(eng, self->verticalPolicy());
}
static QScriptValue horizontalStretch(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QSizePolicy, horizontalStretch);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setHorizontalStretch(arg.toInt32());
}
return QScriptValue(eng, self->horizontalStretch());
}
static QScriptValue verticalStretch(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QSizePolicy, verticalStretch);
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
self->setVerticalStretch(arg.toInt32());
}
return QScriptValue(eng, self->verticalStretch());
}
QScriptValue constructQSizePolicyClass(QScriptEngine *eng)
{
QScriptValue proto = qScriptValueFromValue(eng, QSizePolicy());
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
proto.setProperty("horizontalPolicy", eng->newFunction(horizontalPolicy), getter | setter);
proto.setProperty("verticalPolicy", eng->newFunction(verticalPolicy), getter | setter);
proto.setProperty("horizontalStretch", eng->newFunction(horizontalStretch), getter | setter);
proto.setProperty("verticalStretch", eng->newFunction(verticalStretch), getter | setter);
eng->setDefaultPrototype(qMetaTypeId<QSizePolicy>(), proto);
eng->setDefaultPrototype(qMetaTypeId<QSizePolicy*>(), proto);
return eng->newFunction(ctor, proto);
}

View file

@ -1,70 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@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 version 2 as
* published by the Free Software Foundation
*
* 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 <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QtScript/QScriptable>
#include <QtCore/QTimer>
#include "backportglobal.h"
Q_DECLARE_METATYPE(QTimer*)
static QScriptValue newTimer(QScriptEngine *eng, QTimer *timer)
{
return eng->newQObject(timer, QScriptEngine::AutoOwnership);
}
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
return newTimer(eng, new QTimer(qscriptvalue_cast<QObject*>(ctx->argument(0))));
}
static QScriptValue toString(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QTimer, toString);
return QScriptValue(eng, QString::fromLatin1("QTimer(interval=%0)")
.arg(self->interval()));
}
static QScriptValue active(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QTimer, active);
if (ctx->argumentCount()) {
if (ctx->argument(0).toBool()) {
self->start();
} else {
self->stop();
}
}
return QScriptValue(eng, self->isActive());
}
QScriptValue constructTimerClass(QScriptEngine *eng)
{
QScriptValue proto = newTimer(eng, new QTimer());
ADD_METHOD(proto, toString);
eng->setDefaultPrototype(qMetaTypeId<QTimer*>(), proto);
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
proto.setProperty("active", eng->newFunction(active), getter | setter);
return eng->newFunction(ctor, proto);
}

View file

@ -1,136 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@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 "uiloader.h"
#include <QGraphicsGridLayout>
#include <QGraphicsLinearLayout>
#include <QStringList>
#include <KDebug>
#include <Plasma/BusyWidget>
#include <Plasma/CheckBox>
#include <Plasma/ComboBox>
#include <Plasma/FlashingLabel>
#include <Plasma/Frame>
#include <Plasma/GroupBox>
#include <Plasma/IconWidget>
#include <Plasma/ItemBackground>
#include <Plasma/Label>
#include <Plasma/LineEdit>
#include <Plasma/Meter>
#include <Plasma/PushButton>
#include <Plasma/RadioButton>
#include <Plasma/ScrollBar>
#include <Plasma/ScrollWidget>
#include <Plasma/Separator>
#include <Plasma/SignalPlotter>
#include <Plasma/Slider>
#include <Plasma/SpinBox>
#include <Plasma/SvgWidget>
#include <Plasma/TabBar>
#include <Plasma/TextEdit>
#include <Plasma/ToolButton>
#include <Plasma/TreeView>
#include <Plasma/WebView>
QGraphicsWidget *createBusyWidget(QGraphicsWidget *parent) { return new Plasma::BusyWidget(parent); }
QGraphicsWidget *createCheckBox(QGraphicsWidget *parent) { return new Plasma::CheckBox(parent); }
QGraphicsWidget *createComboBox(QGraphicsWidget *parent) { return new Plasma::ComboBox(parent); }
QGraphicsWidget *createFlashingLabel(QGraphicsWidget *parent) { return new Plasma::FlashingLabel(parent); }
QGraphicsWidget *createFrame(QGraphicsWidget *parent) { return new Plasma::Frame(parent); }
QGraphicsWidget *createGroupBox(QGraphicsWidget *parent) { return new Plasma::GroupBox(parent); }
QGraphicsWidget *createIconWidget(QGraphicsWidget *parent) { return new Plasma::IconWidget(parent); }
QGraphicsWidget *createItemBackground(QGraphicsWidget *parent) { return new Plasma::ItemBackground(parent); }
QGraphicsWidget *createLabel(QGraphicsWidget *parent) { return new Plasma::Label(parent); }
QGraphicsWidget *createLineEdit(QGraphicsWidget *parent) { return new Plasma::LineEdit(parent); }
QGraphicsWidget *createMeter(QGraphicsWidget *parent) { return new Plasma::Meter(parent); }
QGraphicsWidget *createPushButton(QGraphicsWidget *parent) { return new Plasma::PushButton(parent); }
QGraphicsWidget *createRadioButton(QGraphicsWidget *parent) { return new Plasma::RadioButton(parent); }
QGraphicsWidget *createScrollBar(QGraphicsWidget *parent) { return new Plasma::ScrollBar(parent); }
QGraphicsWidget *createScrollWidget(QGraphicsWidget *parent) { return new Plasma::ScrollWidget(parent); }
QGraphicsWidget *createSeparator(QGraphicsWidget *parent) { return new Plasma::Separator(parent); }
QGraphicsWidget *createSignalPlotter(QGraphicsWidget *parent) { return new Plasma::SignalPlotter(parent); }
QGraphicsWidget *createSlider(QGraphicsWidget *parent) { return new Plasma::Slider(parent); }
QGraphicsWidget *createSpinBox(QGraphicsWidget *parent) { return new Plasma::SpinBox(parent); }
QGraphicsWidget *createSvgWidget(QGraphicsWidget *parent) { return new Plasma::SvgWidget(parent); }
QGraphicsWidget *createTabBar(QGraphicsWidget *parent) { return new Plasma::TabBar(parent); }
QGraphicsWidget *createTextEdit(QGraphicsWidget *parent) { return new Plasma::TextEdit(parent); }
QGraphicsWidget *createToolButton(QGraphicsWidget *parent) { return new Plasma::ToolButton(parent); }
QGraphicsWidget *createTreeView(QGraphicsWidget *parent) { return new Plasma::TreeView(parent); }
#ifdef HAVE_QTWEBKIT
QGraphicsWidget *createWebView(QGraphicsWidget *parent) { return new Plasma::WebView(parent); }
#endif
QGraphicsWidget *createGraphicsWidget(QGraphicsWidget *parent) { return new QGraphicsWidget(parent); }
UiLoader::UiLoader()
{
m_widgetCtors.insert("BusyWidget", createBusyWidget);
m_widgetCtors.insert("CheckBox", createCheckBox);
m_widgetCtors.insert("ComboBox", createComboBox);
m_widgetCtors.insert("FlashingLabel", createFlashingLabel);
m_widgetCtors.insert("Frame", createFrame);
m_widgetCtors.insert("GroupBox", createGroupBox);
m_widgetCtors.insert("IconWidget", createIconWidget);
m_widgetCtors.insert("ItemBackground", createItemBackground);
m_widgetCtors.insert("Label", createLabel);
m_widgetCtors.insert("LineEdit", createLineEdit);
m_widgetCtors.insert("Meter", createMeter);
m_widgetCtors.insert("PushButton", createPushButton);
m_widgetCtors.insert("RadioButton", createRadioButton);
m_widgetCtors.insert("ScrollBar", createScrollBar);
m_widgetCtors.insert("ScrollWidget", createScrollWidget);
m_widgetCtors.insert("Separator", createSeparator);
m_widgetCtors.insert("SignalPlotter", createSignalPlotter);
m_widgetCtors.insert("Slider", createSlider);
m_widgetCtors.insert("SpinBox", createSpinBox);
m_widgetCtors.insert("SvgWidget", createSvgWidget);
m_widgetCtors.insert("TabBar", createTabBar);
m_widgetCtors.insert("TextEdit", createTextEdit);
m_widgetCtors.insert("ToolButton", createToolButton);
m_widgetCtors.insert("TreeView", createTreeView);
#ifdef HAVE_QTWEBKIT
m_widgetCtors.insert("WebView", createWebView);
#endif
m_widgetCtors.insert("GraphicsWidget", createGraphicsWidget);
}
UiLoader::~UiLoader()
{
kDebug();
}
QStringList UiLoader::availableWidgets() const
{
return m_widgetCtors.keys();
}
QGraphicsWidget *UiLoader::createWidget(const QString &className, QGraphicsWidget *parent)
{
widgetCreator w = m_widgetCtors.value(className, 0);
if (w) {
return (w)(parent);
}
return 0;
}

View file

@ -1,44 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@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.
*/
#ifndef PLASMA_UILOADER_H
#define PLASMA_UILOADER_H
#include <KSharedPtr>
#include <plasma/applet.h>
class QGraphicsWidget;
class UiLoader : public QSharedData
{
public:
UiLoader();
virtual ~UiLoader();
QStringList availableWidgets() const;
QGraphicsWidget *createWidget(const QString &className, QGraphicsWidget *parent = 0);
private:
typedef QGraphicsWidget *(*widgetCreator)(QGraphicsWidget*);
QHash<QString, widgetCreator> m_widgetCtors;
};
#endif // PLASMA_UILOADER_H

View file

@ -1,39 +0,0 @@
project(plasma-python)
# install the library, .desktop, and plasma.py
install(
FILES
pyappletscript.py
plasma_importer.py
pydataengine.py
pyrunner.py
pywallpaper.py
DESTINATION
${DATA_INSTALL_DIR}/plasma_scriptengine_python
)
install(
FILES plasmascript.py
DESTINATION ${PYTHON_SITE_PACKAGES_DIR}/PyKDE4
)
install(
FILES
plasma-scriptengine-applet-python.desktop
plasma-scriptengine-dataengine-python.desktop
plasma-scriptengine-runner-python.desktop
plasma-scriptengine-wallpaper-python.desktop
DESTINATION ${SERVICES_INSTALL_DIR}
)
###########################################################################
# Test plasmoids
option(INSTALL_PYTHON_TEST_PLASMA "Install test python applet" OFF)
if(INSTALL_PYTHON_TEST_PLASMA )
install(DIRECTORY test/plasma-applet-pyclock DESTINATION ${DATA_INSTALL_DIR}/plasma/plasmoids)
#TODO where install it ?
#install(DIRECTORY test/plasma-dataengine-pytime DESTINATION ${DATA_INSTALL_DIR}/plasma/engines)
endif(INSTALL_PYTHON_TEST_PLASMA)

View file

@ -1,149 +0,0 @@
[Desktop Entry]
Name=Python Widget
Name[ar]=ودجة بايثون
Name[ast]=Widget de Python
Name[be@latin]=Widžet Python
Name[bg]=Джаджа на Python
Name[bn]=
Name[bn_IN]=Python
Name[bs]=Python grafičkih kontrola
Name[ca]=Estri en Python
Name[ca@valencia]=Estri en Python
Name[cs]=Python widget
Name[csb]=Interfejs Phythona
Name[da]=Python-widget
Name[de]=Python-Miniprogramm
Name[el]=Συστατικό Python
Name[en_GB]=Python Widget
Name[eo]=Pitona fenestraĵo
Name[es]=Widget de Python
Name[et]=Pythoni vidin
Name[eu]=Python trepeta
Name[fi]=Python-sovelma
Name[fr]=Composant graphique Python
Name[fy]=Python Widget
Name[ga]=Giuirléid Python
Name[gl]=Widget de Python
Name[gu]= િ
Name[he]=ווידג׳ט של Python
Name[hi]= ि
Name[hne]= ि
Name[hr]=Python widget
Name[hu]=Python-elem
Name[ia]=Elemento graphic (Widget) de Python
Name[id]=Widget Python
Name[is]=Python græja
Name[ja]=Python
Name[kk]=Python бөлшегі
Name[km]= Python
Name[kn]= ಿ (ಿ)
Name[ko]=
Name[ku]=Alava Python
Name[lt]=Python valdiklis
Name[lv]=Python sīkrīks
Name[ml]= ി
Name[mr]=Python Widget
Name[nb]=Pythonelement
Name[nds]=Python-Lüttprogramm
Name[nl]=Python-widget
Name[nn]=Python-element
Name[or]= ି
Name[pa]= ਿ
Name[pl]=Element interfejsu w Pythonie
Name[pt]=Elemento em Python
Name[pt_BR]=Widget em Python
Name[ro]=Control Python
Name[ru]=Виджет на языке Python
Name[si]=QEdje
Name[sk]=Python widget
Name[sl]=Gradnik v Pythonu
Name[sr]=питонски виџет
Name[sr@ijekavian]=питонски виџет
Name[sr@ijekavianlatin]=Python vidžet
Name[sr@latin]=Python vidžet
Name[sv]=Grafisk Python-komponent
Name[ta]=Python Widget
Name[tg]=Илова ба Python
Name[th]=
Name[tr]=Python Programcığı
Name[ug]=Python Widget
Name[uk]=Віджет Python
Name[wa]=Ahesse Python
Name[x-test]=xxPython Widgetxx
Name[zh_CN]=Python
Name[zh_TW]=Python
Comment=Plasma widget support written in Python
Comment[ar]=دعم ودجات البلازما المكتوبة بالبايثون
Comment[ast]=Elementu gráficu nativu de Plasma escritu en Python
Comment[be@latin]=Widžet systemy Plasma, napisany ŭ movie Python
Comment[bg]=Оригинална джаджа за Plasma, написана на Python
Comment[bs]=Podrška plazma grafičkim kontrolama pisanih u Pythonu
Comment[ca]=Estri nadiu del Plasma escrit en Python
Comment[ca@valencia]=Estri nadiu del Plasma escrit en Python
Comment[cs]=Podpora pro plasmoidy napsaná v Pythonu
Comment[da]=Understøttelse af plasma-widgets skrevet i Python
Comment[de]=Plasma-Miniprogramm-Unterstützung, geschrieben in Python
Comment[el]=Υποστήριξη συστατικού Plasma γραμμένο σε Python
Comment[en_GB]=Plasma widget support written in Python
Comment[es]=Elemento gráfico nativo de Plasma escrito en Python
Comment[et]=Pythonis kirjutatud Plasma vidina toetus
Comment[eu]=Python-en idatzitako Plasmaren trepeta-euskarria
Comment[fi]=Tuki Pythonilla kirjoitetuille Plasma-sovelmille
Comment[fr]=Prise en charge des composants graphiques de Plasma écrits en Python
Comment[fy]=Plasma widget stipe skreaun yn Python
Comment[ga]=Tacaíocht giuirléidí Plasma scríofa i Python
Comment[gl]=Widget nativo de Plasma escrito en Python
Comment[gu]= િ
Comment[he]=תמיכה בווידג׳טים של Plasma עבור Python
Comment[hi]= ि ि
Comment[hne]= ि ि
Comment[hr]=Podrška za Plasma widgete napisana u Pythonu
Comment[hu]=Plazmoid-támogatás Python nyelven
Comment[ia]=Supporto de elemento graphic (Widget) de Plasma scribite in Python
Comment[id]=Dukungan widget Plasma didukung oleh Python
Comment[is]=Stuðningur við plasmadót skrifaður í Python
Comment[ja]=Python Plasma
Comment[kk]=Python-да жазылған Plasma интерфейс бөлшегі
Comment[km]= Python
Comment[kn]=ಿಿ ಿ (ಿ)
Comment[ko]= Plasma
Comment[lt]=Plasma valdiklių palaikymas, parašytas su Python
Comment[lv]=Plasma sīkrīks, kas rakstīts Python
Comment[ml]=ി ിിി ി ി ി
Comment[mr]=Python ि ि Plasma ि
Comment[nb]=Plasma skjermelement skrevet i Python
Comment[nds]=Plasma-Lüttprogrammünnerstütten, schreven in Python
Comment[nl]=Plasma-widget-ondersteuning geschreven in Python
Comment[nn]=Plasmoidestøtte skriven i Python
Comment[or]= ିି ି
Comment[pa]= ਿ ਿ ਿ ਿ
Comment[pl]=Obsługa elementu interfejsu Plazmy w Pythonie
Comment[pt]=Elemento nativo do Plasma feito em Python
Comment[pt_BR]=Widget nativo do Plasma escrito em Python
Comment[ro]=Suport controale Plasma scris în Python
Comment[ru]=Виджет Plasma, написанный на языке Python
Comment[si]=Plasma widget support written in Python
Comment[sk]=Podpora widgetov plasmy napísaných v Pythone
Comment[sl]=Podpora za gradnike napisane v Pythonu
Comment[sr]=Подршка плазма виџета писаних у питону
Comment[sr@ijekavian]=Подршка плазма виџета писаних у питону
Comment[sr@ijekavianlatin]=Podrška plasma vidžeta pisanih u Pythonu
Comment[sr@latin]=Podrška plasma vidžeta pisanih u Pythonu
Comment[sv]=Stöd för grafisk Plasma-komponent skriven i Python
Comment[ta]=Plasma widget support written in Python
Comment[tg]=Модуль Plasma, написанный на языке JavaScript
Comment[th]=
Comment[tr]=Python ile yazılmış Plasma gereci desteği
Comment[ug]=Python بىلەن يېزىلغان Plasma widget نى قوللايدۇ
Comment[uk]=Віджет Плазми, написаний на Python
Comment[wa]=Sopoirt des ahesses sicrîtes e Python po Plasma
Comment[x-test]=xxPlasma widget support written in Pythonxx
Comment[zh_CN]=Plasma Python
Comment[zh_TW]= Python Plasma
X-KDE-ServiceTypes=Plasma/ScriptEngine
Type=Service
Icon=text-x-script
X-Plasma-API=python
X-Plasma-ComponentTypes=Applet
X-KDE-Library=kpythonpluginfactory
X-KDE-PluginKeyword=plasma_scriptengine_python/pyappletscript.py

View file

@ -1,151 +0,0 @@
[Desktop Entry]
Name=Python data engine
Name[ar]=محرك بيانات بايثون
Name[ast]=Motor de datos de Python
Name[be@latin]=Systema źviestak u movie Python
Name[bg]=Ядро за данни с Python
Name[bn_IN]=Python ি
Name[bs]=Python pogon podataka
Name[ca]=Motor de dades en Python
Name[ca@valencia]=Motor de dades en Python
Name[cs]=Rozhraní v Pythonu
Name[csb]=Czérownik Phythona
Name[da]=Datamotor til Python
Name[de]=Python-Datentreiber
Name[el]=Μηχανή δεδομένων Python
Name[en_GB]=Python data engine
Name[eo]=Pitona datuma motoro
Name[es]=Motor de datos de Python
Name[et]=Pythoni andmete mootor
Name[eu]=Python-en datu-motorra
Name[fi]=Python-tietomoottori
Name[fr]=Moteur de données Python
Name[fy]=Python gegevens motor
Name[ga]=Inneall sonraí Python
Name[gl]=Motor de datos de Python
Name[gu]= િ િ
Name[he]=מנוע תוכן של Python
Name[hi]= ि
Name[hne]= ि
Name[hr]=Pythonov podatkovni mehanizam
Name[hu]=Adatkezelő modul Python nyelven
Name[ia]=Motor de datos de Python
Name[id]=Mesin data Python
Name[is]=Python gagnavél
Name[ja]=Python
Name[kk]=Python деректер тетігі
Name[km]= Python
Name[kn]= ಿ
Name[ko]=
Name[lt]=Python duomenų variklis
Name[lv]=Python datu dzinējs
Name[ml]= ി
Name[mr]=Python ि
Name[nb]=Python datamotor
Name[nds]=Python-Datenkarn
Name[nl]=Python (gegevensengine)
Name[nn]=Python-datamotor
Name[or]= ି
Name[pa]=
Name[pl]=Silnik danych w Pythonie
Name[pt]=Motor de dados em Python
Name[pt_BR]=Mecanismo de dados Python
Name[ro]=Motor de date Python
Name[ru]=Источник данных на языке Python
Name[si]=Python data engine
Name[sk]=Python dátový nástroj
Name[sl]=Podatkovni vir v Pythonu
Name[sr]=питонски датомотор
Name[sr@ijekavian]=питонски датомотор
Name[sr@ijekavianlatin]=Python datomotor
Name[sr@latin]=Python datomotor
Name[sv]=Python datagränssnitt
Name[ta]=Python data engine
Name[tg]=Системаи санаи Python
Name[th]=
Name[tr]=Python veri motoru
Name[ug]=Python سانلىق-مەلۇمات ماتورى
Name[uk]=Рушій даних Python
Name[wa]=Moteur di dnêyes Python
Name[x-test]=xxPython data enginexx
Name[zh_CN]=Python
Name[zh_TW]=Python
Comment=Plasma data engine support for Python
Comment[ar]=دعم محرك بيانات بلازما للبايثون
Comment[ast]=Sofitu del motor de datos de plasma pa Python
Comment[be@latin]=Absłuhoŭvańnie systemy źviestak Plasma u movie Python
Comment[bg]=Поддръжка за създаване на ядра за данни на Plasma с Python
Comment[bs]=Podrška plazma pogona podataka za Python
Comment[ca]=Implementació de motor de dades del Plasma per al Python
Comment[ca@valencia]=Implementació de motor de dades del Plasma per al Python
Comment[cs]=Podpora datového rozhraní Plasmy v Pythonu
Comment[da]=Plasma datamotor-understøttelse af Python
Comment[de]=Unterstützung für Plasma-Datentreiber in Python
Comment[el]=Υποστήριξη μηχανής δεδομένων Plasma για την Python
Comment[en_GB]=Plasma data engine support for Python
Comment[eo]=Plasma datummotora apogo por Pitono
Comment[es]=Soporte del motor de datos de plasma para Python
Comment[et]=Plasma andmemootori toetus Pythonile
Comment[eu]=Python-erako Plasmaren datu-motorraren euskarria
Comment[fi]=Plasma-tietomoottorituki Python-kielelle
Comment[fr]=Prise en charge du moteur de données Python pour Plasma
Comment[fy]=Plasma-gegevensmotor-stipe foar Python
Comment[ga]=Tacaíocht innill sonraí Plasma le haghaidh Python
Comment[gl]=Motor de datos de Plasma para dar soporte a Python
Comment[gu]= િ િ
Comment[he]=תמיכה במנועי תוכן של Plasma עבור Python
Comment[hi]= ि ि
Comment[hne]= ि
Comment[hr]=Plasmin podatkovni mehanizam koji podržava Python
Comment[hu]=Plazma adatkezelő modul Pythonhoz
Comment[ia]=Supporto de motor de datos de Plasma pro Python
Comment[id]=Mesin data Plasma didukung oleh Python
Comment[is]=Plasma gagnavélarstuðningur fyrir Python
Comment[ja]=Python Plasma
Comment[kk]=Python деректер тетігінің Plasma қолдауы
Comment[km]= Python
Comment[kn]=ಿ
Comment[ko]= Plasma
Comment[lt]=Plasma duomenų variklio palaikymas Python kalbai
Comment[lv]=Plasma datu dzinēju atbalsts Python
Comment[ml]=ിി ി ി
Comment[mr]=Python ि Plasma ि
Comment[nb]=Plasma datamotor-støtte for Python
Comment[nds]=Plasma-Datenkarnünnerstütten för Python
Comment[nl]=Plasma-gegevensengine-ondersteuning voor Python
Comment[nn]=Plasma-datamotorstøtte for Python
Comment[or]= ି
Comment[pa]= ਿ
Comment[pl]=Obsługa silnika danych Plazmy w Pythonie
Comment[pt]=Suporte para os motores de dados do Plasma em Python
Comment[pt_BR]=Suporte aos mecanismos de dados em Python
Comment[ro]=Suport motor de date Plasma pentru Python
Comment[ru]=Поддержка источников данных для Python
Comment[si]=Plasma data engine support for Python
Comment[sk]=Podpora dátového nástroja plasmy pre Python
Comment[sl]=Podpora za podatkovne vire napisane v Pythonu
Comment[sr]=Подршка плазма датомотора за питон
Comment[sr@ijekavian]=Подршка плазма датомотора за питон
Comment[sr@ijekavianlatin]=Podrška plasma datomotora za Python
Comment[sr@latin]=Podrška plasma datomotora za Python
Comment[sv]=Plasma datagränssnittstöd för Python
Comment[ta]=Plasma data engine support for Python
Comment[te]= ి
Comment[tg]=Пуштибонии Python дар асоси маълумоти Plasma
Comment[th]=
Comment[tr]=Python için Plasma veri motoru desteği
Comment[ug]=Python نىڭ Plasma سانلىق-مەلۇمات ماتورىنى قوللىشى
Comment[uk]=Підтримка у рушіях даних для Python
Comment[wa]=Sopoirt po Python do moteur di dnêyes di Plasma
Comment[x-test]=xxPlasma data engine support for Pythonxx
Comment[zh_CN]=Python Plasma
Comment[zh_TW]= Python Plasma
X-KDE-ServiceTypes=Plasma/ScriptEngine
Type=Service
Icon=text-x-script
X-KDE-Library=kpythonpluginfactory
X-KDE-PluginKeyword=plasma_scriptengine_python/pydataengine.py
X-EngineName=pythondataengine
X-Plasma-API=python
X-Plasma-ComponentTypes=DataEngine

View file

@ -1,133 +0,0 @@
[Desktop Entry]
Name=Python Runner
Name[ar]=مشغل بايثون
Name[ast]=Llanzador Python
Name[bg]=Стартер с Python
Name[bs]=Python izvođač
Name[ca]=Executor en Python
Name[ca@valencia]=Executor en Python
Name[cs]=Python spouštěč
Name[da]=Python Runner
Name[de]=Python-Starter
Name[el]=Εκτελεστής Python
Name[en_GB]=Python Runner
Name[eo]=Pitona motoro
Name[es]=Lanzador Python
Name[et]=Pythoni käivitaja
Name[eu]=Python abiarazlea
Name[fi]=Python-suoritusohjelma
Name[fr]=Lanceur Python
Name[ga]=Feidhmitheoir Python
Name[gl]=Executor en Python
Name[gu]=Python
Name[he]=Python Runner
Name[hi]=
Name[hr]=Python Runner
Name[hu]=Python-indító
Name[ia]=Executor de Python
Name[id]=Pelari Python
Name[is]=Python keyrari
Name[ja]=Python
Name[kk]=Python-ды жегу
Name[km]= Python
Name[kn]=
Name[ko]=
Name[lt]=Python leistukas
Name[lv]=Python darbinātājs
Name[mr]=
Name[nb]=Python-kjører
Name[nds]=Python-Dreger
Name[nl]=Python-starter
Name[nn]=Python-køyrar
Name[pa]=
Name[pl]=Uruchamianie w Pythonie
Name[pt]=Módulo de Execução em Python
Name[pt_BR]=Execução em Python
Name[ro]=Executor Python
Name[ru]=Модули запуска команд на языке Python
Name[si]=Python
Name[sk]=Python spúšťač
Name[sl]=Zaganjalnik v Pythonu
Name[sr]=питонски извођач
Name[sr@ijekavian]=питонски извођач
Name[sr@ijekavianlatin]=Python izvođač
Name[sr@latin]=Python izvođač
Name[sv]=Python körningsprogram
Name[tg]=Системаи санаи Python
Name[th]=
Name[tr]=Python Çalıştırıcı
Name[ug]=Python ئىجراچىسى
Name[uk]=Запуск для Python
Name[wa]=Enondeu Python
Name[x-test]=xxPython Runnerxx
Name[zh_CN]=Python
Name[zh_TW]=Python
Comment=Plasma Runner support for Python
Comment[ar]=دعم مشغل بلازما لبايثون
Comment[ast]=Implementación de llanzador Plasma pa Python
Comment[bg]=Поддръжка за създаване на стартери на Plasma с Python
Comment[bs]=Podrška plazma izvođača za Python
Comment[ca]=Implementació de l'executor del Plasma per al Python
Comment[ca@valencia]=Implementació de l'executor del Plasma per al Python
Comment[cs]=Podpora Plasma spouštěče pro Python
Comment[da]=Understøttelse af Plasma Runner til Python
Comment[de]=Plasma-Starter-Unterstützung für Python
Comment[el]=Υποστήριξη εκτελεστή Plasma για την Python
Comment[en_GB]=Plasma Runner support for Python
Comment[es]=Implementación de lanzador Plasma para Python
Comment[et]=Plasma käivitaja toetus Pythonile
Comment[eu]=Python-erako Plasmaren abiarazlearen euskarria
Comment[fi]=Plasma-suoritusohjelmatuki Python-kielelle
Comment[fr]=Prise en charge du lanceur Plasma pour Python
Comment[gl]=Executor de Plasma que permite usar Python
Comment[he]=תמיכה ב־Runner של Plasma עבור Python
Comment[hi]= ि
Comment[hr]=Plasma Runner podrška za Python
Comment[hu]=Plazma-indító támogatás Pythonhoz
Comment[ia]=Supporto de executor de Plasma pro Python
Comment[id]=Dukungan Pelari Plasma terhadap Python
Comment[is]=Plasma gagnavélarstuðningur fyrir Python
Comment[ja]=Python Plasma
Comment[kk]=Plasma-дағы Python-ды жегуін қолдауы
Comment[km]= Python
Comment[kn]=ಿ
Comment[ko]=Plasma
Comment[lt]=Plasma paleidiklio palaikymas Python kalbai
Comment[lv]=Plasma darbinātāja atbalsts Python
Comment[mr]= ि
Comment[nb]=Plasma kjørerstøtte for Python
Comment[nds]=Plasma-Dregerünnerstütten för Python
Comment[nl]=Plasma-starter-ondersteuning voor Python
Comment[nn]=Plasma-køyrarstøtte for Python
Comment[pa]= ਿ
Comment[pl]=Obsługa programów uruchamiających dla Pythona
Comment[pt]=Suporte de módulos de execução do Plasma em Python
Comment[pt_BR]=Suporte aos mecanismos de execução do Plasma para Python
Comment[ro]=Suport executori Plasma pentru Python
Comment[ru]=Поддержка модулей запуска KRunner на языке Python
Comment[si]=Python
Comment[sk]=Podpora spúšťača plasmy pre Python
Comment[sl]=Podpora za zaganjalnike napisane v Pythonu
Comment[sr]=Подршка плазма извођача за питон
Comment[sr@ijekavian]=Подршка плазма извођача за питон
Comment[sr@ijekavianlatin]=Podrška plasma izvođača za Python
Comment[sr@latin]=Podrška plasma izvođača za Python
Comment[sv]=Plasma körningsstöd för Python
Comment[tg]=Пуштибонии Python дар асоси маълумоти Plasma
Comment[th]=
Comment[tr]=Python için Plasma Çalıştırıcı desteği
Comment[ug]=Python نى قوللايدىغان Plasma ئىجراچىسى
Comment[uk]=Підтримка Python у інструментах запуску
Comment[wa]=Sopoirt po Python di l' enondeu di Plasma
Comment[x-test]=xxPlasma Runner support for Pythonxx
Comment[zh_CN]= Python Plasma
Comment[zh_TW]= Python
X-KDE-ServiceTypes=Plasma/ScriptEngine
Type=Service
Icon=text-x-script
X-KDE-Library=kpythonpluginfactory
X-KDE-PluginKeyword=plasma_scriptengine_python/pyrunner.py
X-EngineName=pythonrunner
X-Plasma-API=python
X-Plasma-ComponentTypes=Runner

View file

@ -1,137 +0,0 @@
[Desktop Entry]
Name=Python wallpaper
Name[ar]=خلفية شاشة مكتوبة باستخدام بايثون
Name[ast]=Fondu d'escritoriu en Python
Name[bg]=Тапети с Python
Name[bn]=
Name[bs]=Python pozadinska slika
Name[ca]=Fons d'escriptori en Python
Name[ca@valencia]=Fons d'escriptori en Python
Name[cs]=Python pozadí plochy
Name[da]=Python-baggrundsbillede
Name[de]=Python-Hintergrundbild
Name[el]=Ταπετσαρία Python
Name[en_GB]=Python wallpaper
Name[eo]=Pitona ekranfono
Name[es]=Fondo de escritorio en Python
Name[et]=Pythoni taustapilt
Name[eu]=Python-en horma-papera
Name[fi]=Python-taustakuva
Name[fr]=Papier peint Python
Name[fy]=Python eftergrûnôfbylding
Name[ga]=Cúlbhrat Python
Name[gl]=Fondo de escritorio en Python
Name[gu]=
Name[he]=רקע לשולחן עבודה של Python
Name[hr]=Python podloga
Name[hu]=Python háttérkép
Name[ia]=Tapete de papiro de Python
Name[id]=Wallpaper Python
Name[is]=Python veggfóður
Name[ja]=Python
Name[kk]=Python тұсқағазы
Name[km]= Python
Name[kn]= ಿ ಿ ( )
Name[ko]=
Name[lt]=Python darbastalio fonas
Name[lv]=Python ekrāntapete
Name[ml]= ി
Name[mr]=
Name[nb]=Python bakgrunnsbilde
Name[nds]=Python-Achtergrundbild
Name[nl]=Python-achtergrondafbeelding
Name[nn]=Python-bakgrunnsbilete
Name[pa]=
Name[pl]=Tapeta w Pythonie
Name[pt]=Papel de parede em Python
Name[pt_BR]=Papel de parede em Python
Name[ro]=Fundal Python
Name[ru]=Обои рабочего стола на языке Python
Name[si]=Python
Name[sk]=Python tapeta
Name[sl]=Ozadje v Pythonu
Name[sr]=питонски тапет
Name[sr@ijekavian]=питонски тапет
Name[sr@ijekavianlatin]=Python tapet
Name[sr@latin]=Python tapet
Name[sv]=Python skrivbordsunderlägg
Name[tg]=Барномаи Plasma
Name[th]=
Name[tr]=Python duvar kağıdı
Name[ug]=Python تام قەغىزى
Name[uk]=Шпалери для Python
Name[wa]=Tapisreye Python
Name[x-test]=xxPython wallpaperxx
Name[zh_CN]=Python
Name[zh_TW]=Python
Comment=Plasma wallpaper support for Python
Comment[ar]=دعم خلفية شاشة بلازما لبايثون
Comment[ast]=Fondos de pantalla de Plasma pa Python
Comment[bg]=Поддръжка за работа с тапети на Plasma с Python
Comment[bs]=Podrška plazma pozadinskih slika za Python
Comment[ca]=Implementació de fons d'escriptori del Plasma per al Python
Comment[ca@valencia]=Implementació de fons d'escriptori del Plasma per al Python
Comment[cs]=Podpora Plasma pozadí plochy pro Python
Comment[da]=Understøttelse af Plasma wallpaper til Python
Comment[de]=Unterstützung in Plasma für Python-Hintergrundbilder
Comment[el]=Υποστήριξη ταπετσαρίας Plasma για την Python
Comment[en_GB]=Plasma wallpaper support for Python
Comment[es]=Fondos de pantalla de Plasma para Python
Comment[et]=Plasma taustapildi toetus Pythonile
Comment[eu]=Python-erako Plasma horma-paperaren euskarria
Comment[fi]=Plasma-taustakuvatuki Python-kielelle
Comment[fr]=Prise en charge du papier peint de Plasma pour Python
Comment[fy]=Plasma eftergrûnôfbylding stipe foar Python
Comment[gl]=Compatibilidade de Python co fondo de escritorio de Plasma
Comment[he]=תמיכה ברקעי שולחן עבודה של Plasma עבור Python
Comment[hi]= ि
Comment[hr]=Plasmina podloga koja podržava Python
Comment[hu]=Plasma-háttérkép támogatás Pythonhoz
Comment[ia]=Supporto de tapete de papiro pro Python
Comment[id]=Wallpeper Plasma yang mendukung Python
Comment[is]=Plasma veggfóðurstuðningur fyrir Python
Comment[ja]=Python Plasma
Comment[kk]=Plasma-дағы Python тұсқағазының қолдауы
Comment[km]= Python
Comment[kn]=ಿ ಿ ಿ
Comment[ko]= Plasma
Comment[lt]=Plasma apmušalo palaikymas Python kalbai
Comment[lv]=Plasma ekrāntapetes atbalsts Python
Comment[ml]=ിി ി ി
Comment[mr]= ि
Comment[nb]=Plasma bakgrunnsbilde-støtte for Python
Comment[nds]=Plasma-Achtergrundünnerstütten för Python
Comment[nl]=Plasma-achtergrondafbeelding-ondersteuning voor Python
Comment[nn]=Plasma-bakgrunnsbiletstøtte for Python
Comment[pa]= ਿ
Comment[pl]=Obsługa tapet Plazmy w Pythonie
Comment[pt]=Suporte para os papéis de parede do Plasma em Python
Comment[pt_BR]=Suporte aos mecanismos a papéis de parede do Plasma em Python
Comment[ro]=Suport fundaluri Plasma pentru Python
Comment[ru]=Поддержка обоев рабочего стола на языке Python
Comment[si]=Python
Comment[sk]=Podpora tapiet plasmy pre Python
Comment[sl]=Podpora za ozadja napisana v Pythonu
Comment[sr]=Подршка плазма тапета за питон
Comment[sr@ijekavian]=Подршка плазма тапета за питон
Comment[sr@ijekavianlatin]=Podrška plasma tapeta za Python
Comment[sr@latin]=Podrška plasma tapeta za Python
Comment[sv]=Plasma skrivbordsunderläggsstöd för Python
Comment[tg]=Пуштибонии Python дар асоси маълумоти Plasma
Comment[th]=
Comment[tr]=Python için Plasma duvar kağıdı desteği
Comment[ug]=Python نى قوللايدىغان Plasma تام قەغەز
Comment[uk]=Підтримка Python у шпалерах Плазми
Comment[wa]=Sopoirt po Python del tapisreye di Plasma
Comment[x-test]=xxPlasma wallpaper support for Pythonxx
Comment[zh_CN]= Python Plasma
Comment[zh_TW]= Python Plasma
X-KDE-ServiceTypes=Plasma/ScriptEngine
Type=Service
Icon=text-x-script
X-KDE-Library=kpythonpluginfactory
X-KDE-PluginKeyword=plasma_scriptengine_python/pywallpaper.py
X-EngineName=pythonwallpaper
X-Plasma-API=python
X-Plasma-ComponentTypes=Wallpaper

View file

@ -1,114 +0,0 @@
# -*- coding: utf-8 -*-
#
# Copyright 2008 Simon Edwards <simon@simonzone.com>
#
# 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.
#
import sys
import os
import imp
class PlasmaImporter(object):
def __init__(self):
self.toplevel = {}
self.toplevelcount = {}
self.marker = '<plasma>' + str(id(self))
sys.path.append(self.marker)
sys.path_hooks.append(self.hook)
def hook(self,path):
if path==self.marker:
return self
else:
raise ImportError()
def register_top_level(self,name,path):
if name not in self.toplevel:
self.toplevelcount[name] = 1
self.toplevel[name] = path
else:
self.toplevelcount[name] += 1
def unregister_top_level(self,name):
value = self.toplevelcount[name]-1
self.toplevelcount[name] = value
if value==0:
del self.toplevelcount[name]
del self.toplevel[name]
for key in list(sys.modules.keys()):
if key==name or key.startswith(name+"."):
del sys.modules[key]
def find_module(self,fullname, path=None):
location = self.find_pymod(fullname)
if location is not None:
return self
else:
return None
# Find the given module in the plasma directory.
# Result a tuple on success otherwise None. The tuple contains the location
# of the module/package in disk and a boolean indicating if it is a package
# or module
def find_pymod(self,modulename):
parts = modulename.split('.')
toppackage = parts[0]
rest = parts[1:]
if toppackage in self.toplevel:
path = self.toplevel[toppackage]
if len(rest)==0:
# Simple top level Plasma package
return (path,True)
else:
restpath = apply(os.path.join,rest)
fullpath = os.path.join(path,'contents','code',restpath)
if os.path.isdir(fullpath):
return (fullpath,True)
elif os.path.exists(fullpath+'.py'):
return (fullpath+'.py',False)
else:
return None
def _get_code(self,location):
return open(location).read()
def load_module(self, fullname):
location,ispkg = self.find_pymod(fullname)
if ispkg: # Package dir.
initlocation = os.path.join(location,'__init__.py')
code = None
if os.path.isfile(initlocation):
code = open(initlocation)
else:
code = open(location)
mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
mod.__file__ = location #"<%s>" % self.__class__.__name__
mod.__loader__ = self
if ispkg:
mod.__path__ = [self.marker]
if code is not None:
try:
exec(code in mod.__dict__)
finally:
code.close()
return mod
#plasma_importer = PlasmaImporter()
#plasma_importer.register_top_level('plasma_pyclock','/home/sbe/devel/python_plasma_2/test/plasma-pyclock')
#from plasma_pyclock import main

View file

@ -1,225 +0,0 @@
# -*- coding: utf-8 -*-
#
# Copyright 2008 Simon Edwards <simon@simonzone.com>
#
# 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.
#
# Plasma applet API for Python
from PyQt4.QtCore import QObject
from PyQt4.QtGui import QGraphicsWidget
from PyKDE4.plasma import Plasma # Plasma C++ namespace
#import sip
#import gc
class Applet(QObject):
''' Subclass Applet in your module and return an instance of it in a global function named
applet(). Implement the following functions to breathe life into your applet:
* paint - Draw the applet given a QPainter and some options
It provides the same API as Plasma.Applet; it just has slightly less irritating event names. '''
def __init__(self, parent=None):
# this should be set when the applet is created
QObject.__init__(self, parent)
#sip.settracemask(0x3f)
self.applet = None
self.applet_script = None
self._forward_to_applet = True
def __getattr__(self, key):
# provide transparent access to the real applet instance
if self._forward_to_applet:
try:
return getattr(self.applet_script, key)
except:
return getattr(self.applet, key)
else:
raise AttributeError(key)
def _enableForwardToApplet(self):
self._forward_to_applet = True
def _disableForwardToApplet(self):
self._forward_to_applet = False
# Events
def setApplet(self,applet):
self.applet = applet
def setAppletScript(self,appletScript):
self.applet_script = appletScript
def init(self):
pass
def configChanged(self):
pass
def paintInterface(self, painter, options, rect):
pass
def constraintsEvent(self, flags):
pass
def showConfigurationInterface(self):
self.dlg = self.standardConfigurationDialog()
self.createConfigurationInterface(self.dlg)
self.addStandardConfigurationPages(self.dlg)
self.dlg.show()
def createConfigurationInterface(self, dlg):
pass
def contextualActions(self):
return []
def shape(self):
return QGraphicsWidget.shape(self.applet)
def initExtenderItem(self, item):
print ("Missing implementation of initExtenderItem in the applet " + \
item.config().readEntry('SourceAppletPluginName', '').toString() + \
"!\nAny applet that uses extenders should implement initExtenderItem to " + \
"instantiate a widget.")
def saveState(self, config):
pass
###########################################################################
class DataEngine(QObject):
def __init__(self, parent=None):
QObject.__init__(self, parent)
self.dataengine = None
self.dataengine_script = None
def setDataEngine(self,dataEngine):
self.dataEngine = dataEngine
def setDataEngineScript(self,dataEngineScript):
self.data_engine_script = dataEngineScript
def __getattr__(self, key):
# provide transparent access to the real dataengine script instance
try:
return getattr(self.data_engine_script, key)
except:
return getattr(self.dataEngine, key)
def init(self):
pass
def sources(self):
return []
def sourceRequestEvent(self,name):
return False
def updateSourceEvent(self,source):
return False
def serviceForSource(self,source):
return Plasma.DataEngineScript.serviceForSource(self.data_engine_script,source)
###########################################################################
class Wallpaper(QObject):
def __init__(self, parent=None):
QObject.__init__(self, parent)
self.wallpaper = None
self.wallpaper_script = None
def setWallpaper(self,wallpaper):
self.wallpaper = wallpaper
def setWallpaperScript(self,wallpaperScript):
self.wallpaper_script = wallpaperScript
def __getattr__(self, key):
# provide transparent access to the real wallpaper script instance
try:
return getattr(self.wallpaper_script, key)
except:
return getattr(self.wallpaper, key)
def init(self, config):
pass
def paint(self,painter, exposedRect):
pass
def save(self,config):
pass
def createConfigurationInterface(self,parent):
return None
def mouseMoveEvent(self,event):
pass
def mousePressEvent(self,event):
pass
def mouseReleaseEvent(self,event):
pass
def wheelEvent(self,event):
pass
def renderCompleted(self, image):
pass
def urlDropped(self, url):
pass
###########################################################################
class Runner(QObject):
def __init__(self, parent=None):
QObject.__init__(self, parent)
self.runner = None
self.runner_script = None
def setRunner(self,runner):
self.runner = runner
def setRunnerScript(self,runnerScript):
self.runner_script = runnerScript
def __getattr__(self, key):
# provide transparent access to the real runner script instance
try:
return getattr(self.runner_script, key)
except:
return getattr(self.runner, key)
def init(self):
pass
def match(self, search):
pass
def run(self, search, action):
pass
def prepare(self):
pass
def teardown(self):
pass
def createRunOptions(self, widget):
pass
def reloadConfiguration(self):
pass

View file

@ -1,172 +0,0 @@
# -*- coding: utf-8 -*-
#
# Copyright 2008 Simon Edwards <simon@simonzone.com>
#
# 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.
#
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyKDE4.plasma import Plasma
import plasma_importer
import os.path
class PythonAppletScript(Plasma.AppletScript):
importer = None
def __init__(self, parent):
Plasma.AppletScript.__init__(self,parent)
#print("PythonAppletScript()")
if PythonAppletScript.importer is None:
PythonAppletScript.importer = plasma_importer.PlasmaImporter()
self.initialized = False
def init(self):
#print("Script Name: " + str(self.applet().name()))
#print("Script Category: " + str(self.applet().category()))
# applet() cannot be relied on to give the right details in the destructor,
# so the plugin name is stored aside. (n.b module.__name__ cannot be relied
# on either; it might have been changed in the module itself)
self.moduleName = str(self.applet().pluginName())
#print("pluginname: " + str(self.applet().pluginName()))
self.pluginName = 'applet_' + self.moduleName.replace('-','_')
PythonAppletScript.importer.register_top_level(self.pluginName, str(self.applet().package().path()))
#print("mainScript: " + str(self.mainScript()))
#print("package path: " + str(self.applet().package().path()))
# import the code at the file name reported by mainScript()
relpath = os.path.relpath(str(self.mainScript()),str(self.applet().package().path()))
if relpath.startswith("contents/code/"):
relpath = relpath[14:]
if relpath.endswith(".py"):
relpath = relpath[:-3]
relpath = relpath.replace("/",".")
self.module = __import__(self.pluginName+'.'+relpath)
# Plasma main scripts not necessarily are named "main"
# So we use __dict__ to get the right main script name
basename = os.path.basename(str(self.mainScript()))
basename = os.path.splitext(basename)[0]
self.pyapplet = self.module.__dict__[basename].CreateApplet(None)
self.pyapplet.setApplet(self.applet())
self.pyapplet.setAppletScript(self)
self.connect(self.applet(), SIGNAL('extenderItemRestored(Plasma::ExtenderItem*)'),
self, SLOT('initExtenderItem(Plasma::ExtenderItem*)'))
self.connect(self, SIGNAL('saveState(KConfigGroup&)'),
self, SLOT('saveStateSlot(KConfigGroup&)'))
self._setUpEventHandlers()
self.initialized = True
self.pyapplet.init()
return True
def __dtor__(self):
#print("~PythonAppletScript()")
if not self.initialized:
return
PythonAppletScript.importer.unregister_top_level(self.pluginName)
self.pyapplet = None
@pyqtSignature("initExtenderItem(Plasma::ExtenderItem*)")
def initExtenderItem(self, item):
if not self.initialized:
return
self.pyapplet.initExtenderItem(item)
@pyqtSignature("saveStateSlot(KConfigGroup&)")
def saveStateSlot(self, config):
if not self.initialized:
return
self.pyapplet.saveState(config)
def constraintsEvent(self, constraints):
if not self.initialized:
return
self.pyapplet.constraintsEvent(constraints)
def showConfigurationInterface(self):
if not self.initialized:
return
#print("Script: showConfigurationInterface")
self.pyapplet.showConfigurationInterface()
def configChanged(self):
if not self.initialized:
return
self.pyapplet.configChanged()
def paintInterface(self, painter, option, contentsRect):
if not self.initialized:
return
self.pyapplet.paintInterface(painter, option, contentsRect)
def contextualActions(self):
if not self.initialized:
return
#print("pythonapplet contextualActions()")
return self.pyapplet.contextualActions()
def shape(self):
if not self.initialized:
return QPainterPath()
return self.pyapplet.shape()
def eventFilter(self, obj, event):
handler = self.event_handlers.get(event.type(),None)
if handler is not None:
apply(getattr(self.pyapplet,handler), (event,) )
return True
else:
return False
def _setUpEventHandlers(self):
self.event_handlers = {}
self.pyapplet._disableForwardToApplet()
for event_type,handler in {
QEvent.GraphicsSceneMousePress: "mousePressEvent",
QEvent.GraphicsSceneContextMenu: "contextMenuEvent",
QEvent.GraphicsSceneDragEnter: "dragEnterEvent",
QEvent.GraphicsSceneDragLeave: "dragLeaveEvent",
QEvent.GraphicsSceneDragMove: "dragMoveEvent",
QEvent.GraphicsSceneDrop: "dropEvent",
QEvent.FocusIn: "focusInEvent",
QEvent.FocusOut: "focusOutEvent",
QEvent.GraphicsSceneHoverEnter: "hoverEnterEvent",
QEvent.GraphicsSceneHoverLeave: "hoverLeaveEvent",
QEvent.GraphicsSceneHoverMove: "hoverMoveEvent",
QEvent.InputMethod: "inputMethodEvent",
QEvent.KeyPress: "keyPressEvent",
QEvent.KeyRelease: "keyReleaseEvent",
QEvent.GraphicsSceneMouseDoubleClick: "mouseDoubleClickEvent",
QEvent.GraphicsSceneMouseMove: "mouseMoveEvent",
QEvent.GraphicsSceneMousePress: "mousePressEvent",
QEvent.GraphicsSceneMouseRelease: "mouseReleaseEvent",
QEvent.GraphicsSceneWheel: "wheelEvent"
}.iteritems():
if hasattr(self.pyapplet,handler):
self.event_handlers[event_type] = handler
self.pyapplet._enableForwardToApplet()
if self.event_handlers:
self.applet().installEventFilter(self)
def CreatePlugin(widget_parent, parent, component_data):
return PythonAppletScript(parent)

View file

@ -1,79 +0,0 @@
# -*- coding: utf-8 -*-
#
# Copyright 2008 Simon Edwards <simon@simonzone.com>
#
# 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.
#
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyKDE4.plasma import Plasma
import plasma_importer
import os.path
class PythonDataEngineScript(Plasma.DataEngineScript):
importer = None
def __init__(self, parent):
Plasma.DataEngineScript.__init__(self,parent)
if PythonDataEngineScript.importer is None:
PythonDataEngineScript.importer = plasma_importer.PlasmaImporter()
self.initialized = False
def init(self):
self.moduleName = str(self.dataEngine().pluginName())
self.pluginName = 'dataengine_' + self.moduleName.replace('-','_')
PythonDataEngineScript.importer.register_top_level(self.pluginName, str(self.dataEngine().package().path()))
# import the code at the file name reported by mainScript()
relpath = os.path.relpath(str(self.mainScript()),str(self.dataEngine().package().path()))
if relpath.startswith("contents/code/"):
relpath = relpath[14:]
if relpath.endswith(".py"):
relpath = relpath[:-3]
relpath = relpath.replace("/",".")
self.module = __import__(self.pluginName+'.'+relpath)
# The script may not necessarily be called "main"
# So we use __dict__ to look up the right name
basename = os.path.basename(str(self.mainScript()))
basename = os.path.splitext(basename)[0]
self.pydataengine = self.module.__dict__[basename].CreateDataEngine(None)
self.pydataengine.setDataEngine(self.dataEngine())
self.pydataengine.setDataEngineScript(self)
self.pydataengine.init()
self.initialized = True
return True
def __dtor__(self):
PythonDataEngineScript.importer.unregister_top_level(self.pluginName)
self.pydataengine = None
def sources(self):
return self.pydataengine.sources()
def serviceForSource(self,source):
return self.pydataengine.serviceForSource(source)
def sourceRequestEvent(self,name):
return self.pydataengine.sourceRequestEvent(name)
def updateSourceEvent(self,source):
return self.pydataengine.updateSourceEvent(source)
def CreatePlugin(widget_parent, parent, component_data):
return PythonDataEngineScript(parent)

View file

@ -1,93 +0,0 @@
# -*- coding: utf-8 -*-
#
# Copyright 2008 Simon Edwards <simon@simonzone.com>
# Copyright 2009 Petri Damstén <damu@iki.fi>
#
# 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.
#
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyKDE4.plasma import Plasma
import plasma_importer
import os.path
class PythonRunnerScript(Plasma.RunnerScript):
importer = None
def __init__(self, parent):
Plasma.RunnerScript.__init__(self,parent)
if PythonRunnerScript.importer is None:
PythonRunnerScript.importer = plasma_importer.PlasmaImporter()
self.initialized = False
def init(self):
self.moduleName = str(self.runner().package().metadata().pluginName())
self.pluginName = 'runner_' + self.moduleName.replace('-','_')
PythonRunnerScript.importer.register_top_level(self.pluginName, str(self.runner().package().path()))
# import the code at the file name reported by mainScript()
relpath = os.path.relpath(str(self.mainScript()),str(self.runner().package().path()))
if relpath.startswith("contents/code/"):
relpath = relpath[14:]
if relpath.endswith(".py"):
relpath = relpath[:-3]
relpath = relpath.replace("/",".")
self.module = __import__(self.pluginName+'.'+relpath)
basename = os.path.basename(str(self.mainScript()))
basename = os.path.splitext(basename)[0]
self.pyrunner = self.module.__dict__[basename].CreateRunner(None)
self.pyrunner.setRunner(self.runner())
self.pyrunner.setRunnerScript(self)
self.connect(self, SIGNAL('prepare()'), self, SLOT('prepare()'))
self.connect(self, SIGNAL('teardown()'), self, SLOT('teardown()'))
self.connect(self, SIGNAL('createRunOptions(QWidget*)'),
self, SLOT('createRunOptions(QWidget*)'))
self.connect(self, SIGNAL('reloadConfiguration()'),
self, SLOT('reloadConfiguration()'))
self.pyrunner.init()
self.initialized = True
return True
def __dtor__(self):
PythonRunnerScript.importer.unregister_top_level(self.pluginName)
self.pyrunner = None
def match(self, search):
self.pyrunner.match(search)
def run(self, search, action):
self.pyrunner.run(search, action)
@pyqtSignature("prepare()")
def prepare(self):
self.pyrunner.prepare()
@pyqtSignature("teardown()")
def teardown(self):
self.pyrunner.teardown()
@pyqtSignature("createRunOptions(QWidget*)")
def createRunOptions(self, widget):
self.pyrunner.createRunOptions(widget)
@pyqtSignature("reloadConfiguration()")
def reloadConfiguration(self):
self.pyrunner.reloadConfiguration()
def CreatePlugin(widget_parent, parent, component_data):
return PythonRunnerScript(parent)

View file

@ -1,97 +0,0 @@
# -*- coding: utf-8 -*-
#
# Copyright 2008 Simon Edwards <simon@simonzone.com>
# Copyright 2009 Petri Damstén <damu@iki.fi>
#
# 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.
#
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyKDE4.plasma import Plasma
import plasma_importer
import os.path
class PythonWallpaperScript(Plasma.WallpaperScript):
importer = None
def __init__(self, parent):
Plasma.WallpaperScript.__init__(self,parent)
if PythonWallpaperScript.importer is None:
PythonWallpaperScript.importer = plasma_importer.PlasmaImporter()
self.initialized = False
def init(self):
self.moduleName = str(self.wallpaper().pluginName())
self.pluginName = 'wallpaper_' + self.moduleName.replace('-','_')
PythonWallpaperScript.importer.register_top_level(self.pluginName, str(self.wallpaper().package().path()))
# import the code at the file name reported by mainScript()
relpath = os.path.relpath(str(self.mainScript()),str(self.wallpaper().package().path()))
if relpath.startswith("contents/code/"):
relpath = relpath[14:]
if relpath.endswith(".py"):
relpath = relpath[:-3]
relpath = relpath.replace("/",".")
self.module = __import__(self.pluginName+'.'+relpath)
self.pywallpaper = self.module.main.CreateWallpaper(None)
self.pywallpaper.setWallpaper(self.wallpaper())
self.pywallpaper.setWallpaperScript(self)
self.initialized = True
return True
def __dtor__(self):
PythonWallpaperScript.importer.unregister_top_level(self.pluginName)
self.pywallpaper = None
def paint(self, painter, exposedRect):
self.pywallpaper.paint(painter, exposedRect)
def initWallpaper(self, config):
self.pywallpaper.init(config)
def save(self, config):
self.pywallpaper.save(config)
def createConfigurationInterface(self, parent):
self.connect(self, SIGNAL('settingsChanged(bool)'), parent, SLOT('settingsChanged(bool)'))
return self.pywallpaper.createConfigurationInterface(parent)
def settingsChanged(self, changed):
self.emit(SIGNAL('settingsChanged(bool)'), changed)
def mouseMoveEvent(self, event):
self.pywallpaper.mouseMoveEvent(event)
def mousePressEvent(self, event):
self.pywallpaper.mousePressEvent(event)
def mouseReleaseEvent(self, event):
self.pywallpaper.mouseReleaseEvent(event)
def wheelEvent(self, event):
self.pywallpaper.wheelEvent(event)
@pyqtSignature("renderCompleted(const QImage&)")
def renderCompleted(self, image):
self.pywallpaper.renderCompleted(image)
@pyqtSignature("urlDropped(const KUrl&)")
def urlDropped(self, url):
self.pywallpaper.urlDropped(url)
def CreatePlugin(widget_parent, parent, component_data):
return PythonWallpaperScript(parent)

View file

@ -1,6 +0,0 @@
install(FILES applet.rb DESTINATION ${DATA_INSTALL_DIR}/plasma_scriptengine_ruby)
install(FILES data_engine.rb DESTINATION ${DATA_INSTALL_DIR}/plasma_scriptengine_ruby)
install(FILES plasma-scriptengine-ruby-applet.desktop DESTINATION ${SERVICES_INSTALL_DIR})
install(FILES plasma-scriptengine-ruby-dataengine.desktop DESTINATION ${SERVICES_INSTALL_DIR})

File diff suppressed because it is too large Load diff

View file

@ -1,147 +0,0 @@
=begin
* Copyright 2008 by Richard Dale <richard.j.dale@gmail.com>
*
* 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.
=end
require 'plasma_applet'
module PlasmaScripting
class DataEngine < Qt::Object
slots :updateAllSources, "removeSource(QString)"
signals "sourceAdded(QString)", "sourceRemoved(QString)"
attr_accessor :data_engine_script
def initialize(parent, args = nil)
super(parent)
@data_engine_script = parent
connect(@data_engine_script.dataEngine, SIGNAL("sourceAdded(QString)"), self, SIGNAL("sourceAdded(QString)"))
connect(@data_engine_script.dataEngine, SIGNAL("sourceRemoved(QString)"), self, SIGNAL("sourceRemoved(QString)"))
end
def init
end
def sourceRequestEvent(name)
end
def updateSourceEvent(source)
end
def setData(*args)
if args.length == 2 && !args[1].kind_of?(Qt::Variant)
args[1] = Qt::Variant.fromValue(args[1])
elsif args.length == 3 && !args[2].kind_of?(Qt::Variant)
args[2] = Qt::Variant.fromValue(args[2])
end
@data_engine_script.setData(*args)
end
def removeAllData(source)
@data_engine_script.removeAllData(source)
end
def removeData(source, key)
@data_engine_script.removeData(source, key)
end
def setMaxSourceCount(limit)
@data_engine_script.setMaxSourceCount(limit)
end
def maxSourceCount=(limit)
setMaxSourceCount(limit)
end
def setMinimumPollingInterval(minimumMs)
@data_engine_script.setMinimumPollingInterval(minimumMs)
end
def minimumPollingInterval=(minimumMs)
setMinimumPollingInterval(minimumMs)
end
def minimumPollingInterval
@data_engine_script.minimumPollingInterval
end
def setPollingInterval(frequency)
@data_engine_script.setPollingInterval(frequency)
end
def pollingInterval=(frequency)
setPollingInterval(frequency)
end
def removeAllSources
@data_engine_script.removeAllSources
end
def sources
return []
end
def removeSource(source)
@data_engine_script.dataEngine.removeSource(source)
end
def updateAllSources
@data_engine_script.dataEngine.updateAllSources
end
end
end
module PlasmaScriptengineRuby
class DataEngine < Plasma::DataEngineScript
def initialize(parent, args)
super(parent)
end
def camelize(str)
str.gsub(/(^|[._-])(.)/) { $2.upcase }
end
def init
puts "RubyAppletScript::DataEngine#init mainScript: #{mainScript}"
program = Qt::FileInfo.new(mainScript)
$: << program.path
load Qt::File.encodeName(program.filePath).to_s
moduleName = camelize(Qt::Dir.new(package.path).dirName)
className = camelize(program.baseName)
puts "RubyAppletScript::DataEngine#init instantiating: #{moduleName}::#{className}"
klass = Object.const_get(moduleName.to_sym).const_get(className.to_sym)
@data_engine_script = klass.new(self)
@data_engine_script.init
return true
end
def sources
@data_engine_script.sources
end
def sourceRequestEvent(name)
@data_engine_script.sourceRequestEvent(name)
end
def updateSourceEvent(source)
@data_engine_script.updateSourceEvent(source)
end
end
end
# kate: space-indent on; indent-width 2; replace-tabs on; mixed-indent off;

View file

@ -1,149 +0,0 @@
[Desktop Entry]
Name=Ruby Widget
Name[ar]=ودجة روبي
Name[ast]=Elementu gráficu en Ruby
Name[be@latin]=Widžet u movie Ruby
Name[bg]=Джаджа на Ruby
Name[bn]=ি
Name[bn_IN]=Ruby
Name[bs]=Ruby grafička kontrola
Name[ca]=Estri Ruby
Name[ca@valencia]=Estri Ruby
Name[cs]=Ruby widget
Name[csb]=Interfejs Ruby
Name[da]=Ruby-widget
Name[de]=Ruby-Miniprogramm
Name[el]=Συστατικό Ruby
Name[en_GB]=Ruby Widget
Name[eo]=Ruby-fenestraĵo
Name[es]=Elemento gráfico en Ruby
Name[et]=Ruby vidin
Name[eu]=Ruby trepeta
Name[fi]=Ruby-sovelma
Name[fr]=Composant graphique Ruby
Name[fy]=Ruby widget
Name[ga]=Giuirléid Ruby
Name[gl]=Widget escrito en Ruby
Name[gu]= િ
Name[he]=ווידג׳ט של Ruby
Name[hi]= ि
Name[hne]= ि
Name[hr]=Ruby widget
Name[hu]=Ruby-elem
Name[ia]=Elemento graphic (Widget) de Ruby
Name[id]=Widget Ruby
Name[is]=Ruby græja
Name[ja]=Ruby
Name[kk]=Ruby бөлшегі
Name[km]=
Name[kn]=ಿ ಿ (ಿ)
Name[ko]=
Name[ku]=Alava Ruby
Name[lt]=Ruby valdiklis
Name[lv]=Ruby sīkrīks
Name[ml]=ി ി
Name[mr]=Ruby ि
Name[nb]=Ruby-element
Name[nds]=Ruby-Lüttprogramm
Name[nl]=Ruby-widget
Name[nn]=Ruby-element
Name[or]=ି ି
Name[pa]= ਿ
Name[pl]=Element interfejsu w języku Ruby
Name[pt]=Elemento em Ruby
Name[pt_BR]=Widget Ruby
Name[ro]=Control Ruby
Name[ru]=Виджет на языке Ruby
Name[si]=Ruby
Name[sk]=Ruby widget
Name[sl]=Gradnik v Ruby
Name[sr]=рубијевски виџет
Name[sr@ijekavian]=рубијевски виџет
Name[sr@ijekavianlatin]=ruby vidžet
Name[sr@latin]=ruby vidžet
Name[sv]=Grafisk Ruby-komponent
Name[ta]=Ruby Widget
Name[tg]=Илова ба Ruby
Name[th]=
Name[tr]=Ruby Gereci
Name[ug]=Ruby ۋىجېتى
Name[uk]=Віджет Ruby
Name[wa]=Ahesse Ruby
Name[x-test]=xxRuby Widgetxx
Name[zh_CN]=Ruby
Name[zh_TW]=Ruby
Comment=Native Plasma widget written in Ruby
Comment[ar]=وجة بلازما أصلية مكتوبة بروبي
Comment[ast]=Elementu gráficu nativu de Plasma escrito en Ruby
Comment[be@latin]=Rodny widžet systemy Plasma, napisany ŭ movie Ruby
Comment[bg]=Оригинална джаджа за Plasma, написана на Ruby
Comment[bs]=Samosvojni plazma grafička kontrola napisana u Ruby-ju
Comment[ca]=Estri nadiu del Plasma escrit en Ruby
Comment[ca@valencia]=Estri nadiu del Plasma escrit en Ruby
Comment[cs]=Nativní plasmoid napsaný v Ruby
Comment[da]=Ægte Plasma-widget skrevet i Ruby
Comment[de]=Echtes Plasma-Programm, geschrieben in Ruby
Comment[el]=Εγγενές συστατικό Plasma γραμμένο σε Ruby
Comment[en_GB]=Native Plasma widget written in Ruby
Comment[es]=Elemento gráfico nativo de Plasma escrito en Ruby
Comment[et]=Rubys kirjutatud Plasma vidin
Comment[eu]=Jatorrizko Plasma trepeta, Ruby lengoaian idatzia
Comment[fi]=Natiivi, Ruby-pohjainen Plasma-sovelma
Comment[fr]=Composant graphique natif de Plasma écrit en Ruby
Comment[fy]=Plasma widget skreaun yn Ruby
Comment[ga]=Giuirléid dhúchasach Plasma scríofa i Ruby
Comment[gl]=Widget nativo de Plasma escrito en Ruby
Comment[gu]= િ
Comment[he]=ווידג׳ט Plasma הנכתב ב־Ruby
Comment[hi]= ि ि ि
Comment[hne]= ि ि ि
Comment[hr]=Izvorna Plasma widget napisana u Rubyu
Comment[hu]=Plasma-elem Ruby nyelven
Comment[ia]=Elemento graphic (widget) native de Plasma scribite in Ruby
Comment[id]=Widget Plasma asli yang ditulis dalam Ruby
Comment[is]=Upprunabundin Plasma græja skrifuð í Ruby
Comment[ja]=Ruby Plasma
Comment[kk]=Ruby-дег жазылған Plasma интерфейс бөлшегі
Comment[km]= Ruby
Comment[kn]=ಿಿ ಿ (ಿ)
Comment[ko]= Plasma
Comment[lt]=Nuosavas Plasma valdiklis parašytas Ruby kalba
Comment[lv]=Plasma sīkrīks, rakstīts Ruby
Comment[ml]=ിി ിിി ി
Comment[mr]=Ruby ि Plasma ि
Comment[nb]=Plasmaelement for dette systemet, skrevet i Ruby
Comment[nds]=En orginaal Plasma-Lüttprogramm, schreven in Ruby
Comment[nl]=Plasma-widget geschreven in Ruby
Comment[nn]=Lokalt Plasma-element skrive i Ruby
Comment[or]=Ruby ି ି
Comment[pa]= ਿ ਿ ਿ ਿ
Comment[pl]=Element interfejsu Plazmy napisany w języku Ruby
Comment[pt]=Elemento nativo do Plasma feito em Ruby
Comment[pt_BR]=Widget nativo do Plasma, escrito em Ruby
Comment[ro]=Miniaplicație Plasma scrisă în Ruby
Comment[ru]=Виджет Plasma, написанный на языке Ruby
Comment[si]=Native Plasma widget written in Ruby
Comment[sk]=Natívny plasma widget napísaný v Ruby
Comment[sl]=Lastni gradnik za Plasmo, ki je napisan v Rubyu
Comment[sr]=Самосвојни плазма виџет написан у рубију
Comment[sr@ijekavian]=Самосвојни плазма виџет написан у рубију
Comment[sr@ijekavianlatin]=Samosvojni plasma vidžet napisan u Rubyju
Comment[sr@latin]=Samosvojni plasma vidžet napisan u Rubyju
Comment[sv]=Inbyggd grafisk Plasma-komponent skriven i Ruby
Comment[ta]=Native Plasma widget written in Ruby
Comment[tg]=Модуль Plasma, написанный на языке JavaScript
Comment[th]=
Comment[tr]=Ruby ile yazılmış gerçek Plasma gereci
Comment[ug]=Ruby بىلەن يېزىلغان ئەسلى Plasma widget
Comment[uk]=Віджет Плазми, написаний на Ruby
Comment[wa]=Ahesse askepieye po Plasma eyet scrîte e Ruby
Comment[x-test]=xxNative Plasma widget written in Rubyxx
Comment[zh_CN]=使 Ruby Plasma
Comment[zh_TW]= Ruby Plasma
X-KDE-ServiceTypes=Plasma/ScriptEngine
Type=Service
Icon=text-x-script
X-KDE-Library=krubypluginfactory
X-KDE-PluginKeyword=plasma_scriptengine_ruby/applet.rb
X-Plasma-API=ruby-script
X-Plasma-ComponentTypes=Applet

View file

@ -1,150 +0,0 @@
[Desktop Entry]
Name=Ruby Widget
Name[ar]=ودجة روبي
Name[ast]=Elementu gráficu en Ruby
Name[be@latin]=Widžet u movie Ruby
Name[bg]=Джаджа на Ruby
Name[bn]=ি
Name[bn_IN]=Ruby
Name[bs]=Ruby grafička kontrola
Name[ca]=Estri Ruby
Name[ca@valencia]=Estri Ruby
Name[cs]=Ruby widget
Name[csb]=Interfejs Ruby
Name[da]=Ruby-widget
Name[de]=Ruby-Miniprogramm
Name[el]=Συστατικό Ruby
Name[en_GB]=Ruby Widget
Name[eo]=Ruby-fenestraĵo
Name[es]=Elemento gráfico en Ruby
Name[et]=Ruby vidin
Name[eu]=Ruby trepeta
Name[fi]=Ruby-sovelma
Name[fr]=Composant graphique Ruby
Name[fy]=Ruby widget
Name[ga]=Giuirléid Ruby
Name[gl]=Widget escrito en Ruby
Name[gu]= િ
Name[he]=ווידג׳ט של Ruby
Name[hi]= ि
Name[hne]= ि
Name[hr]=Ruby widget
Name[hu]=Ruby-elem
Name[ia]=Elemento graphic (Widget) de Ruby
Name[id]=Widget Ruby
Name[is]=Ruby græja
Name[ja]=Ruby
Name[kk]=Ruby бөлшегі
Name[km]=
Name[kn]=ಿ ಿ (ಿ)
Name[ko]=
Name[ku]=Alava Ruby
Name[lt]=Ruby valdiklis
Name[lv]=Ruby sīkrīks
Name[ml]=ി ി
Name[mr]=Ruby ि
Name[nb]=Ruby-element
Name[nds]=Ruby-Lüttprogramm
Name[nl]=Ruby-widget
Name[nn]=Ruby-element
Name[or]=ି ି
Name[pa]= ਿ
Name[pl]=Element interfejsu w języku Ruby
Name[pt]=Elemento em Ruby
Name[pt_BR]=Widget Ruby
Name[ro]=Control Ruby
Name[ru]=Виджет на языке Ruby
Name[si]=Ruby
Name[sk]=Ruby widget
Name[sl]=Gradnik v Ruby
Name[sr]=рубијевски виџет
Name[sr@ijekavian]=рубијевски виџет
Name[sr@ijekavianlatin]=ruby vidžet
Name[sr@latin]=ruby vidžet
Name[sv]=Grafisk Ruby-komponent
Name[ta]=Ruby Widget
Name[tg]=Илова ба Ruby
Name[th]=
Name[tr]=Ruby Gereci
Name[ug]=Ruby ۋىجېتى
Name[uk]=Віджет Ruby
Name[wa]=Ahesse Ruby
Name[x-test]=xxRuby Widgetxx
Name[zh_CN]=Ruby
Name[zh_TW]=Ruby
Comment=Native Plasma widget written in Ruby
Comment[ar]=وجة بلازما أصلية مكتوبة بروبي
Comment[ast]=Elementu gráficu nativu de Plasma escrito en Ruby
Comment[be@latin]=Rodny widžet systemy Plasma, napisany ŭ movie Ruby
Comment[bg]=Оригинална джаджа за Plasma, написана на Ruby
Comment[bs]=Samosvojni plazma grafička kontrola napisana u Ruby-ju
Comment[ca]=Estri nadiu del Plasma escrit en Ruby
Comment[ca@valencia]=Estri nadiu del Plasma escrit en Ruby
Comment[cs]=Nativní plasmoid napsaný v Ruby
Comment[da]=Ægte Plasma-widget skrevet i Ruby
Comment[de]=Echtes Plasma-Programm, geschrieben in Ruby
Comment[el]=Εγγενές συστατικό Plasma γραμμένο σε Ruby
Comment[en_GB]=Native Plasma widget written in Ruby
Comment[es]=Elemento gráfico nativo de Plasma escrito en Ruby
Comment[et]=Rubys kirjutatud Plasma vidin
Comment[eu]=Jatorrizko Plasma trepeta, Ruby lengoaian idatzia
Comment[fi]=Natiivi, Ruby-pohjainen Plasma-sovelma
Comment[fr]=Composant graphique natif de Plasma écrit en Ruby
Comment[fy]=Plasma widget skreaun yn Ruby
Comment[ga]=Giuirléid dhúchasach Plasma scríofa i Ruby
Comment[gl]=Widget nativo de Plasma escrito en Ruby
Comment[gu]= િ
Comment[he]=ווידג׳ט Plasma הנכתב ב־Ruby
Comment[hi]= ि ि ि
Comment[hne]= ि ि ि
Comment[hr]=Izvorna Plasma widget napisana u Rubyu
Comment[hu]=Plasma-elem Ruby nyelven
Comment[ia]=Elemento graphic (widget) native de Plasma scribite in Ruby
Comment[id]=Widget Plasma asli yang ditulis dalam Ruby
Comment[is]=Upprunabundin Plasma græja skrifuð í Ruby
Comment[ja]=Ruby Plasma
Comment[kk]=Ruby-дег жазылған Plasma интерфейс бөлшегі
Comment[km]= Ruby
Comment[kn]=ಿಿ ಿ (ಿ)
Comment[ko]= Plasma
Comment[lt]=Nuosavas Plasma valdiklis parašytas Ruby kalba
Comment[lv]=Plasma sīkrīks, rakstīts Ruby
Comment[ml]=ിി ിിി ി
Comment[mr]=Ruby ि Plasma ि
Comment[nb]=Plasmaelement for dette systemet, skrevet i Ruby
Comment[nds]=En orginaal Plasma-Lüttprogramm, schreven in Ruby
Comment[nl]=Plasma-widget geschreven in Ruby
Comment[nn]=Lokalt Plasma-element skrive i Ruby
Comment[or]=Ruby ି ି
Comment[pa]= ਿ ਿ ਿ ਿ
Comment[pl]=Element interfejsu Plazmy napisany w języku Ruby
Comment[pt]=Elemento nativo do Plasma feito em Ruby
Comment[pt_BR]=Widget nativo do Plasma, escrito em Ruby
Comment[ro]=Miniaplicație Plasma scrisă în Ruby
Comment[ru]=Виджет Plasma, написанный на языке Ruby
Comment[si]=Native Plasma widget written in Ruby
Comment[sk]=Natívny plasma widget napísaný v Ruby
Comment[sl]=Lastni gradnik za Plasmo, ki je napisan v Rubyu
Comment[sr]=Самосвојни плазма виџет написан у рубију
Comment[sr@ijekavian]=Самосвојни плазма виџет написан у рубију
Comment[sr@ijekavianlatin]=Samosvojni plasma vidžet napisan u Rubyju
Comment[sr@latin]=Samosvojni plasma vidžet napisan u Rubyju
Comment[sv]=Inbyggd grafisk Plasma-komponent skriven i Ruby
Comment[ta]=Native Plasma widget written in Ruby
Comment[tg]=Модуль Plasma, написанный на языке JavaScript
Comment[th]=
Comment[tr]=Ruby ile yazılmış gerçek Plasma gereci
Comment[ug]=Ruby بىلەن يېزىلغان ئەسلى Plasma widget
Comment[uk]=Віджет Плазми, написаний на Ruby
Comment[wa]=Ahesse askepieye po Plasma eyet scrîte e Ruby
Comment[x-test]=xxNative Plasma widget written in Rubyxx
Comment[zh_CN]=使 Ruby Plasma
Comment[zh_TW]= Ruby Plasma
X-KDE-ServiceTypes=Plasma/ScriptEngine
Type=Service
Icon=text-x-script
X-KDE-Library=krubypluginfactory
X-KDE-PluginKeyword=plasma_scriptengine_ruby/data_engine.rb
X-EngineName=ruby-dataengine-script
X-Plasma-API=ruby-script
X-Plasma-ComponentTypes=DataEngine

View file

@ -1,33 +0,0 @@
add_subdirectory(dashboard)
project(plasma-webapplet)
set(webapplet_SRCS
webpage.cpp webapplet.cpp plasmawebapplet.cpp plasmajs.cpp webapplet_plugin.cpp)
kde4_add_plugin(plasma_appletscriptengine_webapplet ${webapplet_SRCS})
target_link_libraries(plasma_appletscriptengine_webapplet ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS} ${QT_QTWEBKIT_LIBRARY} )
install(TARGETS plasma_appletscriptengine_webapplet DESTINATION ${PLUGIN_INSTALL_DIR})
set(webappletpackage_SRCS
webapplet_package.cpp)
kde4_add_plugin(plasma_packagestructure_web ${webappletpackage_SRCS})
target_link_libraries(plasma_packagestructure_web ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS} ${QT_QTWEBKIT_LIBRARY} )
install(TARGETS plasma_packagestructure_web DESTINATION ${PLUGIN_INSTALL_DIR})
set(dashboardapplet_SRCS
webpage.cpp webapplet.cpp dashboardapplet.cpp bundle.cpp dashboardjs.cpp)
kde4_add_plugin(plasma_appletscriptengine_dashboard ${dashboardapplet_SRCS})
target_link_libraries(plasma_appletscriptengine_dashboard ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS} ${QT_QTWEBKIT_LIBRARY} )
install(TARGETS plasma_appletscriptengine_dashboard DESTINATION ${PLUGIN_INSTALL_DIR})
set(bundlepackage_SRCS
bundle.cpp dashboard_plugin.cpp)
kde4_add_plugin(plasma_packagestructure_dashboard ${bundlepackage_SRCS})
target_link_libraries(plasma_packagestructure_dashboard ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS} ${QT_QTWEBKIT_LIBRARY} )
install(TARGETS plasma_packagestructure_dashboard DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES plasma-scriptengine-applet-web.desktop
plasma-scriptengine-applet-dashboard.desktop
plasma-packagestructure-dashboard.desktop
plasma-packagestructure-web.desktop
DESTINATION ${SERVICES_INSTALL_DIR})

View file

@ -1,2 +0,0 @@
#!/bin/bash
$XGETTEXT *.cpp -o $podir/plasma_appletscriptengine_dashboard.pot

View file

@ -1,2 +0,0 @@
Document about dashboard stuff
http://developer.apple.com/documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/Dashboard_ProgTopics.pdf

View file

@ -1,430 +0,0 @@
/*
Copyright (c) 2007 Zack Rusin <zack@kde.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "bundle.h"
#include <QBuffer>
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QtCore/qxmlstream.h>
#include <KDebug>
#include <KIO/CopyJob>
#include <KIO/Job>
#include <Plasma/PackageMetadata>
#include <Plasma/Package>
void recursive_print(const KArchiveDirectory *dir, const QString &path)
{
const QStringList l = dir->entries();
QStringList::const_iterator it = l.constBegin();
for (; it != l.end(); ++it)
{
const KArchiveEntry* entry = dir->entry((*it));
printf("mode=%07o %s %s size: %lld pos: %lld %s%s isdir=%d%s",
entry->permissions(),
entry->user().toLatin1().constData(),
entry->group().toLatin1().constData(),
entry->isDirectory() ? 0 : ((KArchiveFile*)entry)->size(),
entry->isDirectory() ? 0 : ((KArchiveFile*)entry)->position(),
path.toLatin1().constData(),
(*it).toLatin1().constData(), entry->isDirectory(),
entry->symLinkTarget().isEmpty() ? "" :
QString(" symlink: %1").arg(
entry->symLinkTarget()).toLatin1().constData());
//if (!entry->isDirectory()) printf("%d",
// ((KArchiveFile*)entry)->size());
printf("\n");
if (entry->isDirectory())
recursive_print((KArchiveDirectory *)entry, path+(*it)+'/');
}
}
static const KArchiveDirectory *recursiveFind(const KArchiveDirectory *dir)
{
const QStringList l = dir->entries();
QStringList::const_iterator it;
for (it = l.constBegin(); it != l.constEnd(); ++it) {
const KArchiveEntry* entry = dir->entry((*it));
if (entry->isDirectory()) {
QString name = *it;
if (name.startsWith(QLatin1String("__MACOSX"))) {
//skip this
continue;
} else if (name.endsWith(QLatin1String(".wdgt"))) {
//got our bad boy
return static_cast<const KArchiveDirectory*>(entry);
} else {
const KArchiveDirectory *fd =
recursiveFind(static_cast<const KArchiveDirectory*>(entry));
if (fd)
return fd;
}
}
}
return 0;
}
Bundle::Bundle(const QString &path)
: PackageStructure(0, "MacDashboard"),
m_isValid(false),
m_width(0), m_height(0)
{
setContentsPrefixPaths(QStringList());
QFile f(path);
f.open(QIODevice::ReadOnly);
m_data = f.readAll();
f.close();
initTempDir();
open();
}
Bundle::Bundle(const QByteArray &data)
: PackageStructure(0, "MacDashboard"),
m_isValid(false),
m_width(0),
m_height(0)
{
setContentsPrefixPaths(QStringList());
m_data = data;
initTempDir();
open();
}
Bundle::Bundle(QObject *parent, QVariantList args)
: PackageStructure(parent, "MacDashboard"),
m_isValid(false),
m_tempDir(0),
m_width(0),
m_height(0)
{
Q_UNUSED(args)
setContentsPrefixPaths(QStringList());
}
Bundle::~Bundle()
{
close();
}
void Bundle::setData(const QByteArray &data)
{
m_data = data;
close();
open();
}
QByteArray Bundle::data() const
{
return m_data;
}
bool Bundle::open()
{
if (!m_tempDir) {
initTempDir();
}
if (m_data.isEmpty()) {
return false;
}
QBuffer buffer(&m_data);
KZip zip(&buffer);
if (!zip.open(QIODevice::ReadOnly)) {
qWarning("Couldn't open the bundle!");
return false;
}
const KArchiveDirectory *dir = zip.directory();
const KArchiveDirectory *foundDir = recursiveFind(dir);
if (!foundDir) {
qWarning("not a bundle");
m_isValid = false;
zip.close();
return 0;
}
m_isValid = extractArchive(foundDir, QLatin1String(""));
qDebug()<<"Dir = "<<foundDir->name() << m_isValid;
if (m_isValid) {
setPath(m_tempDir->name());
}
zip.close();
return m_isValid;
}
bool Bundle::close()
{
bool ret = m_tempDir;
delete m_tempDir;
m_tempDir = 0;
return ret;
}
bool Bundle::extractArchive(const KArchiveDirectory *dir, const QString &path)
{
const QStringList l = dir->entries();
QStringList::const_iterator it;
for (it = l.constBegin(); it != l.constEnd(); ++it) {
const KArchiveEntry* entry = dir->entry((*it));
QString fullPath = QString("%1/%2").arg(path).arg(*it);
if (entry->isDirectory()) {
QString outDir = QString("%1%2").arg(m_tempDir->name()).arg(path);
QDir qdir(outDir);
qdir.mkdir(*it);
extractArchive(static_cast<const KArchiveDirectory*>(entry), fullPath);
} else if (entry->isFile()) {
QString outName = QString("%1%2").arg(m_tempDir->name()).arg(fullPath.remove(0, 1));
//qDebug()<<"-------- "<<outName;
QFile f(outName);
if (!f.open(QIODevice::WriteOnly)) {
qWarning("Couldn't create %s", qPrintable(outName));
continue;
}
const KArchiveFile *archiveFile = static_cast<const KArchiveFile*>(entry);
f.write(archiveFile->data());
f.close();
} else {
qWarning("Unidentified entry at %s", qPrintable(fullPath));
}
}
return true;
}
void Bundle::pathChanged()
{
//qDebug() << "path changed";
m_isValid = extractInfo();
}
bool Bundle::extractInfo()
{
QString plistLocation = QString("%1Info.plist").arg(path());
QString configXml = QString("%1config.xml").arg(path());
if (QFile::exists(plistLocation)) {
//qDebug() << "doing plist";
return parsePlist(plistLocation);
} else if (QFile::exists(configXml)) {
return parseConfigXml(configXml);
}
return false;
}
bool Bundle::parsePlist(const QString &loc)
{
QFile f(loc);
if (!f.open(QIODevice::ReadOnly)) {
qWarning("Couldn't open info file: '%s'", qPrintable(loc));
return false;
}
QMap<QString, QString> infoMap;
QString str = f.readAll();
QXmlStreamReader reader(str);
while (!reader.atEnd()) {
reader.readNext();
// do processing
if (reader.isStartElement()) {
//qDebug() << reader.name().toString();
if (reader.name() == "key") {
QString key, value;
reader.readNext();
if (reader.isCharacters()) {
QString str = reader.text().toString();
str = str.trimmed();
if (!str.isEmpty())
key = str;
}
if (key.isEmpty())
continue;
while (!reader.isStartElement())
reader.readNext();
if (reader.name() != "string" &&
reader.name() != "integer") {
qDebug()<<"Unrecognized val "<<reader.name().toString()
<<" for key "<<key;
continue;
}
reader.readNext();
if (reader.isCharacters()) {
QString str = reader.text().toString();
str = str.trimmed();
if (!str.isEmpty())
value = str;
}
//qDebug()<<"key = "<<key<<", value = "<<value;
infoMap.insert(key, value);
}
}
}
QMap<QString, QString>::const_iterator itr;
for (itr = infoMap.constBegin(); itr != infoMap.constEnd(); ++itr) {
kDebug() << itr.key() << itr.value();
if (itr.key() == QLatin1String("CFBundleIdentifier")) {
m_bundleId = itr.value();
} else if (itr.key() == QLatin1String("CFBundleName")) {
m_description = itr.value();
} else if (itr.key() == QLatin1String("CFBundleDisplayName")) {
m_name = itr.value();
} else if (itr.key() == QLatin1String("CFBundleVersion")) {
m_version = itr.value();
} else if (itr.key() == QLatin1String("CloseBoxInsetX")) {
} else if (itr.key() == QLatin1String("CloseBoxInsetY")) {
} else if (itr.key() == QLatin1String("Height")) {
m_height = itr.value().toInt();
} else if (itr.key() == QLatin1String("Width")) {
m_width = itr.value().toInt();
} else if (itr.key() == QLatin1String("MainHTML")) {
m_htmlLocation = QString("%1%2").arg(path()).arg(itr.value());
addFileDefinition("mainscript", itr.value(), i18n("Main Webpage"));
} else {
qDebug()<<"Unrecognized key = "<<itr.key();
}
}
m_iconLocation = QString("%1Icon.png").arg(path());
kDebug() << path();
addDirectoryDefinition("root", "/", i18n("Root HTML directory"));
//qDebug()<<"name = "<<m_name;
//qDebug()<<"id = "<<m_bundleId;
//qDebug()<<"html = "<<m_htmlLocation;
//qDebug()<<"icon = "<<m_iconLocation;
return !m_bundleId.isEmpty();
}
bool Bundle::installPackage(const QString &archivePath, const QString &packageRoot)
{
//kDebug() << "??????????????" << archivePath << packageRoot;
QFile f(archivePath);
f.open(QIODevice::ReadOnly);
m_data = f.readAll();
f.close();
open();
if (m_isValid) {
m_tempDir->setAutoRemove(false);
QString pluginName = "dashboard_" + m_bundleId;
//kDebug() << "valid, so going to move it in to" << pluginName;
KIO::CopyJob* job = KIO::move(m_tempDir->name(), QString(packageRoot + pluginName), KIO::HideProgressInfo);
m_isValid = job->exec();
if (m_isValid) {
//kDebug() << "still so good ... registering";
Plasma::PackageMetadata data;
data.setName(m_name);
data.setDescription(m_description);
data.setPluginName(pluginName);
data.setImplementationApi("dashboard");
Plasma::Package::registerPackage(data, m_iconLocation);
}
}
if (!m_isValid) {
// make sure we clean up after ourselves afterwards on failure
m_tempDir->setAutoRemove(true);
}
return m_isValid;
}
bool Bundle::parseConfigXml(const QString &loc)
{
QFile f(loc);
if (!f.open(QIODevice::ReadOnly)) {
qWarning("Couldn't open info file: '%s'", qPrintable(loc));
return false;
}
qWarning("FIXME: Widgets 1.0 not implemented");
return false;
}
void Bundle::initTempDir()
{
m_tempDir = new KTempDir();
//make it explicit
m_tempDir->setAutoRemove(true);
}
QString Bundle::bundleId() const
{
return m_bundleId;
}
QString Bundle::name() const
{
return m_name;
}
QString Bundle::version() const
{
return m_version;
}
QString Bundle::description() const
{
return m_description;
}
int Bundle::width() const
{
return m_width;
}
int Bundle::height() const
{
return m_height;
}
QString Bundle::htmlLocation() const
{
return m_htmlLocation;
}
QString Bundle::iconLocation() const
{
return m_iconLocation;
}
bool Bundle::isValid() const
{
return m_isValid;
}

Some files were not shown because too many files have changed in this diff Show more