Esempio n. 1
0
BrowserWindow::BrowserWindow()
    : OpenGLWindow(NULL)
{
    connect(QMozContext::GetInstance(), SIGNAL(onInitialized()), this, SLOT(onContextInitialized()));
    connect(&m_mozView, SIGNAL(viewInitialized()), this, SLOT(onViewInitialized()));
    m_timer.setInterval(41);
    m_timer.setSingleShot(false);
    connect(&m_timer, SIGNAL(timeout()), this, SLOT(renderNow()));
}
Esempio n. 2
0
GameObject * GameObjectManager::createObject( int id, int type, int group )
{
	// 检查该对象是否存在;
	auto it = m_objectMap.find(id);
	if (it != m_objectMap.end())
	{
		log("createObject: id=%d, object already exist", id);
		return it->second.object;	
	}

	// 创建实体;
	char config[128];
	sprintf(config, "config/gameobject_%d.json", type);
	auto object = new GameObject;
	if (object && object->init(config, id, group))
	{

	}
	else
	{
		delete object;
		object = nullptr;
		return nullptr;
	}

	// 创建视图;
	auto view = new GameObjectView;
	if (view && view->init(id))
	{
		view->autorelease();
	}
	else
	{
		delete view;
		view = nullptr;

		delete object;
		object = nullptr;
	}

	// 创建对应关系;
	if (object && view)
	{
		this->addChild(view);

		ObjectData data;
		data.object = object;
		data.view = view;

		m_objectMap.insert(ObjectMapPair(id, data));
	}

	// 初始化成功,显示;
	view->onInitialized();

	return object;
}
Esempio n. 3
0
Window::Window( QWidget *parent) :
    QObject(parent)
{
    m_view = new QWebView();
    m_page = new WebPage(m_view);
    m_view->setPage(m_page);
    m_window = new CustomWindow(m_view);
    connect(m_page, SIGNAL(javaScriptWindowObjectCleared()),this,SLOT(onInitialized()));
    connect(m_window,SIGNAL(myCloseEvent()),SIGNAL(_onClose()));
}
DeclarativeWebContainer::DeclarativeWebContainer(QQuickItem *parent)
    : QQuickItem(parent)
    , m_webPage(0)
    , m_model(0)
    , m_webPageComponent(0)
    , m_settingManager(SettingManager::instance())
    , m_foreground(true)
    , m_allowHiding(true)
    , m_popupActive(false)
    , m_portrait(true)
    , m_fullScreenMode(false)
    , m_fullScreenHeight(0.0)
    , m_inputPanelVisible(false)
    , m_inputPanelHeight(0.0)
    , m_inputPanelOpenHeight(0.0)
    , m_toolbarHeight(0.0)
    , m_tabId(0)
    , m_loading(false)
    , m_loadProgress(0)
    , m_canGoForward(false)
    , m_canGoBack(false)
    , m_realNavigation(false)
    , m_completed(false)
    , m_initialized(false)
{
    m_webPages.reset(new WebPages(this));
    setFlag(QQuickItem::ItemHasContents, true);
    connect(DownloadManager::instance(), SIGNAL(downloadStarted()), this, SLOT(onDownloadStarted()));
    connect(QMozContext::GetInstance(), SIGNAL(onInitialized()), this, SLOT(initialize()));
    connect(this, SIGNAL(portraitChanged()), this, SLOT(resetHeight()));
    connect(this, SIGNAL(enabledChanged()), this, SLOT(handleEnabledChanged()));

    QString cacheLocation = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
    QDir dir(cacheLocation);
    if(!dir.exists() && !dir.mkpath(cacheLocation)) {
        qWarning() << "Can't create directory "+ cacheLocation;
        return;
    }

    connect(this, SIGNAL(heightChanged()), this, SLOT(sendVkbOpenCompositionMetrics()));
    connect(this, SIGNAL(widthChanged()), this, SLOT(sendVkbOpenCompositionMetrics()));

    qApp->installEventFilter(this);
}
Esempio n. 5
0
void Phantom::init()
{
    if (m_config.helpFlag()) {
        Terminal::instance()->cout(QString("%1").arg(m_config.helpText()));
        Terminal::instance()->cout("Any of the options that accept boolean values ('true'/'false') can also accept 'yes'/'no'.");
        Terminal::instance()->cout("");
        Terminal::instance()->cout("Without any argument, PhantomJS will launch in interactive mode (REPL).");
        Terminal::instance()->cout("");
        Terminal::instance()->cout("Documentation can be found at the web site, http://phantomjs.org.");
        Terminal::instance()->cout("");
        m_terminated = true;
        return;
    }

    if (m_config.versionFlag()) {
        m_terminated = true;
        Terminal::instance()->cout(QString("%1").arg(PHANTOMJS_VERSION_STRING));
        return;
    }

    if (!m_config.unknownOption().isEmpty()) {
        Terminal::instance()->cerr(m_config.unknownOption());
        m_terminated = true;
        return;
    }

    // Initialize the CookieJar
    m_defaultCookieJar = new CookieJar(m_config.cookiesFile());

    QWebSettings::setOfflineWebApplicationCachePath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
    if (m_config.offlineStoragePath().isEmpty()) {
        QWebSettings::setOfflineStoragePath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
    } else {
        QWebSettings::setOfflineStoragePath(m_config.offlineStoragePath());
    }
    if (m_config.offlineStorageDefaultQuota() > 0) {
        QWebSettings::setOfflineStorageDefaultQuota(m_config.offlineStorageDefaultQuota());
    }

    m_page = new WebPage(this, QUrl::fromLocalFile(m_config.scriptFile()));
    m_page->setCookieJar(m_defaultCookieJar);
    m_pages.append(m_page);

    // Set up proxy if required
    QString proxyType = m_config.proxyType();
    if (proxyType != "none") {
        setProxy(m_config.proxyHost(), m_config.proxyPort(), proxyType, m_config.proxyAuthUser(), m_config.proxyAuthPass());
    }

    // Set output encoding
    Terminal::instance()->setEncoding(m_config.outputEncoding());

    // Set script file encoding
    m_scriptFileEnc.setEncoding(m_config.scriptEncoding());

    connect(m_page, SIGNAL(javaScriptConsoleMessageSent(QString)),
            SLOT(printConsoleMessage(QString)));
    connect(m_page, SIGNAL(initialized()),
            SLOT(onInitialized()));

    m_defaultPageSettings[PAGE_SETTINGS_LOAD_IMAGES] = QVariant::fromValue(m_config.autoLoadImages());
    m_defaultPageSettings[PAGE_SETTINGS_JS_ENABLED] = QVariant::fromValue(true);
    m_defaultPageSettings[PAGE_SETTINGS_XSS_AUDITING] = QVariant::fromValue(false);
    m_defaultPageSettings[PAGE_SETTINGS_USER_AGENT] = QVariant::fromValue(m_page->userAgent());
    m_defaultPageSettings[PAGE_SETTINGS_LOCAL_ACCESS_REMOTE] = QVariant::fromValue(m_config.localToRemoteUrlAccessEnabled());
    m_defaultPageSettings[PAGE_SETTINGS_WEB_SECURITY_ENABLED] = QVariant::fromValue(m_config.webSecurityEnabled());
    m_defaultPageSettings[PAGE_SETTINGS_JS_CAN_OPEN_WINDOWS] = QVariant::fromValue(m_config.javascriptCanOpenWindows());
    m_defaultPageSettings[PAGE_SETTINGS_JS_CAN_CLOSE_WINDOWS] = QVariant::fromValue(m_config.javascriptCanCloseWindows());
    m_page->applySettings(m_defaultPageSettings);

    setLibraryPath(QFileInfo(m_config.scriptFile()).dir().absolutePath());
}
Esempio n. 6
0
// public:
Phantom::Phantom(QObject *parent)
    : REPLCompletable(parent)
    , m_terminated(false)
    , m_returnValue(0)
    , m_filesystem(0)
    , m_system(0)
{
    // second argument: script name
    QStringList args = QApplication::arguments();

    // Skip the first argument, i.e. the application executable (phantomjs).
    args.removeFirst();

    m_config.init(&args);

    if (m_config.helpFlag()) {
        m_terminated = true;
        Utils::showUsage();
        return;
    }

    if (m_config.versionFlag()) {
        m_terminated = true;
        Terminal::instance()->cout(QString("%1").arg(PHANTOMJS_VERSION_STRING));
        return;
    }

    if (!m_config.unknownOption().isEmpty()) {
        Terminal::instance()->cerr(m_config.unknownOption());
        m_terminated = true;
        return;
    }

    m_page = new WebPage(this, &m_config, QUrl::fromLocalFile(m_config.scriptFile()));
    m_pages.append(m_page);

    if (m_config.proxyHost().isEmpty()) {
        QNetworkProxyFactory::setUseSystemConfiguration(true);
    } else {
        QString proxyType = m_config.proxyType();
        QNetworkProxy::ProxyType networkProxyType = QNetworkProxy::HttpProxy;

        if (proxyType == "socks5") {
            networkProxyType = QNetworkProxy::Socks5Proxy;
        }

        if(!m_config.proxyAuthUser().isEmpty() && !m_config.proxyAuthPass().isEmpty()) {
            QNetworkProxy proxy(networkProxyType, m_config.proxyHost(), m_config.proxyPort(), m_config.proxyAuthUser(), m_config.proxyAuthPass());
            QNetworkProxy::setApplicationProxy(proxy);
        } else {
            QNetworkProxy proxy(networkProxyType, m_config.proxyHost(), m_config.proxyPort());
            QNetworkProxy::setApplicationProxy(proxy);
        }
    }

    // Set output encoding
    Terminal::instance()->setEncoding(m_config.outputEncoding());

    // Set script file encoding
    m_scriptFileEnc.setEncoding(m_config.scriptEncoding());

    connect(m_page, SIGNAL(javaScriptConsoleMessageSent(QString)),
            SLOT(printConsoleMessage(QString)));
    connect(m_page, SIGNAL(initialized()),
            SLOT(onInitialized()));

    m_defaultPageSettings[PAGE_SETTINGS_LOAD_IMAGES] = QVariant::fromValue(m_config.autoLoadImages());
    m_defaultPageSettings[PAGE_SETTINGS_JS_ENABLED] = QVariant::fromValue(true);
    m_defaultPageSettings[PAGE_SETTINGS_XSS_AUDITING] = QVariant::fromValue(false);
    m_defaultPageSettings[PAGE_SETTINGS_USER_AGENT] = QVariant::fromValue(m_page->userAgent());
    m_defaultPageSettings[PAGE_SETTINGS_LOCAL_ACCESS_REMOTE] = QVariant::fromValue(m_config.localToRemoteUrlAccessEnabled());
    m_defaultPageSettings[PAGE_SETTINGS_WEB_SECURITY_ENABLED] = QVariant::fromValue(m_config.webSecurityEnabled());
    m_page->applySettings(m_defaultPageSettings);

    setLibraryPath(QFileInfo(m_config.scriptFile()).dir().absolutePath());
}
Esempio n. 7
0
void Phantom::init()
{
    if (m_config.helpFlag()) {
        Terminal::instance()->cout(QString("%1").arg(m_config.helpText()));
        Terminal::instance()->cout("Without any argument, PhantomJS will launch in interactive mode (REPL).");
        Terminal::instance()->cout("");
        Terminal::instance()->cout("Documentation can be found at the web site, http://phantomjs.org.");
        Terminal::instance()->cout("");
        m_terminated = true;
        return;
    }

    if (m_config.versionFlag()) {
        m_terminated = true;
        Terminal::instance()->cout(QString("%1").arg(PHANTOMJS_VERSION_STRING));
        return;
    }

    if (!m_config.unknownOption().isEmpty()) {
        Terminal::instance()->cerr(m_config.unknownOption());
        m_terminated = true;
        return;
    }

    m_page = new WebPage(this, QUrl::fromLocalFile(m_config.scriptFile()));
    m_pages.append(m_page);

    QString proxyType = m_config.proxyType();
    if (proxyType != "none") {
        if (m_config.proxyHost().isEmpty()) {
            QNetworkProxyFactory::setUseSystemConfiguration(true);
        } else {
            QNetworkProxy::ProxyType networkProxyType = QNetworkProxy::HttpProxy;

            if (proxyType == "socks5") {
                networkProxyType = QNetworkProxy::Socks5Proxy;
            }

            if(!m_config.proxyAuthUser().isEmpty() && !m_config.proxyAuthPass().isEmpty()) {
                QNetworkProxy proxy(networkProxyType, m_config.proxyHost(), m_config.proxyPort(), m_config.proxyAuthUser(), m_config.proxyAuthPass());
                QNetworkProxy::setApplicationProxy(proxy);
            } else {
                QNetworkProxy proxy(networkProxyType, m_config.proxyHost(), m_config.proxyPort());
                QNetworkProxy::setApplicationProxy(proxy);
            }
        }
    }

    // Set output encoding
    Terminal::instance()->setEncoding(m_config.outputEncoding());

    // Set script file encoding
    m_scriptFileEnc.setEncoding(m_config.scriptEncoding());

    connect(m_page, SIGNAL(javaScriptConsoleMessageSent(QString)),
            SLOT(printConsoleMessage(QString)));
    connect(m_page, SIGNAL(initialized()),
            SLOT(onInitialized()));

    m_defaultPageSettings[PAGE_SETTINGS_LOAD_IMAGES] = QVariant::fromValue(m_config.autoLoadImages());
    m_defaultPageSettings[PAGE_SETTINGS_JS_ENABLED] = QVariant::fromValue(true);
    m_defaultPageSettings[PAGE_SETTINGS_XSS_AUDITING] = QVariant::fromValue(false);
    m_defaultPageSettings[PAGE_SETTINGS_USER_AGENT] = QVariant::fromValue(m_page->userAgent());
    m_defaultPageSettings[PAGE_SETTINGS_LOCAL_ACCESS_REMOTE] = QVariant::fromValue(m_config.localToRemoteUrlAccessEnabled());
    m_defaultPageSettings[PAGE_SETTINGS_WEB_SECURITY_ENABLED] = QVariant::fromValue(m_config.webSecurityEnabled());
    m_defaultPageSettings[PAGE_SETTINGS_JS_CAN_OPEN_WINDOWS] = QVariant::fromValue(m_config.javascriptCanOpenWindows());
    m_defaultPageSettings[PAGE_SETTINGS_JS_CAN_CLOSE_WINDOWS] = QVariant::fromValue(m_config.javascriptCanCloseWindows());
    m_page->applySettings(m_defaultPageSettings);

    setLibraryPath(QFileInfo(m_config.scriptFile()).dir().absolutePath());
}
Esempio n. 8
0
bool CUpdateLogView::init(CGameUpdateScene *updataScene,bool isUpdate)
{
    m_updataScene = updataScene;
    m_isUpdate    = isUpdate;
    
    if( !CContainer::init() )
        return onInitialized(false);

    CCSize winSize = CCDirector::sharedDirector()->getVisibleSize();

    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("General.plist");
    CSprite *pBackground = CSprite::createWithSpriteFrameName("general_first_underframe.png", CCRectMake(75.0f, 75.0f, 25.0f, 25.0f));

    pBackground->setPreferredSize(CCSizeMake(600,500));
    pBackground->setPosition(ccp(winSize.width/2.0f+30.0f, winSize.height/2.0f + 50.0f));

    addChild(pBackground);
    
    CSprite *pTitleImg = CSprite::create("loginResources/signs_word_yxgxgg.png");
    pTitleImg->setControlName("this CUpdateLogView pTitleImg 81");
    pTitleImg->setPosition(ccp( winSize.width/2.0f+30.0f, winSize.height/2.0f + 255 ));
    addChild(pTitleImg);

    //webView
    CCSize screenSize = CDevice::sharedDevice()->getScreenSize();

    m_pWebView = CWebView::create();
    CCSize mySize;
#if( CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    mySize = CCSizeMake(screenSize.height, screenSize.width);
#elif( CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    mySize = CCSizeMake(screenSize.width, screenSize.height);
#endif
    CCSize bgSize   = pBackground->getPreferredSize();
    CCSize viewSize = CCSizeMake(mySize.width / winSize.width * (bgSize.width-40) , mySize.height / 640 * bgSize.height*0.68f);
    
    m_pWebView->setPreferredSize(viewSize);
    m_pWebView->setPosition(ccp( mySize.width/2-viewSize.width/2+30.0f/winSize.width*mySize.width,100.0f/winSize.height*mySize.height ));
    
    addChild(m_pWebView);
    
    
    //添加 进入按钮 
    m_pGoInBtn = CButton::createWithSpriteFrameName("进入游戏", "general_button_normal.png");
    CCSize buttonSize = m_pGoInBtn->getPreferredSize();
    m_pGoInBtn->setPosition(ccp(winSize.width/2.0f+30.0f,winSize.height*0.25f));
    m_pGoInBtn->addEventListener("TouchBegan", this, eventhandler_selector(CUpdateLogView::onBeganTouchGoInButton));
    addChild(m_pGoInBtn);
    
    char szUrl[1024];
    __getUrl(szUrl);
    m_pWebView->loadGet(szUrl);
    if(m_isUpdate)
    {
        m_pGoInBtn->setTouchesEnabled( false );
        
        m_pWebView->loadGet(szUrl, NULL, NULL, 0U, this , eventhandler_selector(CUpdateLogView::onUpdateLogLoaded));
        CCLOG(" CUpdateLogView   %s",szUrl);
    }

    

    
    
    return onInitialized(true);
}
Esempio n. 9
0
Q_DECL_EXPORT int main(int argc, char *argv[])
{
    // EGL FPS are lower with threaded render loop
    // that's why this workaround.
    // See JB#7358
    setenv("QML_BAD_GUI_RENDER_LOOP", "1", 1);
    setenv("USE_ASYNC", "1", 1);

    // Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=929879
    setenv("LC_NUMERIC", "C", 1);
    setlocale(LC_NUMERIC, "C");
#ifdef HAS_BOOSTER
    QScopedPointer<QGuiApplication> app(MDeclarativeCache::qApplication(argc, argv));
    QScopedPointer<QQuickView> view(MDeclarativeCache::qQuickView());
#else
    QScopedPointer<QGuiApplication> app(new QGuiApplication(argc, argv));
    QScopedPointer<QQuickView> view(new QQuickView);
#endif
    app->setQuitOnLastWindowClosed(false);

    // TODO : Remove this and set custom user agent always
    // Don't set custom user agent string when arguments contains -developerMode, give url as last argument
    if (!app->arguments().contains("-developerMode")) {
        setenv("CUSTOM_UA", "Mozilla/5.0 (Maemo; Linux; U; Jolla; Sailfish; Mobile; rv:26.0) Gecko/26.0 Firefox/26.0 SailfishBrowser/1.0 like Safari/538.1", 1);
    }

    BrowserService *service = new BrowserService(app.data());
    // Handle command line launch
    if (!service->registered()) {
        QDBusMessage message = QDBusMessage::createMethodCall(service->serviceName(), "/",
                                                              service->serviceName(), "openUrl");
        QStringList args;
        // Pass url argument if given
        if (app->arguments().count() > 1) {
            args << app->arguments().at(1);
        }
        message.setArguments(QVariantList() << args);

        QDBusConnection::sessionBus().asyncCall(message);
        if (QCoreApplication::hasPendingEvents()) {
            QCoreApplication::processEvents();
        }

        return 0;
    }

    QString translationPath("/usr/share/translations/");
    QTranslator engineeringEnglish;
    engineeringEnglish.load("sailfish-browser_eng_en", translationPath);
    qApp->installTranslator(&engineeringEnglish);

    QTranslator translator;
    translator.load(QLocale(), "sailfish-browser", "-", translationPath);
    qApp->installTranslator(&translator);

    //% "Browser"
    view->setTitle(qtTrId("sailfish-browser-ap-name"));

    qmlRegisterType<DeclarativeBookmarkModel>("Sailfish.Browser", 1, 0, "BookmarkModel");
    qmlRegisterType<DeclarativeTabModel>("Sailfish.Browser", 1, 0, "TabModel");
    qmlRegisterType<DeclarativeHistoryModel>("Sailfish.Browser", 1, 0, "HistoryModel");
    qmlRegisterType<DeclarativeTab>("Sailfish.Browser", 1, 0, "Tab");
    qmlRegisterType<DeclarativeWebContainer>("Sailfish.Browser", 1, 0, "WebContainer");

    QString componentPath(DEFAULT_COMPONENTS_PATH);
    QMozContext::GetInstance()->addComponentManifest(componentPath + QString("/components/EmbedLiteBinComponents.manifest"));
    QMozContext::GetInstance()->addComponentManifest(componentPath + QString("/components/EmbedLiteJSComponents.manifest"));
    QMozContext::GetInstance()->addComponentManifest(componentPath + QString("/chrome/EmbedLiteJSScripts.manifest"));
    QMozContext::GetInstance()->addComponentManifest(componentPath + QString("/chrome/EmbedLiteOverrides.manifest"));

    app->setApplicationName(QString("sailfish-browser"));
    app->setOrganizationName(QString("org.sailfishos"));

    DeclarativeWebUtils * utils = new DeclarativeWebUtils(app->arguments(), service, app.data());
    utils->clearStartupCacheIfNeeded();
    view->rootContext()->setContextProperty("WebUtils", utils);
    view->rootContext()->setContextProperty("MozContext", QMozContext::GetInstance());

    DownloadManager  * dlMgr = new DownloadManager(service, app.data());
    CloseEventFilter * clsEventFilter = new CloseEventFilter(dlMgr, app.data());
    view->installEventFilter(clsEventFilter);
    QObject::connect(service, SIGNAL(openUrlRequested(QString)),
                     clsEventFilter, SLOT(cancelStopApplication()));

    SettingManager * settingMgr = new SettingManager(app.data());
    QObject::connect(QMozContext::GetInstance(), SIGNAL(onInitialized()),
                     settingMgr, SLOT(initialize()));

    QObject::connect(QMozContext::GetInstance(), SIGNAL(newWindowRequested(QString)),
                     utils, SLOT(openUrl(QString)));

#ifdef USE_RESOURCES
    view->setSource(QUrl("qrc:///browser.qml"));
#else
    bool isDesktop = qApp->arguments().contains("-desktop");

    QString path;
    if (isDesktop) {
        path = qApp->applicationDirPath() + QDir::separator();
    } else {
        path = QString(DEPLOYMENT_PATH);
    }
    view->setSource(QUrl::fromLocalFile(path+"browser.qml"));
#endif

    view->showFullScreen();

    // Setup embedding
    QTimer::singleShot(0, QMozContext::GetInstance(), SLOT(runEmbedding()));

    return app->exec();
}