コード例 #1
0
void DashboardApplet::initJsObjects()
{
    QWebFrame *frame = qobject_cast<QWebFrame*>(sender());
    Q_ASSERT(frame);
    frame->addToJavaScriptWindowObject(QLatin1String("applet"), this);
    frame->addToJavaScriptWindowObject(QLatin1String("widget"), new DashboardJs(frame, this, applet()));
}
コード例 #2
0
void DumpRenderTree::initJSObjects()
{
    QWebFrame *frame = qobject_cast<QWebFrame*>(sender());
    Q_ASSERT(frame);
    frame->addToJavaScriptWindowObject(QLatin1String("layoutTestController"), m_controller);
    frame->addToJavaScriptWindowObject(QLatin1String("eventSender"), m_eventSender);
    frame->addToJavaScriptWindowObject(QLatin1String("textInputController"), m_textInputController);
    frame->addToJavaScriptWindowObject(QLatin1String("GCController"), m_gcController);
    frame->addToJavaScriptWindowObject(QLatin1String("plainText"), m_plainTextController);
}
コード例 #3
0
void DumpRenderTree::initJSObjects()
{
    QWebFrame *frame = qobject_cast<QWebFrame*>(sender());
    Q_ASSERT(frame);
    frame->addToJavaScriptWindowObject(QLatin1String("testRunner"), m_controller);
    frame->addToJavaScriptWindowObject(QLatin1String("eventSender"), m_eventSender);
    frame->addToJavaScriptWindowObject(QLatin1String("textInputController"), m_textInputController);
    frame->addToJavaScriptWindowObject(QLatin1String("GCController"), m_gcController);
    DumpRenderTreeSupportQt::injectInternalsObject(frame);
}
コード例 #4
0
	void CustomWebPage::handleJavaScriptWindowObjectCleared ()
	{
		QWebFrame *frame = qobject_cast<QWebFrame*> (sender ());
		Util::DefaultHookProxy_ptr proxy (new Util::DefaultHookProxy ());
		emit hookJavaScriptWindowObjectCleared (proxy, this, frame);
		if (proxy->IsCancelled ())
			return;

		frame->addToJavaScriptWindowObject ("JSProxy", JSProxy_.get ());
		frame->addToJavaScriptWindowObject ("external", ExternalProxy_.get ());
	}
コード例 #5
0
ファイル: mainwindow.cpp プロジェクト: Zimtronic/posjs
void MainWindow::addJSObject()
{
    QWebFrame *frame = view->page()->mainFrame();

    if (posdriver)
    {
        frame->addToJavaScriptWindowObject("ESCPOSPrinter", (QObject*)posdriver->getESCPOSPrinterInstance());
        frame->addToJavaScriptWindowObject("BarcodeScanner", (QObject*)posdriver->getBarcodeScannerInstance());
        frame->addToJavaScriptWindowObject("MagneticScanner", (QObject*)posdriver->getMagneticScannerInstance());
    }
}
コード例 #6
0
void MarbleLegendBrowser::injectCheckBoxChecker()
{
#ifndef MARBLE_NO_WEBKIT
    QWebFrame *frame = page()->mainFrame();
    frame->addToJavaScriptWindowObject( "Marble", this );
#endif
}
コード例 #7
0
ファイル: csvfactory.cpp プロジェクト: yuyichao/explore
QObject *CSVFactory::create(const QString &mimeType, const QUrl &url,
                            const QStringList &argumentNames,
                            const QStringList &argumentValues) const
{
    if (mimeType != "text/csv")
        return 0;

    QHash<QString, QString> arguments;
    for (int i = 0; i < argumentNames.count(); ++i)
        arguments[argumentNames[i]] = argumentValues[i];

    CSVView *view = new CSVView(arguments["type"], arguments["related"]);

    QWebFrame *frame = webView->page()->mainFrame();
    frame->addToJavaScriptWindowObject(arguments["related"] + "_input", view);
    frame->evaluateJavaScript(
        arguments["related"] + "_input.rowSelected.connect(fillInForm);\n");

    QNetworkRequest request(url);
    QNetworkReply *reply = manager->get(request);
    connect(reply, SIGNAL(finished()), view, SLOT(updateModel()));
    connect(reply, SIGNAL(finished()), reply, SLOT(deleteLater()));

    return view;
}
コード例 #8
0
ファイル: qwebframeproto.cpp プロジェクト: xtuple/qt-client
void QWebFrameProto::addToJavaScriptWindowObject(const QString & name, QObject * object, QWebFrame::ValueOwnership own)
{
  scriptDeprecated("QWebFrame will not be available in future versions");
  QWebFrame *item = qscriptvalue_cast<QWebFrame*>(thisObject());
  if (item)
    item->addToJavaScriptWindowObject(name, object, own);
}
コード例 #9
0
    void WebPage::on_load_finished(bool ok)
    {
        if (!ok)
            return;

        QWebFrame* frame = mainFrame();
        if (frame)
            frame->addToJavaScriptWindowObject("webpage", this);
    }
コード例 #10
0
ファイル: AssetEditor_Script.cpp プロジェクト: TrieBr/GMIDE
void AssetEditor_Script::frameLoaded(bool ok)
{
    QWebFrame* frame = ui->webView->page()->mainFrame();
    frame->addToJavaScriptWindowObject("bridge",this);
    frame->evaluateJavaScript("editor.setValue(bridge.js_get_script_text())");  //Tell editor to set its text to te script text
    frame->evaluateJavaScript("editor.setShowPrintMargin(false);");
    frame->evaluateJavaScript("editor.selection.moveCursorFileStart();");

}
コード例 #11
0
ファイル: phonegap.cpp プロジェクト: tranter/callback-qt
/**
 * Called when the webview finished loading a new page
 */
void PhoneGap::loadFinished( bool ok ) {
    Q_UNUSED(ok)

    // Change into the xml-directory
    QDir xmlDir( m_workingDir );
    xmlDir.cd( "xml" );

    // Try to open the plugins configuration
    QFile pluginsXml( xmlDir.filePath("plugins.xml") );
    if( !pluginsXml.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
        qDebug() << "Error loading plugins config!";
        return;
    }

    // Start reading the file as a stream
    QXmlStreamReader plugins;
    plugins.setDevice( &pluginsXml );

    // Get a reference to the current main-frame
    QWebFrame *webFrame = m_webView->page()->mainFrame();

    // Iterate over plugins-configuration and load all according plugins
    while(!plugins.atEnd()) {
        if( plugins.readNext() == QXmlStreamReader::StartElement ) {
            // Check if we have a plugin element
            if( plugins.name() == "plugin" ) {
                QXmlStreamAttributes attribs = plugins.attributes();
                // Check for name & value attributes
                if( attribs.hasAttribute("name") && attribs.hasAttribute("value") ) {
                    // Construct object & attribute names
                    QString attribName = attribs.value( "name" ).toString();
                    QString attribValue = attribs.value( "value" ).toString();
                    QString objectName = attribName + "_native";

                    qDebug() << "Adding Plugin " << attribName << " with " << attribValue;
                    // Check for such a plugin
                    PGPlugin *currPlugin = PluginRegistry::getRegistry()->getPlugin( attribValue );
                    if( currPlugin != NULL ) {
                        currPlugin->setWebFrame( webFrame );
                        webFrame->addToJavaScriptWindowObject( objectName, currPlugin );

                        webFrame->evaluateJavaScript( "PhoneGap.Qt.registerObject( '" + attribValue + "', " + objectName + " )" );
                        webFrame->evaluateJavaScript( "PhoneGap.enablePlugin( '" + attribValue + "' )" );
                    }
                    else {
                        qDebug() << "Unknown Plugin " << attribName;
                    }
                }
            }
        }
    }

    // Device is now ready to rumble
    webFrame->evaluateJavaScript( "PhoneGap.deviceready();" );
}
コード例 #12
0
void QtStageWebView::registerEventbus()
{
    QWebFrame* frame = page()->mainFrame();
    frame->addToJavaScriptWindowObject(QString("eventbus2"), new BlackBerryBus(this, frame));
    frame->evaluateJavaScript(BlackBerry::Ripple::eventbusSource);

    // check for iframes, if found add to window object
    for(int i = 0; i < frame->childFrames().length(); i++)
    {
        frame->childFrames()[i]->addToJavaScriptWindowObject(QString("eventbus2"), new BlackBerryBus(this, frame->childFrames()[i]));
        frame->childFrames()[i]->evaluateJavaScript(BlackBerry::Ripple::eventbusSource);
  }
}
コード例 #13
0
ファイル: qasmine.cpp プロジェクト: tart/qasmine
/**
  * When file finished, execute JavaScript functions
  */
void Qasmine::finishLoading(bool isFinished) 
{
    if (!isFinished) {
        this->log("ERROR: cannot load file : '" + fileName + "'");
        exitConditionally(255);
    }

    QWebFrame *frame  = webView->page()->mainFrame();

    frame->evaluateJavaScript(readFileContent(":/qasmine.js"));
    frame->addToJavaScriptWindowObject(QString("qasmine"), this);
    frame->evaluateJavaScript(getQasmineJsCommand());
}
コード例 #14
0
void wrapInFunction()
{

    //! [0]
    // ...
    QWebFrame *frame = myWebPage->mainFrame();
    frame->addToJavaScriptWindowObject("someNameForMyObject", myObject);
    // ...
    //! [0]
#if 0
    //! [1]
    {
        width: ...,
        height: ...,
        toDataURL: function() { ... },
        assignToHTMLImageElement: function(element) { ... }
    }
コード例 #15
0
// Message Observer Interface
void
dmz::BorderWebInterface::receive_message (
      const Message &Type,
      const UInt32 MessageSendHandle,
      const Handle TargetObserverHandle,
      const Data *InData,
      Data *outData) {

   if (Type == _addPinMessage) {

      int x, y;
      String title, description;

      if (InData->lookup_int32 (_pinPositionHandle, 0, x) &&
         InData->lookup_int32 (_pinPositionHandle, 1, y) &&
         InData->lookup_string (_pinTitleHandle, 0, title) &&
         InData->lookup_string (_pinDescHandle, 0, description)) {

         emit (addPin (x, y, title.get_buffer (), description.get_buffer ()));
      }
   }
   else if (Type == _removePinMessage) {

      int id;
      if (InData->lookup_int32 (_pinIDHandle, 0, id)) { emit (removePin (id)); }
   }
   else if (Type == _setFrameMessage) {

      QWebFrame *frame;
      if (_mainWindow) {

         frame = _mainWindow->get_qt_main_window ()->findChild<QWebFrame *>(_frameName.get_buffer ());
      }

      if (frame) {

         frame->addToJavaScriptWindowObject (_jsWindowObjectName.get_buffer (), this);
      }
   }
}
コード例 #16
0
void SimpleWebView::SendObjectToPage(QString objectName, QObject * pObject){
	//get the active page.
	QWebFrame * pWebFrame = this->page()->mainFrame();
	pWebFrame->addToJavaScriptWindowObject(objectName, pObject);
}
コード例 #17
0
ファイル: odfview.cpp プロジェクト: Decad/WebODF
void
OdfView::slotInitWindowObjects()
{
    QWebFrame *frame = page()->mainFrame();
    frame->addToJavaScriptWindowObject("nativeio", nativeio);
}
コード例 #18
0
JavaScript::JavaScript(QWidget *parent)
    : QWebView(parent)
{
    QWebFrame *frame = this->page()->mainFrame();
    frame->addToJavaScriptWindowObject("gmint",this);
}
コード例 #19
0
void QgsHtmlAnnotation::javascript()
{
  QWebFrame *frame = mWebPage->mainFrame();
  frame->addToJavaScriptWindowObject( QStringLiteral( "layer" ), mapLayer() );
}