2019-12-18 17:35:37 +08:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QDialog>
|
2019-12-04 15:51:46 +08:00
|
|
|
#include <QFile>
|
2019-12-14 10:04:17 +08:00
|
|
|
#include <QResource>
|
2019-12-04 15:51:46 +08:00
|
|
|
|
|
|
|
#include "context_manager.h"
|
2019-12-19 19:54:58 +08:00
|
|
|
#include "async/async_result.h"
|
2019-12-19 20:24:44 +08:00
|
|
|
#include "template/custom_callback.h"
|
2019-12-04 15:51:46 +08:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2019-12-18 17:35:37 +08:00
|
|
|
QApplication app(argc, argv);
|
|
|
|
{
|
|
|
|
QWidget *widget = new QWidget(nullptr, Qt::WindowType::Window);
|
|
|
|
widget->setWindowTitle(QString("Hello Doric"));
|
|
|
|
widget->resize(360, 640);
|
|
|
|
widget->show();
|
|
|
|
}
|
2019-12-04 16:44:30 +08:00
|
|
|
{
|
2019-12-04 17:39:41 +08:00
|
|
|
QResource resource(":/doric/Snake.js");
|
|
|
|
QFile *file = new QFile(resource.fileName());
|
2019-12-04 16:44:30 +08:00
|
|
|
file->open(QFile::ReadOnly | QFile::Text);
|
|
|
|
QTextStream in(file);
|
|
|
|
QString script = in.readAll();
|
|
|
|
file->close();
|
|
|
|
delete file;
|
|
|
|
|
2019-12-13 17:48:37 +08:00
|
|
|
QString *source = new QString("Snake.js");
|
2019-12-04 16:44:30 +08:00
|
|
|
Context *context = ContextManager::getInstance()->createContext(&script, source);
|
2019-12-06 19:47:59 +08:00
|
|
|
context->show();
|
2019-12-04 16:44:30 +08:00
|
|
|
context->init(180, 320);
|
|
|
|
delete source;
|
|
|
|
}
|
2019-12-04 15:51:46 +08:00
|
|
|
|
2019-12-19 20:24:44 +08:00
|
|
|
{
|
|
|
|
// code for test
|
|
|
|
QJsonValue *a = new QJsonValue();
|
|
|
|
AsyncResult<QJsonValue> *result = new AsyncResult<QJsonValue>(*a);
|
|
|
|
CustomCallback<QJsonValue> *callback = new CustomCallback<QJsonValue>();
|
|
|
|
result->setCallback(callback);
|
|
|
|
qDebug() << result->hasResult();
|
|
|
|
qDebug() << result->getResult();
|
|
|
|
}
|
2019-12-19 19:54:58 +08:00
|
|
|
|
2019-12-04 15:51:46 +08:00
|
|
|
return app.exec();
|
|
|
|
}
|