add uiloader to the gang, add the layouts to API, but now i have a new challenge ... layouts aren't qobjects. oh nos.
svn path=/trunk/KDE/kdebase/workspace/plasma/scriptengines/javascript/; revision=905832
This commit is contained in:
parent
299ca62104
commit
b27afeb94d
@ -1,6 +1,7 @@
|
||||
set(simple_javascript_engine_SRCS
|
||||
simplejavascriptapplet.cpp
|
||||
appletinterface.cpp
|
||||
uiloader.cpp
|
||||
qtgui/font.cpp
|
||||
qtgui/graphicsitem.cpp
|
||||
qtgui/painter.cpp
|
||||
|
@ -381,6 +381,7 @@ void SimpleJavaScriptApplet::setupObjects()
|
||||
qScriptRegisterMetaType<DataEngine::Data>(m_engine, qScriptValueFromData, 0, QScriptValue());
|
||||
|
||||
installWidgets(m_engine);
|
||||
installLayouts(m_engine);
|
||||
}
|
||||
|
||||
QString SimpleJavaScriptApplet::findDataResource(const QString &filename)
|
||||
@ -536,7 +537,8 @@ void SimpleJavaScriptApplet::installWidgets(QScriptEngine *engine)
|
||||
QScriptValue SimpleJavaScriptApplet::createWidget(QScriptContext *context, QScriptEngine *engine)
|
||||
{
|
||||
if (context->argumentCount() > 1) {
|
||||
return context->throwError("Create widget takes one argument");
|
||||
//FIXME: 4.3: i18nc
|
||||
return context->throwError("CreateWidget takes one argument");
|
||||
}
|
||||
|
||||
QGraphicsWidget *parent = 0;
|
||||
@ -562,6 +564,56 @@ QScriptValue SimpleJavaScriptApplet::createWidget(QScriptContext *context, QScri
|
||||
return fun;
|
||||
}
|
||||
|
||||
void SimpleJavaScriptApplet::installLayouts(QScriptEngine *engine)
|
||||
{
|
||||
QScriptValue globalObject = engine->globalObject();
|
||||
UiLoader loader;
|
||||
|
||||
QStringList layouts = loader.availableLayouts();
|
||||
for (int i=0; i < layouts.size(); ++i) {
|
||||
QScriptValue fun = engine->newFunction(createLayout);
|
||||
QScriptValue name = engine->toScriptValue(layouts[i]);
|
||||
fun.setProperty(QString("functionName"), name,
|
||||
QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
|
||||
fun.setProperty(QString("prototype"), createPrototype(engine, name.toString()));
|
||||
|
||||
globalObject.setProperty(layouts[i], fun);
|
||||
}
|
||||
}
|
||||
|
||||
QScriptValue SimpleJavaScriptApplet::createLayout(QScriptContext *context, QScriptEngine *engine)
|
||||
{
|
||||
return context->throwError("CreateLayout is currently broken.");
|
||||
/*
|
||||
if (context->argumentCount() > 1) {
|
||||
//FIXME: 4.3: i18nc
|
||||
return context->throwError("CreateLayout takes one argument");
|
||||
}
|
||||
|
||||
QGraphicsWidget *parent = 0;
|
||||
if (context->argumentCount()) {
|
||||
parent = qscriptvalue_cast<QGraphicsWidget*>(context->argument(0));
|
||||
|
||||
if (!parent) {
|
||||
return context->throwError(i18n("The parent must be a QGraphicsWidget"));
|
||||
}
|
||||
}
|
||||
|
||||
QString self = context->callee().property("functionName").toString();
|
||||
UiLoader loader;
|
||||
QGraphicsLayout *w = loader.createLayout(self, parent);
|
||||
|
||||
if (!w) {
|
||||
return QScriptValue();
|
||||
}
|
||||
|
||||
QScriptValue fun = engine->newQObject(w);
|
||||
fun.setPrototype(context->callee().property("prototype"));
|
||||
|
||||
return fun;
|
||||
*/
|
||||
}
|
||||
|
||||
QScriptValue SimpleJavaScriptApplet::print(QScriptContext *context, QScriptEngine *engine)
|
||||
{
|
||||
if (context->argumentCount() != 1) {
|
||||
|
@ -65,7 +65,9 @@ private:
|
||||
static QScriptValue newPlasmaFrameSvg(QScriptContext *context, QScriptEngine *engine);
|
||||
|
||||
void installWidgets( QScriptEngine *engine );
|
||||
void installLayouts( QScriptEngine *engine );
|
||||
static QScriptValue createWidget(QScriptContext *context, QScriptEngine *engine);
|
||||
static QScriptValue createLayout(QScriptContext *context, QScriptEngine *engine);
|
||||
static QScriptValue print(QScriptContext *context, QScriptEngine *engine);
|
||||
static QScriptValue createPrototype( QScriptEngine *engine, const QString &name );
|
||||
|
||||
|
@ -23,27 +23,27 @@
|
||||
#include <QGraphicsLinearLayout>
|
||||
#include <QStringList>
|
||||
|
||||
#include "widgets/busywidget.h"
|
||||
#include "widgets/checkbox.h"
|
||||
#include "widgets/combobox.h"
|
||||
#include "widgets/flashinglabel.h"
|
||||
#include "widgets/frame.h"
|
||||
#include "widgets/groupbox.h"
|
||||
#include "widgets/iconwidget.h"
|
||||
#include "widgets/label.h"
|
||||
#include "widgets/lineedit.h"
|
||||
#include "widgets/meter.h"
|
||||
#include "widgets/pushbutton.h"
|
||||
#include "widgets/radiobutton.h"
|
||||
#include "widgets/scrollbar.h"
|
||||
#include "widgets/signalplotter.h"
|
||||
#include "widgets/slider.h"
|
||||
#include "widgets/svgwidget.h"
|
||||
#include "widgets/tabbar.h"
|
||||
#include "widgets/textedit.h"
|
||||
#include "widgets/toolbutton.h"
|
||||
#include "widgets/treeview.h"
|
||||
#include "widgets/webview.h"
|
||||
#include <Plasma/BusyWidget>
|
||||
#include <Plasma/CheckBox>
|
||||
#include <Plasma/ComboBox>
|
||||
#include <Plasma/FlashingLabel>
|
||||
#include <Plasma/Frame>
|
||||
#include <Plasma/GroupBox>
|
||||
#include <Plasma/IconWidget>
|
||||
#include <Plasma/Label>
|
||||
#include <Plasma/LineEdit>
|
||||
#include <Plasma/Meter>
|
||||
#include <Plasma/PushButton>
|
||||
#include <Plasma/RadioButton>
|
||||
#include <Plasma/ScrollBar>
|
||||
#include <Plasma/SignalPlotter>
|
||||
#include <Plasma/Slider>
|
||||
#include <Plasma/SvgWidget>
|
||||
#include <Plasma/TabBar>
|
||||
#include <Plasma/TextEdit>
|
||||
#include <Plasma/ToolButton>
|
||||
#include <Plasma/TreeView>
|
||||
#include <Plasma/WebView>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user