jint EXPORT_ME JAVA_FUNC(init)(JNIEnv* env, jobject thiz, jobject act, jobjectArray argsArray, jstring game_path_, jstring lib_path_, jstring app_path_, jstring abi, jstring abi_alt) { // getGlobalClasses(env); //set_check_len(3840538); activity_ = &act; env_ = env; argv[0] = "quake"; int argCount = (env)->GetArrayLength(argsArray); LOGI("argCount = %d", argCount); for (int i = 0; i < argCount; i++) { jstring string = (jstring)(env)->GetObjectArrayElement(argsArray, i); argv[argc] = (char *) (env)->GetStringUTFChars(string, 0); LOGI("arg = %s", argv[argc]); argc++; } game_path = (char *) (env)->GetStringUTFChars(game_path_, 0); lib_path = (char *) (env)->GetStringUTFChars(lib_path_, 0); app_path = (char *) (env)->GetStringUTFChars(app_path_, 0); android_abi = (char *) (env)->GetStringUTFChars(abi, 0); android_abi_alt = (char *) (env)->GetStringUTFChars(abi_alt, 0); LOGI("game_path = %s", getGamePath()); LOGI("lib_path = %s", getLibPath()); LOGI("app_path = %s", getAppPath()); LOGI("android_abi = %s", getAndroidAbi()); LOGI("android_abi_alt = %s", getAndroidAbiAlt()); chdir(getGamePath()); //self_crc_check((string(getLibPath()) + "/libjk3.so").c_str()); PortableInit(argc, argv); /* const char * p = env->GetStringUTFChars(graphics_dir,NULL); graphicpath = std::string(p); initControls(640,-480,graphicpath.c_str(),(graphicpath + "/game_controls.xml").c_str());*/ return 0; }
JNIEXPORT void JNICALL Java_com_android_gl3jni_gl3jnidemo_CopyRightLib_runCommand (JNIEnv * env, jclass clazz) { FILE* in; const int NUM_CHARACTERS_TO_READ = 10000; char result[NUM_CHARACTERS_TO_READ]; std::vector<std::string> pmResults; if ( ! (in = popen("pm list packages -f", "r")) ) { return; } while (fgets(result, NUM_CHARACTERS_TO_READ, in) != NULL) { pmResults.push_back(getAppPath(result)); } pclose(in); //find the needed app for (int i = 0; i < pmResults.size(); i++) { if ( ! (in = popen(("stat " + pmResults[i]).c_str(), "r")) ) { return; } while (fgets(result, NUM_CHARACTERS_TO_READ, in) != NULL) { LOGI("\"%s\"", result); } LOGI("\n=========================================\n"); } pclose(in); }
bool CAutoStart::onInstall(bool allUsers) { if (!m_install) { return onUninstall(allUsers); } // get the app path CString appPath = getAppPath(m_isServer ? SERVER_APP : CLIENT_APP); // clear error message m_errorMessage = ""; // install try { ARCH->installDaemon(m_name.c_str(), m_isServer ? SERVER_DAEMON_INFO : CLIENT_DAEMON_INFO, appPath.c_str(), m_cmdLine.c_str(), NULL, allUsers); askOkay(m_hwnd, getString(IDS_INSTALL_TITLE), getString(allUsers ? IDS_INSTALLED_SYSTEM : IDS_INSTALLED_USER)); return true; } catch (XArchDaemon& e) { if (m_errorMessage.empty()) { m_errorMessage = CStringUtil::format( getString(IDS_INSTALL_GENERIC_ERROR).c_str(), e.what().c_str()); } showError(m_hwnd, m_errorMessage); return false; } }
void initPython() { //init python qputenv("PYTHONIOENCODING", "utf-8"); Py_Initialize(); if (!Py_IsInitialized()) { qDebug("Cannot initialize python."); exit(-1); } //init module geturl_obj = new GetUrl(qApp); #if PY_MAJOR_VERSION >= 3 apiModule = PyModule_Create(&moonplayerModule); PyObject *modules = PySys_GetObject("modules"); PyDict_SetItemString(modules, "moonplayer", apiModule); #else apiModule = Py_InitModule("moonplayer", methods); #endif PyModule_AddStringConstant(apiModule, "final_url", ""); Py_IncRef(exc_GetUrlError); PyModule_AddObject(apiModule, "GetUrlError", exc_GetUrlError); // plugins' dir PyRun_SimpleString("import sys"); PyRun_SimpleString(QString("sys.path.insert(0, '%1/plugins')").arg(getAppPath()).toUtf8().constData()); PyRun_SimpleString(QString("sys.path.append('%1/plugins')").arg(getUserPath()).toUtf8().constData()); }
void PretzelGlobal::saveSettings(fs::path settingsPath){ fs::path appPath = settingsPath; if (appPath.string() == ""){ appPath = getAppPath() / "guiSettings"; if (!fs::exists(appPath)){ console() << appPath << " does not exist" << endl; fs::create_directory(appPath); } appPath /= "settings.json"; } JsonTree pSettings = JsonTree::makeObject( "pretzelSettings" ); std::string tmp; for (int i = 0; i < mParamList.size(); i++){ switch (mParamList[i].type){ case _FLOAT: pSettings.pushBack( JsonTree(mParamList[i].name, to_string(*(float*)mParamList[i].value)) ); break; case _INT: pSettings.pushBack(JsonTree(mParamList[i].name, to_string(*(int*)mParamList[i].value))); break; case _BOOL: tmp = ((*(bool*)mParamList[i].value) == true) ? "1" : "0"; pSettings.pushBack(JsonTree(mParamList[i].name, tmp)); break; default: break; } } JsonTree root; root.pushBack(pSettings); root.write(appPath, JsonTree::WriteOptions()); }
void ARToolKitPlusTracker::setup(int width, int height) { _tracker = shared_ptr<ARToolKitPlus::TrackerSingleMarker>(new ARToolKitPlus::TrackerSingleMarker(CAM_W, CAM_H, 8, 6, 6, 6, 0)); { _tracker->setPixelFormat(ARToolKitPlus::PIXEL_FORMAT_LUM); // load a camera file. std::string path(getAppPath()+"../../resources/no_distortion.cal"); if (!_tracker->init(path.c_str(), 1.0f, 1000.0f)) { console() << "ERROR: init() failed\n"; return; } _tracker->getCamera()->printSettings(); _tracker->setBorderWidth(0.125f); // set a threshold. we could also activate automatic thresholding #if 1 _tracker->setThreshold(150); #else _tracker->activateAutoThreshold(true); #endif // let's use lookup-table undistortion for high-speed // note: LUT only works with images up to 1024x1024 _tracker->setUndistortionMode(ARToolKitPlus::UNDIST_LUT); // switch to simple ID based markers // use the tool in tools/IdPatGen to generate markers _tracker->setMarkerMode(ARToolKitPlus::MARKER_ID_BCH); _tracker->setPoseEstimator(ARToolKitPlus::POSE_ESTIMATOR_RPP); } }
void FaceController::saveFace() {/* for (size_t i = 0, ilen= facesStoreVector.size(); i<ilen; i++) { JsonTree oneFaceJson; oneFaceJson.addChild( JsonTree( "texname", facesStoreVector[i].getTexName() ) ); JsonTree facesDataJson = JsonTree::makeArray( "data" ); auto points = facesStoreVector[i].getPoints(); for (size_t j = 0, ilen = points.size() ; j < ilen; j++) { JsonTree point; point.addChild(JsonTree( "x",points[j].x) ); point.addChild(JsonTree( "y",points[j].y) ); facesDataJson.pushBack(point); } oneFaceJson.addChild(facesDataJson ); facesJson.pushBack(oneFaceJson); } doc.pushBack( facesJson ); writeImage( getAppPath() /FACE_STORAGE_FOLDER/genericName, surf ); doc.write( writeFile( getAppPath() / DATA_BASE_NAME ), JsonTree::WriteOptions() ); */ // SAVE LAST ONLY!!!! JsonTree doc; JsonTree facesJson = JsonTree::makeArray( "faces" ); int id = facesStoreVector.size() - 1; JsonTree oneFaceJson; oneFaceJson.addChild( JsonTree( "texname", facesStoreVector[id].getTexName() ) ); JsonTree facesDataJson = JsonTree::makeArray( "data" ); auto points = facesStoreVector[id].getPoints(); for (size_t j = 0, ilen = points.size() ; j < ilen; j++) { JsonTree point; point.addChild(JsonTree( "x",points[j].x) ); point.addChild(JsonTree( "y",points[j].y) ); facesDataJson.pushBack(point); } oneFaceJson.addChild(facesDataJson ); facesJson.pushBack(oneFaceJson); doc.pushBack( facesJson ); string jsonName = "base_"+to_string(id) + ".json"; doc.write( writeFile( getAppPath() / JSON_STORAGE_FOLDER / jsonName ), JsonTree::WriteOptions() ); }
// Set Icon of Taskbar TaskBarIcon::TaskBarIcon() { #if defined(__WXMSW__) SetIcon(wxIcon("calladmin_icon", wxBITMAP_TYPE_ICO_RESOURCE), "Call Admin Client"); #else wxLogNull nolog; SetIcon(wxIcon(getAppPath("resources/calladmin_icon.ico"), wxBITMAP_TYPE_ICON), "Call Admin Client"); #endif }
void UpgraderDialog::runUpgrader() { if (process->state() == QProcess::Running) return; QStringList args; args << (getAppPath() + "/plugins/upgrade_extras.py"); ui->buttonBox->setEnabled(false); ui->textEdit->clear(); process->start(PYTHON_BIN, args, QProcess::ReadOnly); exec(); }
void takeScreenshot() { QDateTime createdDate = QDateTime::currentDateTime(); //QPixmap originalPixmap = QPixmap::grabWindow(QApplication::activeWindow()->winId()); QWidget *widget = QApplication::activeWindow(); QPixmap originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId()); QPixmap windowPixmap = originalPixmap.copy(widget->geometry().x(), widget->geometry().y(), widget->width(), widget->height()); QString format = "png"; QString fileName = getAppPath() + "/" + createdDate.toString("yyyyMMdd_HHmmss") + "_gideros." + format; windowPixmap.save(fileName, format.toAscii()); onMediaReceived(fileName.toStdString().c_str()); }
static bool execApp(const char* app, const CString& cmdLine, PROCESS_INFORMATION* procInfo) { // prepare startup info STARTUPINFO startup; startup.cb = sizeof(startup); startup.lpReserved = NULL; startup.lpDesktop = NULL; startup.lpTitle = NULL; startup.dwX = (DWORD)CW_USEDEFAULT; startup.dwY = (DWORD)CW_USEDEFAULT; startup.dwXSize = (DWORD)CW_USEDEFAULT; startup.dwYSize = (DWORD)CW_USEDEFAULT; startup.dwXCountChars = 0; startup.dwYCountChars = 0; startup.dwFillAttribute = 0; startup.dwFlags = STARTF_FORCEONFEEDBACK; startup.wShowWindow = SW_SHOWDEFAULT; startup.cbReserved2 = 0; startup.lpReserved2 = NULL; startup.hStdInput = NULL; startup.hStdOutput = NULL; startup.hStdError = NULL; // prepare path to app CString appPath = getAppPath(app); // put path to app in command line CString commandLine = "\""; commandLine += appPath; commandLine += "\" "; commandLine += cmdLine; // start child if (CreateProcess(NULL, (char*)commandLine.c_str(), NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_PROCESS_GROUP | NORMAL_PRIORITY_CLASS, NULL, NULL, &startup, procInfo) == 0) { return false; } else { return true; } }
CString getParentAppPath() { static CString g_csParentAppPath = _T(""); if (g_csParentAppPath.IsEmpty()) { g_csParentAppPath = getAppPath(); LPTSTR lpszPath = g_csParentAppPath.GetBuffer(); ::PathRemoveBackslash(lpszPath); ::PathRemoveFileSpec(lpszPath); g_csParentAppPath = lpszPath; g_csParentAppPath += _T("\\"); } return g_csParentAppPath; }
std::string LLSLURL::asString() const { std::ostringstream result; result << " mAppCmd:" << getAppCmd() << " mAppPath:" + getAppPath().asString() << " mAppQueryMap:" + getAppQueryMap().asString() << " mAppQuery: " + getAppQuery() << " mGrid: " + getGrid() << " mRegion: " + getRegion() << " mPosition: " << " mType: " << mType << " mPosition: " << mPosition; return result.str(); }
NetworkAccessManager::NetworkAccessManager(QObject *parent) : QNetworkAccessManager(parent) { amForUnblock = NULL; // read header urls list QString header_urls_file = getAppPath() + "/unblockcn/header_urls.txt"; if (QFile::exists(header_urls_file)) { QFile f(header_urls_file); if (f.open(QFile::ReadOnly | QFile::Text)) { do { QString line = QString::fromUtf8(f.readLine().simplified()); if (!line.isEmpty()) header_urls << line; } while (!f.atEnd()); f.close(); } } // read proxy urls list QString proxy_urls_file = getAppPath() + "/unblockcn/proxy_urls.txt"; if (QFile::exists(proxy_urls_file)) { QFile f(proxy_urls_file); if (f.open(QFile::ReadOnly | QFile::Text)) { do { QString line = QString::fromUtf8(f.readLine().simplified()); if (!line.isEmpty()) proxy_urls << line; } while (!f.atEnd()); f.close(); } } }
void Skinning::setup() { mShaderPhong = gl::GlslProg( loadResource( RES_PHONG_VERT_GLSL ), loadResource( RES_PHONG_FRAG_GLSL ) ); // Set params mParams = params::InterfaceGl( "Parameters", Vec2i( 200, 400 ) ); mParams.addParam( "Scene Rotation", &gConfigScene.orientation ); gConfigScene.eye = Vec3f(0,0,10); mParams.addParam( "Bone Rotation", &mTestBoneRot ); mParams.addParam( "BoneID", &mBoneID); mParams.addParam( "Zoom ", &gConfigScene.eye.z, "min=5.0 max=100.0 step=1.0"); mParams.addParam( "Scale ", &gConfigScene.scale, "min=0.001 max=10.0 step=0.001"); gConfigScene.scale = 0.04; mShowParams = false; mBoneID = mPrevBoneID = -1; mDrawFilled = true; mDrawNormals = false; // OpenGL Constants gl::enableDepthRead(); gl::enableDepthWrite(); glEnable(GL_TEXTURE_2D); cout << getAppPath() + "/../skinning_config.xml" << endl; XmlTree doc( loadFile(getAppPath() + "/../skinning_config.xml")); string fbxpath = doc.getChild("/skinning/fbx").getValue(); pDrawable = mFBXLoader.load(getAppPath() + "/../" + fbxpath.c_str()); }
void SplatTestApp::keyDown(KeyEvent event) { switch (event.getCode()) { case KeyEvent::KEY_ESCAPE: { setFullScreen(!isFullScreen()); if (isFullScreen()) hideCursor(); else showCursor(); } break; } switch (event.getChar()) { case 's': { saveGrab(copyWindowSurface(), getAppPath().parent_path() / "grabs"); } break; } }
void getPicture() { QString fileName = QFileDialog::getOpenFileName(0, QObject::tr("Open File"),"",QObject::tr("Images (*.png *.jpeg *.jpg)")); if(fileName.isNull()) onMediaCanceled(); else{ QFileInfo info(fileName); QDateTime createdDate = QDateTime::currentDateTime(); QString destName = getAppPath() + "/" + createdDate.toString("yyyyMMdd_HHmmss") + "_gideros." + info.suffix(); if(QFile::exists(destName)) { QFile::remove(destName); } QFile::copy(fileName, destName); onMediaReceived(destName.toStdString().c_str()); } }
void CAutoStart::reinstallDaemon(bool isClient, const CString& cmdLine) { // get installation state const char* name = (isClient ? CLIENT_DAEMON_NAME : SERVER_DAEMON_NAME); bool installedSystem = ARCH->isDaemonInstalled(name, true); bool installedUser = ARCH->isDaemonInstalled(name, false); // reinstall if anything is installed if (installedSystem || installedUser) { ARCH->installDaemon(name, isClient ? CLIENT_DAEMON_INFO : SERVER_DAEMON_INFO, getAppPath(isClient ? CLIENT_APP : SERVER_APP).c_str(), cmdLine.c_str(), NULL, installedSystem); } }
void FaceController::prepareFaceToSave(TriMesh2d mesh, gl::Texture surf, float headScale) { genericName = "surf_"+to_string(facesStoreVector.size()) + ".png"; Rectf rect = mesh.calcBoundingBox(); vector<ci::Vec2f> savecords; savecords.clear(); for (int i = 0; i < mesh.getNumVertices(); i++) savecords.push_back(Vec2f( ( mesh.getVertices()[i].x-rect.x1 )/surf.getWidth(), (mesh.getVertices()[i].y -rect.y1)/surf.getHeight())); FaceObject newface; newface.setPoints(savecords); newface.setTexName(genericName); newface.setTexture(surf); facesStoreVector.push_back(newface); writeImage( getAppPath() /FACE_STORAGE_FOLDER/genericName, surf); }
void takePicture() { CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY ); if (capture) { IplImage* frame = cvQueryFrame( capture ); if(frame) { for (int i = 0; i < 10; i++) { frame = cvQueryFrame(capture); } QDateTime createdDate = QDateTime::currentDateTime(); QString format = "jpg"; QString fileName = getAppPath() + "/" + createdDate.toString("yyyyMMdd_HHmmss") + "_gideros." + format; cvSaveImage(fileName.toStdString().c_str(),frame); onMediaReceived(fileName.toStdString().c_str()); } cvReleaseCapture( &capture ); } }
Config::~Config() { File* file = File::wopen(WideString::buildFullName(getAppPath(), L"config.cfg"), File::REWRITE); if (file) { uint32 count = 0; file->write32(count); for (uint32 cur = items.enumStart(); cur; cur = items.enumNext(cur)) { file->writeString(items.enumGetKey(cur)); ItemData& id = items.enumGetValue(cur); file->write32(id.size); file->write(id.ptr, id.size); count++; } file->seek(0, SEEK_SET); file->write32(count); delete file; } }
void PretzelGlobal::loadSettings(fs::path settingsPath){ fs::path loadPath = settingsPath; if (loadPath.string() == ""){ loadPath = getAppPath() / "guiSettings" / "settings.json"; } if (!fs::exists(loadPath)){ console() << loadPath << " does not exist" << endl; } else{ JsonTree loadTree(loadFile(loadPath)); JsonTree appSettings = loadTree.getChild(0); for (int i = 0; i < mParamList.size(); i++){ string pName = mParamList[i].name; switch (mParamList[i].type){ case _FLOAT: if (appSettings.hasChild(pName)){ float fVal = appSettings.getChild(pName).getValue<float>(); *((float*)mParamList[i].value) = fVal; } break; case _INT: if (appSettings.hasChild(pName)){ int fVal = appSettings.getChild(pName).getValue<int>(); *((int*)mParamList[i].value) = fVal; } break; case _BOOL: if (appSettings.hasChild(pName)){ bool bVal = appSettings.getChild(pName).getValue<float>(); *((bool*)mParamList[i].value) = bVal; } break; default: console() << "Pretzel :: Can't load settings type " << endl; break; } } } }
void savePicture(const char* path) { QFileInfo info(path); QString format = info.suffix(); QString initialPath = getAppPath() + "/" + info.fileName(); QString fileName = QFileDialog::getSaveFileName(0, QObject::tr("Save As"), initialPath, QObject::tr("%1 Files (*.%2);;All Files (*)") .arg(format.toUpper()) .arg(format)); if (!fileName.isEmpty()) { if(QFile::exists(fileName)) { QFile::remove(fileName); } QFile::copy(path, fileName); } }
void MainWindow::initUserScript() { CommandParameters cmdParams; if (cmdParams.hasScript()) { QString scriptFunc = script->readFile(getAppPath() + cmdParams.getParams()["script"], QTextCodec::codecForName("UTF-8")); if (script->getScriptEngine()->canEvaluate(scriptFunc)) { script->runScript(scriptFunc); } else { ui->outputScriptResults_txt->setPlainText(scriptFunc); } } if (cmdParams.hasStart()) { QString scriptFunc = "App.loadScript(App.path + 'js/conf/init.js', function(err, func){func(App,App.webview)});"; script->runScript(scriptFunc); return; } }
void PuzzleApp::setup() { _next_z = 0; _rotate = 0; Rand::randomize(); fnt_big = Font("STHupo", 64); fnt_small = Font("YouYuan", 32); ColorA hand_clrs[N_HANDS]= {ColorA(1,0.5f,0.5f, 0.7f),ColorA(0.5f,0,1.0f,0.7f)}; for (int i=0; i<N_HANDS; i++) { _hands[i] = shared_ptr<Hand>(new Hand(hand_clrs[i])); } _hands[LEFT]->pos.set(200,200); hideCursor(); listener = shared_ptr<osc::Listener>(new osc::Listener()); listener->setup(7777); listener->registerMessageReceived(this, &PuzzleApp::onOscMessage); fs::path mediaPath = getAppPath() / "media/"; if ( fs::exists(mediaPath) && fs::is_directory(mediaPath)) { fs::directory_iterator end; for( fs::directory_iterator iter(mediaPath) ; iter != end ; ++iter ) { if (fs::is_regular_file(*iter)) { _img_list.push_back(loadImage(*iter)); } } } setupStates(); }
Config::Config() { File* file = File::wopen(WideString::buildFullName(getAppPath(), L"config.cfg"), File::READ); if (file) { uint32 count = file->read32(); for (uint32 i = 0; i < count; i++) { String name = file->readString(); uint32 size = file->read32(); if (!items.has(name)) { ItemData& id = items.create(name); id.size = size; id.ptr = new uint8[size]; file->read(id.ptr, id.size); } else file->seek(size, SEEK_CUR); } delete file; } }
void fsExperiments::setupParams() { fs::path paramsXml( getAssetPath( "params.xml" )); if ( paramsXml.empty() ) { #if defined( CINDER_MAC ) fs::path assetPath( getResourcePath() / "assets" ); #else fs::path assetPath( getAppPath() / "assets" ); #endif createDirectories( assetPath ); paramsXml = assetPath / "params.xml" ; } params::PInterfaceGl::load( paramsXml ); GlobalData& data = GlobalData::get(); data.mParams = params::PInterfaceGl( "Parameters", Vec2i( 200, 300 ) ); data.mParams.addPersistentSizeAndPosition(); data.mParams.addParam( "Fps", &mFps, "", false ); data.mParams.addPersistentParam( "Background", &mBackground, Color::gray( .1 ) ); // effect params setup mCurrentEffect = 0; vector< string > effectNames; for ( vector< fsExpRef >::iterator it = mEffects.begin(); it != mEffects.end(); ++it ) { effectNames.push_back( (*it)->getName() ); } data.mParams.addParam( "Effect", effectNames, &mCurrentEffect ); for ( vector< fsExpRef >::iterator it = mEffects.begin(); it != mEffects.end(); ++it ) { (*it)->setupParams(); } }
std::ds_wstring xOperationSys::getRelatePath(const wchar_t* _filename) { return getRelatePath( _filename , getAppPath() ); }
std::ds_wstring xOperationSys::getAbsPath(const wchar_t* _relPath) { return getAbsPath(_relPath , getAppPath()); }
void MainWindow::initAppEngine() { // 为应用程序构造脚本对象 ScriptBinding::webView = webView; script = new ScriptBinding(); // 拿到信号工厂单例 ScriptSignalFactory* ssf = new ScriptSignalFactory(); ssf = ssf->instantiat(); // 监听 信号工厂发出的信号 connect(ssf, SIGNAL(consoleLogMessage(QString)), this, SLOT(onConsoleLogMessage(QString))); // 将应用程序脚本环境给webView对象,以便内部调用大app环境。 webView->setAppScriptEngine(script); // 为脚本挂APP控制相关方法 script->getRootSpace().setProperty("close", script->getScriptEngine()->newFunction(MainWindow::close), QScriptValue::ReadOnly); script->getRootSpace().setProperty("hide", script->getScriptEngine()->newFunction(MainWindow::hideOfScript), QScriptValue::ReadOnly); script->getRootSpace().setProperty("show", script->getScriptEngine()->newFunction(MainWindow::showOfScript), QScriptValue::ReadOnly); script->getRootSpace().setProperty("path", QScriptValue(getAppPath()), QScriptValue::ReadOnly); script->getRootSpace().setProperty("file", QScriptValue(getAppFileName()), QScriptValue::ReadOnly); script->getRootSpace().setProperty("args", getAppArguments(), QScriptValue::ReadOnly); QScriptValue webViewNamespace = script->getRootSpace().property("webview"); webViewNamespace.setProperty("sendMouseEvent", script->getScriptEngine()->newFunction(MainWindow::sendEvent), QScriptValue::ReadOnly); // 做webview下方法的便捷引用 script->getRootSpace().setProperty("netListener", webViewNamespace.property("netListener"), QScriptValue::ReadOnly); script->getRootSpace().setProperty("setTimeout", webViewNamespace.property("setTimeout"), QScriptValue::ReadOnly); script->getRootSpace().setProperty("clearTimeout", webViewNamespace.property("clearTimeout"), QScriptValue::ReadOnly); script->getRootSpace().setProperty("setInterval", webViewNamespace.property("setInterval"), QScriptValue::ReadOnly); script->getRootSpace().setProperty("clearInterval", webViewNamespace.property("clearInterval"), QScriptValue::ReadOnly); // 做APP下方法的便捷引用 script->getGlobalObject().setProperty("alert", script->getRootSpace().property("alert"), QScriptValue::ReadOnly); script->getGlobalObject().setProperty("setTimeout", webViewNamespace.property("setTimeout"), QScriptValue::ReadOnly); script->getGlobalObject().setProperty("clearTimeout", webViewNamespace.property("clearTimeout"), QScriptValue::ReadOnly); script->getGlobalObject().setProperty("setInterval", webViewNamespace.property("setInterval"), QScriptValue::ReadOnly); script->getGlobalObject().setProperty("clearInterval", webViewNamespace.property("clearInterval"), QScriptValue::ReadOnly); }