Exemple #1
0
PhoneGap::PhoneGap(QWebView *webView) : QObject(webView) {
    m_webView = webView;
    // Configure web view
    m_webView->settings()->enablePersistentStorage();

    // Listen to load finished signal
    QObject::connect( m_webView, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)) );

    // Set our own WebPage class
    m_webView->setPage( new PGWebPage() );

    // Read the phonegap.xml options config file
    readConfigFile();

    if (QCoreApplication::instance()->arguments().size() == 2) {
        // If user specified a URL on the command line, use that
        m_webView->load( QUrl::fromUserInput(QCoreApplication::instance()->arguments()[1]));
    } else {
        // Otherwise load www/index.html relative to current working directory

        // Determine index file path
        m_workingDir = QDir::current();
        QDir wwwDir( m_workingDir );
        wwwDir.cd( "www" );

        // Load the correct startup file
        m_webView->load( QUrl::fromUserInput(wwwDir.absoluteFilePath("index.html")) );
        //m_webView->load( QUrl::fromUserInput("http://html5test.com/") );
    }
}
Cordova::Cordova(QObject *parent) : QObject(parent) {
    m_topLevelEventsReceiver = 0;
    // Determine index file path
    m_workingDir = QApplication::applicationDirPath();
#ifdef MEEGO_EDITION_HARMATTAN
    m_workingDir.cdUp();
#endif
    qDebug() << "Using" << m_workingDir.absolutePath() << "as working dir";
    QDir wwwDir( m_workingDir );
    wwwDir.cd( "www" );

#if QT_VERSION < 0x050000
    m_mainUrl = QUrl::fromUserInput(wwwDir.absoluteFilePath("index.html")).toString();
#else
    m_mainUrl = QUrl::fromUserInput(wwwDir.absoluteFilePath("index_qt5.html")).toString();
#endif
}