Esempio n. 1
0
QString ForumProbe::getTitle(QString &html) {
    QString title;
#ifndef NO_WEBKITWIDGETS
    QWebPage *page = new QWebPage();
    QWebFrame *frame = page->mainFrame();
    frame->setHtml(html);
    title = frame->title();
    page->deleteLater();
#else
    int titleBegin = html.indexOf("<title>");
    if(titleBegin > 0) {
        int titleEnd = html.indexOf("</", titleBegin);
        title = html.mid(titleBegin + 7, titleEnd - titleBegin - 7);
    }
#endif
    return title;
}
Esempio n. 2
0
void AlertWebApp::updateContentRect()
{
    QWebFrame* frame = page()->page()->mainFrame();
    QWebElement el = frame->findFirstElement("[x-palm-popup-content]");
    QRect r;
    if (!el.isNull()) {
        r = el.geometry();
    	r.setLeft(MAX(0, r.left()));
	    r.setRight(MIN(r.right(), (int) m_windowWidth));
    	r.setTop(MAX(0, r.top()));
	    r.setBottom(MIN(r.bottom(), (int) m_windowHeight));
    }

	m_channel->sendAsyncMessage(new ViewHost_Alert_SetContentRect(routingId(),
																  r.left(), r.right(), 
																  r.top(), r.bottom()));
}
	void CustomWebView::handleAutoscroll ()
	{
		if (!ScrollDelta_)
			return;

		AccumulatedScrollShift_ += ScrollDelta_;

		if (std::abs (AccumulatedScrollShift_) >= 1)
		{
			QWebFrame *mf = page ()->mainFrame ();
			QPoint pos = mf->scrollPosition ();
			pos += QPoint (0, AccumulatedScrollShift_);
			mf->setScrollPosition (pos);

			AccumulatedScrollShift_ -= static_cast<int> (AccumulatedScrollShift_);
		}
	}
Esempio n. 4
0
void HelpPage::onHandleUnsupportedContent(QNetworkReply *reply)
{
    // sub resource of this page
    if (m_loadingUrl != reply->url()) {
        qWarning() << "Resource" << reply->url().toEncoded() << "has unknown Content-Type, will be ignored.";
        reply->deleteLater();
        return;
    }

    // set a default error string we are going to display
    QString errorString = HelpViewer::tr("Unknown or unsupported Content!");
    if (reply->error() == QNetworkReply::NoError) {
        // try to open the url using using the desktop service
        if (QDesktopServices::openUrl(reply->url())) {
            reply->deleteLater();
            return;
        }
        // seems we failed, now we show the error page inside creator
    } else {
        errorString = reply->errorString();
    }

    // setup html
    const QString html = QString::fromLatin1(g_htmlPage).arg(g_percent1, errorString,
        HelpViewer::tr("Error loading: %1").arg(reply->url().toString()), g_percent4, g_percent5, g_percent6,
        g_percent7);

    // update the current layout
    QList<QWebFrame*> frames;
    frames.append(mainFrame());
    while (!frames.isEmpty()) {
        QWebFrame *frame = frames.takeFirst();
        if (frame->url() == reply->url()) {
            frame->setHtml(html, reply->url());
            return;
        }

        QList<QWebFrame *> children = frame->childFrames();
        foreach (QWebFrame *frame, children)
            frames.append(frame);
    }

    if (m_loadingUrl == reply->url())
        mainFrame()->setHtml(html, reply->url());
}
Esempio n. 5
0
void KWebKitPart::slotMainFrameLoadFinished (bool ok)
{
    if (!ok || !m_doLoadFinishedActions)
        return;

    m_doLoadFinishedActions = false;

    if (!m_emitOpenUrlNotify) {
        m_emitOpenUrlNotify = true; // Save history once page loading is done.
    }

    // If the document contains no <title> tag, then set it to the current url.
    if (m_webView->title().trimmed().isEmpty()) {
        // If the document title is empty, then set it to the current url
        const QUrl url (m_webView->url());
        const QString caption (url.toString((QUrl::RemoveQuery|QUrl::RemoveFragment)));
        emit setWindowCaption(caption);

        // The urlChanged signal is emitted if and only if the main frame
        // receives the title of the page so we manually invoke the slot as a
        // work around here for pages that do not contain it, such as text
        // documents...
        slotUrlChanged(url);
    }

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

    if (!frame || frame->url() == *globalBlankUrl)
        return;

    // Set the favicon specified through the <link> tag...
    if (WebKitSettings::self()->favIconsEnabled()
        && !frame->page()->settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) {
        const QWebElement element = frame->findFirstElement(QL1S("head>link[rel=icon], "
                                                                 "head>link[rel=\"shortcut icon\"]"));
        QUrl shortcutIconUrl;
        if (!element.isNull()) {
            shortcutIconUrl = frame->baseUrl().resolved(QUrl(element.attribute("href")));
            //kDebug() << "setting favicon to" << shortcutIconUrl;
            m_browserExtension->setIconUrl(shortcutIconUrl);
        }
    }

    slotFrameLoadFinished(ok);
}
Esempio n. 6
0
void WebView::applyEncoding()
{
	if (m_encoding_in_progress)
		return;

	if (webPage() && webPage()->mainWindow())
	{
		QString enc = webPage()->mainWindow()->m_currentEncoding;
		if (enc.isEmpty())
			return;

		if (enc == m_current_encoding && m_current_encoding_url == url() )
			return;

		QWebPage *page = webPage();
		if (!page)
			return;

		QWebFrame *mainframe = page->mainFrame();
		if (!mainframe)
			return;

		QString html = mainframe->toHtml();

		QTextCodec *codec = QTextCodec::codecForName( enc.toAscii() );
		if (!codec)
			return;

		QTextDecoder *decoder = codec->makeDecoder();
		if (!decoder)
			return;

		m_encoding_in_progress = true;
		m_current_encoding = enc;
		m_current_encoding_url = url();
		QString output = decoder->toUnicode(html.toAscii());
		mainframe->setHtml(output, mainframe->url());

		QList<QWebFrame *> children = mainframe->childFrames();
		foreach(QWebFrame *frame, children)
		{
			html = frame->toHtml();
			output = decoder->toUnicode(html.toAscii());
			frame->setHtml(output, frame->url());
		}
Esempio n. 7
0
void WebView::paintEvent(QPaintEvent * event)
{
    QWebView::paintEvent(event);

    QWebFrame *frameff = page()->mainFrame();

    int hValue = frameff->scrollBarValue(Qt::Horizontal);
    int vValue = frameff->scrollBarValue(Qt::Vertical);

    if (hValue != _lastHorizontalValue || vValue != _lastVerticalValue)
    {
        _lastHorizontalValue = hValue;
        _lastVerticalValue = vValue;

        emit scrollValueChanged();
    }

}
Esempio n. 8
0
void tst_QWebView::reusePage()
{
    if (!QDir(TESTS_SOURCE_DIR).exists())
        QSKIP(QString("This test requires access to resources found in '%1'").arg(TESTS_SOURCE_DIR).toLatin1().constData(), SkipAll);

    QDir::setCurrent(TESTS_SOURCE_DIR);

    QFETCH(QString, html);
    QWebView* view1 = new QWebView;
    QPointer<QWebPage> page = new QWebPage;
    view1->setPage(page);
    page->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
    QWebFrame* mainFrame = page->mainFrame();
    mainFrame->setHtml(html, QUrl::fromLocalFile(TESTS_SOURCE_DIR));
    if (html.contains("</embed>")) {
        // some reasonable time for the PluginStream to feed test.swf to flash and start painting
        waitForSignal(view1, SIGNAL(loadFinished(bool)), 2000);
    }
Esempio n. 9
0
void CWebNewsLoader::on_webPageLoadFinished(bool res)
{
        if (res)
        {
            QWebFrame *frame = m_webView->page()->mainFrame();

            QWebElement document = frame->documentElement();
            QWebElementCollection elements = document.findAll("li a");

            QStringList newsList;
            foreach (QWebElement element, elements)
                newsList.append(element.toPlainText());

            emit newsListLoadFinished(m_webView->url().toString(), newsList);
        }

        delete m_webView;
}
Esempio n. 10
0
QString NoteItem::getTitle()
{
    if(m_readOnly)
        return m_title->text();
    else {
        QString title = m_titleEdit->text();
        if(title == "" || title == tr("Untitled")) {
            if(m_rich) {
                QWebFrame* mainFrame = m_webView->page()->mainFrame();
                QWebFrame* iframe = mainFrame->childFrames()[0];
                title = MainWindow::getTitleFromContent(iframe->toPlainText());
            }
            else
                title = MainWindow::getTitleFromContent(m_textEdit->toPlainText());
        }
        return title;
    }
}
Esempio n. 11
0
void wrapInFunction()
{

    //! [0]
    // ...
    QWebFrame *frame = myWebPage->mainFrame();
    frame->addToJavaScriptWindowObject("someNameForMyObject", myObject);
    // ...
    //! [0]
#if 0
    //! [1]
    {
        width: ...,
        height: ...,
        toDataURL: function() { ... },
        assignToHTMLImageElement: function(element) { ... }
        toImageData: function() { ... }
    }
Esempio n. 12
0
void FlickScroll::activateOn(QWebView *webView)
{

        QWebFrame *frame = webView->page()->mainFrame();
        frame->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
        frame->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);

        webView->installEventFilter(this);

        int removed = flickScroll_pm->flickData.remove(webView);
        printf("FlickScroll::activateOn removed %d items from hash\n", removed);

        FlickData * newFlickData = new FlickData();
        flickScroll_pm->flickData[webView] = newFlickData;
        newFlickData->widget = webView;
        newFlickData->state = FlickData::Steady;

}
Esempio n. 13
0
bool PropertyChanger::set_repaint_throttle(QString value)
{
	QWebFrame* pFrame = static_cast < QWebFrame* >  ( this->parent() );
	QWebPage* pPage = NULL;

	if ( pFrame != NULL )
		pPage = pFrame->page();
	else
		return false;

	if ( pPage == NULL )
		return false;

//TODO: check values
	pPage->setProperty("_q_RepaintThrottlingPreset", value);

	return true;
}
Esempio n. 14
0
bool LoadItem::invoke() const
{
    //qDebug() << ">>>LoadItem::invoke";
    Q_ASSERT(m_webPage);

    QWebFrame* frame = 0;
    const QString t = target();
    if (t.isEmpty())
        frame = m_webPage->mainFrame();
    else
        frame = findFrameNamed(t, m_webPage->mainFrame());

    if (!frame)
        return false;

    frame->load(url());
    return true;
}
Esempio n. 15
0
void lmcMessageLog::appendPublicMessage(QString* lpszUserId, QString* lpszUserName, QString* lpszMessage,
										QDateTime *pTime, QFont *pFont, QColor *pColor) {
	QString html = QString::null;
	bool localUser = (lpszUserId->compare(localId) == 0);

	decodeMessage(lpszMessage);

	QString fontStyle = getFontStyle(pFont, pColor, localUser);

	if(lpszUserId->compare(lastId) != 0) {
		outStyle = !outStyle;
		html = outStyle ? themeData.outMsg : themeData.inMsg;

		//	get the avatar image for this user from the cache folder
		QString filePath = participantAvatars.value(*lpszUserId);
		//	if image not found, use the default avatar image for this user
		QString iconPath = QFile::exists(filePath) ? QUrl::fromLocalFile(filePath).toString() : "qrc"AVT_DEFAULT;

		html.replace("%iconpath%", iconPath);
		html.replace("%sender%", *lpszUserName);
		html.replace("%time%", getTimeString(pTime));
		html.replace("%style%", fontStyle);
		html.replace("%message%", *lpszMessage);

		QWebFrame* frame = page()->mainFrame();
		QWebElement document = frame->documentElement();
		QWebElement body = document.findFirst("body");
		body.appendInside(html);
	} else {
		html = outStyle ? themeData.outNextMsg : themeData.inNextMsg;
		html.replace("%time%", getTimeString(pTime));
		html.replace("%style%", fontStyle);
		html.replace("%message%", *lpszMessage);

		QWebFrame* frame = page()->mainFrame();
		QWebElement document = frame->documentElement();
		QWebElement body = document.findFirst("body");
		QWebElement last = body.lastChild();
		QWebElement insert = last.findFirst("div#insert");
		insert.replace(html);
	}

	hasData = true;
}
Esempio n. 16
0
void FrameInit::handleFrameLayoutComplete()
{
        QString str;
        str += QString("%1,%2,%3,%4,").arg(m_frame->geometry().height())
            .arg(m_frame->geometry().width())
            .arg(m_frame->geometry().x())
            .arg(m_frame->geometry().y());
        str += m_frame->frameName();
        //qDebug() << "frameLayoutComplete" << m_frame->frameName() << " " << m_frame->url() << ", " << str; 
        OPNET::OpNetwork::instance()->sendSysCall(MSG_EMBED_FRAME, 1, str.toAscii());

        QPoint p = m_frame->pos();
        QWebFrame *frame = m_frame;
        while(frame->parentFrame() != NULL) {
            frame = frame->parentFrame();
            p += frame->pos();
        }
        //qDebug() << "  pos = " << p;
    }
Esempio n. 17
0
void
CutyCapt::saveSnapshot() {
    QWebFrame *mainFrame = mPage->mainFrame();
    
    // TODO: sometimes contents/viewport can have size 0x0
    // in which case saving them will fail. This is likely
    // the result of the method being called too early. So
    // far I've been unable to find a workaround, except
    // using --delay with some substantial wait time. I've
    // tried to resize multiple time, make a fake render,
    // check for other events... This is primarily a problem
    // under my Ubuntu virtual machine.

    mPage->setViewportSize( mainFrame->contentsSize() );
    
    if (mPage->fixedWidth != 0 && mPage->fixedHeight != 0) {
      mPage->setViewportSize(QSize(mPage->fixedWidth, mPage->fixedHeight));
    }

    if (this-mPage->mSelector.count() > 0) {
        QWebElementCollection collection = mainFrame->findAllElements(this->mPage->mSelector);

        QJsonObject obj;
        QJsonArray elements;

        foreach(QWebElement elem, collection) {
            QJsonObject e;
            e["id"] = elem.attribute("id");

            if (this->mPage->mRetina) {
                e["x"] = elem.geometry().x() * 2;
                e["y"] = elem.geometry().y() * 2;
                e["width"] = elem.geometry().width() * 2;
                e["height"] = elem.geometry().height() * 2;
            }else{
                e["x"] = elem.geometry().x();
                e["y"] = elem.geometry().y();
                e["width"] = elem.geometry().width();
                e["height"] = elem.geometry().height();
            }

            elements.append(e);
        }
Esempio n. 18
0
void InfoView::loaded(bool ok) {
    if (!ok || !shouldShow()) {
        deleteLater();
        return;
    }
    
    QDesktopWidget* desktop = Application::getInstance()->desktop();
    QWebFrame* mainFrame = page()->mainFrame();
    
    int height = mainFrame->contentsSize().height() > desktop->height() ?
        desktop->height() * MAX_DIALOG_HEIGHT_RATIO :
        mainFrame->contentsSize().height();
    
    resize(mainFrame->contentsSize().width(), height);
    move(desktop->screen()->rect().center() - rect().center());
    setWindowTitle(title());
    setAttribute(Qt::WA_DeleteOnClose);
    show();
}
Esempio n. 19
0
void LinkFetcher::fetchLinks(bool ok)
{
    if (!ok) {
        emit finished(false);
        return;
    }
    QString javaScript = scriptOrScriptName;
    if (scriptOrScriptName.endsWith(".js")) {
        QFile file(scriptOrScriptName);
        if (!file.open(QIODevice::ReadOnly)) {
            emit finished(false);
            return;
        }
        javaScript = QString::fromUtf8(file.readAll());
    }
    QWebFrame *frame = page.mainFrame();
    frame->evaluateJavaScript(javaScript);
    emit finished(true);
}
Esempio n. 20
0
void MainWindow::arduinoExec(const QString &action) {
    QStringList arguments;

    // Check if temp path exists
    QDir dir(settings->tmpDirName());
    if (dir.exists() == false) {
        dir.mkdir(settings->tmpDirName());
    }

    // Check if tmp file exists
    QFile tmpFile(settings->tmpFileName());
    if (tmpFile.exists()) {
        tmpFile.remove();
    }
    tmpFile.open(QIODevice::WriteOnly);

    // Read code
    QWebFrame *mainFrame = ui->webView->page()->mainFrame();
    QVariant codeVariant = mainFrame->evaluateJavaScript(
                "Blockly.Arduino.workspaceToCode();");
    QString codeString = codeVariant.toString();

    // Write code to tmp file
    tmpFile.write(codeString.toLocal8Bit());
    tmpFile.close();

    // Verify code
    arguments << action;
    // Board parameter
    if (ui->boardBox->count() > 0) {
        arguments << "--board" << ui->boardBox->currentText();
    }
    // Port parameter
    if (ui->serialPortBox->count() > 0) {
        arguments << "--port" << ui->serialPortBox->currentText();
    }
    arguments << settings->tmpFileName();
    process->start(settings->arduinoIdePath(), arguments);

    // Show messages
    ui->messagesWidget->show();
}
Esempio n. 21
0
void KWebKitPart::slotLoadFinished(bool ok)
{
    bool pending = false;

    if (m_doLoadFinishedActions) {
        updateActions();
        QWebFrame* frame = (page() ? page()->currentFrame() : 0);
        if (ok &&
            frame == page()->mainFrame() &&
            !frame->findFirstElement(QL1S("head>meta[http-equiv=refresh]")).isNull()) {
            if (WebKitSettings::self()->autoPageRefresh()) {
                pending = true;
            } else {
                frame->page()->triggerAction(QWebPage::StopScheduledPageRefresh);
            }
        }
    }

    emit completed ((ok && pending));
}
Esempio n. 22
0
void downloader::render(QString rawHtml)
{
    currencyLoaded.clear();
    rateLoaded.clear();
    QWebFrame *mainFrame = webPage.mainFrame();
    mainFrame->setHtml(rawHtml);
    QWebElement documentElement = mainFrame->documentElement();
    QWebElementCollection elements = documentElement.findAll("#content > div:nth-child(1) > div > div.col2.pull-right.module.bottomMargin > div.moduleContent > table:nth-child(4) > tbody > tr");

    int i = 0;
    foreach (QWebElement element, elements)
    {
        currency.push_back(element.findFirst("td:nth-child(1)").toInnerXml());
        rate.push_back(element.findFirst("td:nth-child(3) > a").toInnerXml());
//        qDebug()<< currency[i+(elements.count()*downloadCount)]+"\t\t"+rate[i+(elements.count()*downloadCount)]+"\n";

        currencyLoaded.push_back(currency[i+(elements.count()*downloadCount)]);
        rateLoaded.push_back(rate[i+(elements.count()*downloadCount)]);
        i++;
    }
Esempio n. 23
0
void WebPage::handleUnsupportedContent(QNetworkReply *reply)
{
    if (reply->error() == QNetworkReply::NoError) {
        BrowserApplication::downloadManager()->handleUnsupportedContent(reply);
        return;
    }

    QFile file(QLatin1String(":/notfound.html"));
    bool isOpened = file.open(QIODevice::ReadOnly);
    Q_ASSERT(isOpened);
    QString title = tr("Error loading page: %1").arg(reply->url().toString());
    QString html = QString(QLatin1String(file.readAll()))
                        .arg(title)
                        .arg(reply->errorString())
                        .arg(reply->url().toString());

    QBuffer imageBuffer;
    imageBuffer.open(QBuffer::ReadWrite);
    QIcon icon = view()->style()->standardIcon(QStyle::SP_MessageBoxWarning, 0, view());
    QPixmap pixmap = icon.pixmap(QSize(32, 32));
    if (pixmap.save(&imageBuffer, "PNG")) {
        html.replace(QLatin1String("IMAGE_BINARY_DATA_HERE"),
                     QString(QLatin1String(imageBuffer.buffer().toBase64())));
    }

    QList<QWebFrame*> frames;
    frames.append(mainFrame());
    while (!frames.isEmpty()) {
        QWebFrame *frame = frames.takeFirst();
        if (frame->url() == reply->url()) {
            frame->setHtml(html, reply->url());
            return;
        }
        QList<QWebFrame *> children = frame->childFrames();
        foreach(QWebFrame *frame, children)
            frames.append(frame);
    }
    if (m_loadingUrl == reply->url()) {
        mainFrame()->setHtml(html, reply->url());
    }
}
Esempio n. 24
0
void WebView::Private::showFullScreen()
{
    //normal -> full

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

    //スクロールバー非表示
    QWebElement element = frame->findFirstElement(QStringLiteral("body"));
    if (element.isNull()) {
        qDebug() << "failed find target";
        return;
    }

    QHash<QString, QString> properties;
    properties.insert(QStringLiteral("overflow"), QStringLiteral("hidden"));
    if(body.isEmpty()){
        foreach (const QString &key, properties.keys()) {
            body.insert(key, element.styleProperty(key, QWebElement::InlineStyle));
        }
        qDebug() << element.styleProperty(QStringLiteral("overflow"), QWebElement::InlineStyle);
    }
Esempio n. 25
0
void
OdfView::slotLoadFinished(bool ok) {
    if (!ok) return;
    loaded = true;
    QWebFrame *frame = page()->mainFrame();
    QString js =
            "var originalReadFileSync = runtime.readFileSync;"
            "runtime.readFileSync = function (path, encoding) {"
            "    if (path.substr(path.length - 3) === '.js') {"
            "        return originalReadFileSync.apply(runtime,"
            "           [path, encoding]);"
            "    }"
            "    return nativeio.readFileSync(path, encoding);"
            "};"
            "runtime.read = function (path, offset, length, callback) {"
            "    var data = nativeio.read(path, offset, length);"
            "    data = runtime.byteArrayFromString(data, 'binary');"
            "    callback(nativeio.error()||null, data);"
            "};";
    frame->evaluateJavaScript(js);
}
Esempio n. 26
0
    // scroll by dx, dy
    // return true if the widget was scrolled
    bool scrollWidget(const int dx, const int dy)
    {
        QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget);
        if (scrollArea) {
            const int x = scrollArea->horizontalScrollBar()->value();
            const int y = scrollArea->verticalScrollBar()->value();
            scrollArea->horizontalScrollBar()->setValue(x - dx);
            scrollArea->verticalScrollBar()->setValue(y - dy);
            return (scrollArea->horizontalScrollBar()->value() != x
                    || scrollArea->verticalScrollBar()->value() != y);
        }

        QWebView *webView = qobject_cast<QWebView*>(widget);
        if (webView) {
            QWebFrame *frame = webView->page()->mainFrame();
            const QPoint position = frame->scrollPosition();
            frame->setScrollPosition(position - QPoint(dx, dy));
            return frame->scrollPosition() != position;
        }
        return false;
    }
Esempio n. 27
0
void PhpWebView::showXPath()
{
	QWebFrame *frame = page()->frameAt(rightClick);
	if (frame)
	{
		XPathInspector *dlg = new XPathInspector(this, this);

		if (selectedElements.count() == 0)
		{
			QPoint point = frame->scrollPosition();
			point += rightClick;
            QWebElement elem = getElementByCoord(frame->documentElement(), point);
			dlg->setActiveElement(elem);
		}
		else
		{
			dlg->setFewActiveElements(selectedElements);
		}
		dlg->show();
	}
}
Esempio n. 28
0
void FormExtractor::submit()
{
    QWebFrame *frame = ui.webView->page()->mainFrame();

    QWebElement firstName = frame->findFirstElement("#firstname");
    QWebElement lastName = frame->findFirstElement("#lastname");
    QWebElement maleGender = frame->findFirstElement("#genderMale");
    QWebElement femaleGender = frame->findFirstElement("#genderFemale");
    QWebElement updates = frame->findFirstElement("#updates");

    ui.firstNameEdit->setText(firstName.evaluateJavaScript("this.value").toString());
    ui.lastNameEdit->setText(lastName.evaluateJavaScript("this.value").toString());

    if (maleGender.evaluateJavaScript("this.checked").toBool())
        ui.genderEdit->setText(maleGender.evaluateJavaScript("this.value").toString());
    else if (femaleGender.evaluateJavaScript("this.checked").toBool())
        ui.genderEdit->setText(femaleGender.evaluateJavaScript("this.value").toString());

    if (updates.evaluateJavaScript("this.checked").toBool())
        ui.updatesEdit->setText("Yes");
    else
        ui.updatesEdit->setText("No");

    // In mobile devices, change the tab when the data has been submitted
    #if defined Q_OS_SYMBIAN || defined Q_WS_HILDON || defined Q_WS_MAEMO_5 || defined Q_WS_SIMULATOR
        ui.tabWidget->setCurrentWidget(ui.tabData);
    #endif
}
// 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);
      }
   }
}
Esempio n. 30
0
ItemWeb::ItemWeb(const QString &html, QWidget *parent)
    : QWebView(parent)
    , ItemWidget(this)
{
    QWebFrame *frame = page()->mainFrame();
    frame->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
    frame->setScrollBarPolicy(Qt::Vertical,   Qt::ScrollBarAlwaysOff);

    const QFont &defaultFont = font();
    settings()->setFontFamily(QWebSettings::StandardFont, defaultFont.family());
    // DPI resolution can be different than the one used by this widget.
    QWidget* window = QApplication::desktop()->screen();
    int dpi = window->logicalDpiX();
    int pt = defaultFont.pointSize();
    settings()->setFontSize(QWebSettings::DefaultFontSize, pt * dpi / 72);

    history()->setMaximumItemCount(0);

    QPalette pal(palette());
    pal.setBrush(QPalette::Base, Qt::transparent);
    page()->setPalette(pal);
    setAttribute(Qt::WA_OpaquePaintEvent, false);

    connect( frame, SIGNAL(loadFinished(bool)),
             this, SLOT(onItemChanged()) );
    connect( frame, SIGNAL(contentsSizeChanged(QSize)),
             this, SLOT(onItemChanged()) );

    connect( frame, SIGNAL(loadFinished(bool)),
             this, SLOT(onItemChanged()) );
    connect( frame, SIGNAL(contentsSizeChanged(QSize)),
             this, SLOT(onItemChanged()) );

    // Selecting text copies it to clipboard.
    connect( this, SIGNAL(selectionChanged()), SLOT(onSelectionChanged()) );

    setHtml(html);
    updateSize();
    updateItem();
}