![]() |
Mixxx
|
00001 #include "qtscriptinterface.h" 00002 #include <QPushButton> 00003 00004 QtScriptInterface::QtScriptInterface(PlayInterface* pi) : m_pi(pi), 00005 m_engine() { 00006 00007 //QPushButton* steve = new QPushButton("Hello!", 0); 00008 //steve->setVisible(true); 00009 QScriptValue globalObject = m_engine.globalObject(); 00010 00011 QScriptValue pbfunc = m_engine.newFunction(newQPushButton); 00012 //fun.setProperty(QString("functionName"), engine->scriptValue("QPushButton")) 00013 globalObject.setProperty("QPushButton", pbfunc); 00014 globalObject.setProperty("Mixxx", m_engine.newQObject(this)); 00015 00016 //qWarning() << "Script: " << m_engine.evaluate("var bob = new QPushButton(\"Hello, world!\", 0); bob.setText(\"Hello!\"); bob.show()").toString(); 00017 //qWarning() << "Test: " << m_engine.evaluate("Mixxx.test()").toString(); 00018 //qWarning() << "Test2: " << m_engine.evaluate("Mixxx.getValue(\"[Master]\", \"crossfader\")").toString(); 00019 } 00020 00021 void QtScriptInterface::executeScript(const char* script, int process) { 00022 m_pi->setProcess(process); 00023 m_result = m_engine.evaluate(script).toString(); 00024 qWarning() << m_result; 00025 m_pi->clearProcess(); 00026 } 00027 00028 QString QtScriptInterface::getResult() { 00029 return m_result; 00030 } 00031 00032 QScriptValue QtScriptInterface::newQPushButton(QScriptContext *context, QScriptEngine *engine) 00033 { 00034 QScriptValue nobj = engine->newQObject(new QPushButton()); 00035 return nobj; 00036 } 00037 00038 void QtScriptInterface::test() { 00039 m_pi->test(); 00040 } 00041 00042 void QtScriptInterface::stop(int channel) { 00043 m_pi->stop(channel); 00044 } 00045 00046 void QtScriptInterface::play(int channel) { 00047 m_pi->play(channel); 00048 } 00049 00050 void QtScriptInterface::setTag(int tag) { 00051 m_pi->setTag(tag); 00052 } 00053 00054 void QtScriptInterface::clearTag() { 00055 m_pi->clearTag(); 00056 } 00057 00058 void QtScriptInterface::kill() { 00059 m_pi->kill(); 00060 } 00061 00062 void QtScriptInterface::killTag(int tag) { 00063 m_pi->killTag(tag); 00064 } 00065 00066 double QtScriptInterface::getValue(QString group, QString name) { 00067 return m_pi->getValue(group, name); 00068 } 00069 00070 void QtScriptInterface::startList(QString group, QString name) { 00071 m_pi->startList(group, name); 00072 } 00073 00074 void QtScriptInterface::startFade(QString group, QString name) { 00075 m_pi->startFade(group, name); 00076 } 00077 00078 void QtScriptInterface::point(int time, double value) { 00079 m_pi->fadePoint(time, value); 00080 } 00081 00082 void QtScriptInterface::endFade() { 00083 m_pi->endFade(); 00084 } 00085 00086 void QtScriptInterface::endList() { 00087 m_pi->endList(); 00088 } 00089 00090 void QtScriptInterface::playChannel1(int time, QString path) { 00091 m_pi->playChannel1(time, path); 00092 } 00093 00094 void QtScriptInterface::playChannel2(int time, QString path) { 00095 m_pi->playChannel2(time, path); 00096 }