[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/runtime/plasma/scriptengines/javascript/plasmoid
From:       Marco Martin <notmart () gmail ! com>
Date:       2010-10-13 16:12:44
Message-ID: 20101013161244.12FC0AC896 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1185532 by mart:

first important part for the ml bindings merge:
make appletInterface more generic it could work with QML too
simplejavascriptapplet inherits from an abstract ckass that provides just the \
virtuals of functions needed by appletinterface so a different scriptengine \
implementation can be used as well.

The behaviour of the current js bindings should be completely unchanged.


 A             abstractjsappletscript.cpp   [License: LGPL (v2+)]
 A             abstractjsappletscript.h   [License: LGPL (v2+)]
 M  +3 -2      appletauthorization.cpp  
 M  +6 -2      appletauthorization.h  
 M  +22 -12    appletinterface.cpp  
 M  +25 -15    appletinterface.h  
 A             jsappletinterface.cpp   [License: LGPL (v2)]
 M  +1 -1      simplejavascriptapplet.cpp  
 M  +2 -2      simplejavascriptapplet.h  


--- trunk/KDE/kdebase/runtime/plasma/scriptengines/javascript/plasmoid/appletauthorization.cpp \
#1185531:1185532 @@ -19,9 +19,10 @@
 #include <KAuthorized>
 
 #include "appletauthorization.h"
-#include "simplejavascriptapplet.h"
+#include <Plasma/AppletScript>
+#include <Plasma/Applet>
 
-AppletAuthorization::AppletAuthorization(SimpleJavaScriptApplet *scriptEngine)
+AppletAuthorization::AppletAuthorization(Plasma::AppletScript *scriptEngine)
     : Authorization(),
       m_scriptEngine(scriptEngine)
 {
--- trunk/KDE/kdebase/runtime/plasma/scriptengines/javascript/plasmoid/appletauthorization.h \
#1185531:1185532 @@ -21,19 +21,23 @@
 
 #include "authorization.h"
 
+namespace Plasma {
+    class AppletScript;
+}
+
 class SimpleJavaScriptApplet;
 
 class AppletAuthorization : public Authorization
 {
 public:
-    AppletAuthorization(SimpleJavaScriptApplet *scriptEngine);
+    AppletAuthorization(Plasma::AppletScript *scriptEngine);
 
     bool authorizeRequiredExtension(const QString &extension);
     bool authorizeOptionalExtension(const QString &extension);
     bool authorizeExternalExtensions();
 
 private:
-    SimpleJavaScriptApplet *m_scriptEngine;
+    Plasma::AppletScript *m_scriptEngine;
 };
 
 #endif
--- trunk/KDE/kdebase/runtime/plasma/scriptengines/javascript/plasmoid/appletinterface.cpp \
#1185531:1185532 @@ -1,5 +1,7 @@
 /*
  *   Copyright 2008 Chani Armitage <chani@kde.org>
+ *   Copyright 2008, 2009 Aaron Seigo <aseigo@kde.org>
+ *   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 as
@@ -36,13 +38,14 @@
 
 Q_DECLARE_METATYPE(AppletInterface*)
 
-AppletInterface::AppletInterface(SimpleJavaScriptApplet *parent)
+AppletInterface::AppletInterface(AbstractJsAppletScript *parent)
     : QObject(parent),
       m_appletScriptEngine(parent),
       m_actionSignals(0)
 {
     connect(this, SIGNAL(releaseVisualFocus()), applet(), \
                SIGNAL(releaseVisualFocus()));
     connect(this, SIGNAL(configNeedsSaving()), applet(), \
SIGNAL(configNeedsSaving())); +    connect(applet(), \
SIGNAL(immutabilityChanged(Plasma::ImmutabilityType)), this, \
SIGNAL(immutableChanged()));  }
 
 AppletInterface::~AppletInterface()
@@ -120,11 +123,25 @@
     m_appletScriptEngine->setConfigurationRequired(needsConfiguring, reason);
 }
 
+#ifdef USE_JS_SCRIPTENGINE
+
 void AppletInterface::update(const QRectF &rect)
 {
     applet()->update(rect);
 }
 
+QGraphicsLayout *AppletInterface::layout() const
+{
+    return applet()->layout();
+}
+
+void AppletInterface::setLayout(QGraphicsLayout *layout)
+{
+    applet()->setLayout(layout);
+}
+
+#endif
+
 QString AppletInterface::activeConfig() const
 {
     return m_currentConfig.isEmpty() ? "main" : m_currentConfig;
@@ -295,16 +312,6 @@
     applet()->setPreferredSize(w,h);
 }
 
-QGraphicsLayout *AppletInterface::layout() const
-{
-    return applet()->layout();
-}
-
-void AppletInterface::setLayout(QGraphicsLayout *layout)
-{
-    applet()->setLayout(layout);
-}
-
 bool AppletInterface::immutable() const
 {
     return applet()->immutability() != Plasma::Mutable;
@@ -363,13 +370,14 @@
     return m_appletScriptEngine->extender();
 }
 
+
 void AppletInterface::gc()
 {
     QTimer::singleShot(0, m_appletScriptEngine, SLOT(collectGarbage()));
 }
 
 
-PopupAppletInterface::PopupAppletInterface(SimpleJavaScriptApplet *parent)
+PopupAppletInterface::PopupAppletInterface(AbstractJsAppletScript *parent)
     : AppletInterface(parent)
 {
 }
@@ -424,4 +432,6 @@
     return popupApplet()->graphicsWidget();
 }
 
+#ifndef USE_JS_SCRIPTENGINE
 #include "appletinterface.moc"
+#endif
--- trunk/KDE/kdebase/runtime/plasma/scriptengines/javascript/plasmoid/appletinterface.h \
#1185531:1185532 @@ -1,6 +1,7 @@
 /*
  *   Copyright 2008 Chani Armitage <chani@kde.org>
  *   Copyright 2008, 2009 Aaron Seigo <aseigo@kde.org>
+ *   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 as
@@ -31,10 +32,10 @@
 #include <Plasma/DataEngine>
 #include <Plasma/Theme>
 
-#include "simplejavascriptapplet.h"
+#include "abstractjsappletscript.h"
 
 class QAction;
-class SimpleJavaScriptApplet;
+class QmlAppletScript;
 class QSignalMapper;
 class QSizeF;
 
@@ -63,23 +64,25 @@
     Q_ENUMS(IntervalAlignment)
     Q_ENUMS(ThemeColors)
     Q_PROPERTY(AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE \
                setAspectRatioMode)
-    Q_PROPERTY(FormFactor formFactor READ formFactor)
-    Q_PROPERTY(Location location READ location)
-    Q_PROPERTY(QString currentActivity READ currentActivity)
+    Q_PROPERTY(FormFactor formFactor READ formFactor NOTIFY formFactorChanged)
+    Q_PROPERTY(Location location READ location NOTIFY locationChanged)
+    Q_PROPERTY(QString currentActivity READ currentActivity NOTIFY contextChanged)
     Q_PROPERTY(bool shouldConserveResources READ shouldConserveResources)
     Q_PROPERTY(QString activeConfig WRITE setActiveConfig READ activeConfig)
     Q_PROPERTY(bool busy WRITE setBusy READ isBusy)
     Q_PROPERTY(BackgroundHints backgroundHints WRITE setBackgroundHints READ \
                backgroundHints)
-    Q_PROPERTY(QGraphicsLayout *layout WRITE setLayout READ layout)
-    Q_PROPERTY(bool immutable READ immutable)
+    Q_PROPERTY(bool immutable READ immutable NOTIFY immutableChanged)
     Q_PROPERTY(bool userConfiguring READ userConfiguring) // @since 4.5
-    Q_PROPERTY(int apiVersion READ apiVersion)
+    Q_PROPERTY(int apiVersion READ apiVersion CONSTANT)
     Q_PROPERTY(QRectF rect READ rect)
     Q_PROPERTY(QSizeF size READ size)
+#ifdef USE_JS_SCRIPTENGINE
+    Q_PROPERTY(QGraphicsLayout *layout WRITE setLayout READ layout)
     Q_PROPERTY(QObject *sender READ sender)
+#endif
 
 public:
-    AppletInterface(SimpleJavaScriptApplet *parent);
+    AppletInterface(AbstractJsAppletScript *parent);
     ~AppletInterface();
 
 //------------------------------------------------------------------
@@ -255,8 +258,6 @@
 
     Q_INVOKABLE void setPreferredSize(qreal w, qreal h);
 
-    Q_INVOKABLE void update(const QRectF &rect = QRectF());
-
     Q_INVOKABLE QString activeConfig() const;
 
     Q_INVOKABLE void setActiveConfig(const QString &name);
@@ -275,11 +276,15 @@
 
     Q_INVOKABLE Plasma::Extender *extender() const;
 
+#ifdef USE_JS_SCRIPTENGINE
+    Q_INVOKABLE void update(const QRectF &rect = QRectF());
+    QGraphicsLayout *layout() const;
+    void setLayout(QGraphicsLayout *);
+#endif
+
     Plasma::DataEngine *dataEngine(const QString &name);
 
     QList<QAction*> contextualActions() const;
-    QGraphicsLayout *layout() const;
-    void setLayout(QGraphicsLayout *);
     bool immutable() const;
     bool userConfiguring() const;
     int apiVersion() const;
@@ -291,8 +296,13 @@
     void releaseVisualFocus();
     void configNeedsSaving();
 
+    void formFactorChanged();
+    void locationChanged();
+    void contextChanged();
+    void immutableChanged();
+
 protected:
-    SimpleJavaScriptApplet *m_appletScriptEngine;
+    AbstractJsAppletScript *m_appletScriptEngine;
 
 private:
     QSet<QString> m_actions;
@@ -309,7 +319,7 @@
     Q_PROPERTY(QGraphicsWidget *popupWidget READ popupWidget WRITE setPopupWidget)
 
 public:
-    PopupAppletInterface(SimpleJavaScriptApplet *parent);
+    PopupAppletInterface(AbstractJsAppletScript *parent);
 
     void setPopupIcon(const QIcon &icon);
     QIcon popupIcon();
--- trunk/KDE/kdebase/runtime/plasma/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp \
#1185531:1185532 @@ -98,7 +98,7 @@
 QHash<QString, Plasma::Animator::Animation> SimpleJavaScriptApplet::s_animationDefs;
 
 SimpleJavaScriptApplet::SimpleJavaScriptApplet(QObject *parent, const QVariantList \
                &args)
-    : Plasma::AppletScript(parent)
+    : AbstractJsAppletScript(parent)
 {
     Q_UNUSED(args);
 //    kDebug() << "Script applet launched, args" << applet()->startupArguments();
--- trunk/KDE/kdebase/runtime/plasma/scriptengines/javascript/plasmoid/simplejavascriptapplet.h \
#1185531:1185532 @@ -22,10 +22,10 @@
 #include <QScriptValue>
 
 #include <Plasma/Animator>
-#include <Plasma/AppletScript>
 #include <Plasma/DataEngine>
 
 #include "simplebindings/uiloader.h"
+#include "abstractjsappletscript.h"
 
 class QScriptContext;
 class QScriptEngine;
@@ -38,7 +38,7 @@
     class ExtenderItem;
 } // namespace Plasma
 
-class SimpleJavaScriptApplet : public Plasma::AppletScript
+class SimpleJavaScriptApplet : public AbstractJsAppletScript
 {
     Q_OBJECT
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic