Ejemplo n.º 1
0
bool HistoryChatView::onContextMenu(ChatView *view, QMenu *menu, const QWebHitTestResult &result)
{
  ChatId id(view->id());
  if (id.type() != ChatId::ChannelId && id.type() != ChatId::UserId)
    return false;

  const QWebElement block = result.enclosingBlockElement();
  if (!block.hasClass("blocks") || block.hasClass("removed"))
    return false;

  const QWebElement container = block.parent();
  const qint64 mdate          = container.attribute(LS("data-mdate")).toLongLong();

  if (!mdate)
    return false;

  id.init(container.attribute(LS("id")).toLatin1());
  id.setDate(mdate);
  if (id.type() != ChatId::MessageId)
    return false;

  const int permissions = this->permissions(HistoryDB::get(id));
  if (permissions == NoPermissions)
    return false;

  if (permissions & Remove) {
    QVariantList data;
    data << view->id() << (id.hasOid() ? ChatId::toBase32(id.oid().byteArray()) : id.toString());

    menu->insertAction(menu->actions().first(), removeAction(data));
  }
  return true;
}
Ejemplo n.º 2
0
void MainWindow::finished_loading(bool ok)
{
	if(!ok)
std::cout << "LOAD FINISH NOT OK!\n\n";
	QString output;
	QWebElement body;
	progress = 100;
	adjust_title();
	QWebFrame *frame = uimw->webView->page()->mainFrame();
	QWebElement document = frame->documentElement();
	QWebElement element = document.firstChild();
	while(!element.isNull())
	{
		if(element.tagName() == "BODY")
		{
			output = element.toInnerXml();
			if(output == "ok\n")
			{
				QNetworkCookieJar *cj = uimw->webView->page()->networkAccessManager()->cookieJar();
				QList<QNetworkCookie> cookies = cj->cookiesForUrl(testauth);
				for(QList<QNetworkCookie>::const_iterator i = cookies.begin() ; i != cookies.end() ; i++ )
				{
					std::cout << "Set-Cookie: ";
					QByteArray ba = i->toRawForm();
					std::cout.write(ba.data(), ba.count());
					std::cout << "\r\n";
				}
				exit(0);
			}
		}
		element = element.nextSibling();
	}
	this->show();
}
Ejemplo n.º 3
0
void PmrWindowWidget::filter(const QString &pFilter)
{
    // Filter our list of exposures and remove any duplicates (they will be
    // 'reintroduced' in the next step)

    QStringList filteredExposureNames = mExposureNames.filter(QRegularExpression(pFilter, QRegularExpression::CaseInsensitiveOption));

    mNumberOfFilteredExposures = filteredExposureNames.count();

    filteredExposureNames.removeDuplicates();

    // Update our message and show/hide the relevant exposures

    page()->mainFrame()->documentElement().findFirst("p[id=message]").setInnerXml(message());

    QWebElement trElement = page()->mainFrame()->documentElement().findFirst(QString("tbody[id=exposures]")).firstChild();
    QWebElement ulElement;

    for (int i = 0, iMax = mExposureNames.count(); i < iMax; ++i) {
        if (mExposureDisplayed[i] != filteredExposureNames.contains(mExposureNames[i])) {
            QString displayValue = mExposureDisplayed[i]?"none":"table-row";

            trElement.setStyleProperty("display", displayValue);

            ulElement = trElement.firstChild().firstChild().nextSibling();

            if (ulElement.hasClass("visible"))
                ulElement.setStyleProperty("display", displayValue);

            mExposureDisplayed[i] = !mExposureDisplayed[i];
        }

        trElement = trElement.nextSibling();
    }
}
Ejemplo n.º 4
0
FightBox MWBotWin::getDuelResult() {
	FightBox res;
	int mylife;
	int enlife;
	QWebElement elm;
	res.enemy = getStat("div.fighter2","td.fighter2-cell");
	clickElement("i.icon.icon-forward");				// forward button
	mylife = frm->findFirstElement("span#fighter1-life").toPlainText().split("/").first().trimmed().toInt();
	enlife = frm->findFirstElement("span#fighter2-life").toPlainText().split("/").first().trimmed().toInt();
	res.result = (mylife > 0) ? 1 : ((enlife > 0) ? 0 : 2);		// duel result (0,1,2 = lose,win,draw)
	res.items = getDuelResultMain();
	elm = frm->findFirstElement("div.backlink div.button div.c");
	if (!elm.isNull()) {
		clickElement(elm);
	}
	res.items.append(getDuelResultExtra());
	return res;
}
Ejemplo n.º 5
0
void ShadowGUI::setNumConnections(int count)
{
    QWebElement connectionsIcon = documentFrame->findFirstElement("#connectionsIcon");

    QString icon;
    switch(count)
    {
    case 0:          icon = "qrc:///icons/connect_0"; break;
    case 1: case 2:  icon = "qrc:///icons/connect_1"; break;
    case 3: case 4:  icon = "qrc:///icons/connect_2"; break;
    case 5: case 6:  icon = "qrc:///icons/connect_3"; break;
    case 7: case 8:  icon = "qrc:///icons/connect_4"; break;
    case 9: case 10: icon = "qrc:///icons/connect_5"; break;
    default:         icon = "qrc:///icons/connect_6"; break;
    }
    connectionsIcon.setAttribute("src", icon);
    connectionsIcon.setAttribute("title", tr("%n active connection(s) to ZirkCoin network", "", count));
}
Ejemplo n.º 6
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;
}
Ejemplo n.º 7
0
FightBox MWBotWin::getGroupResult() {
	FightBox res;
	QWebElement elm;
	QString str;
	elm = frm->findFirstElement("form#fightGroupForm h3 div.group2");
	str = elm.toPlainText();
	res.enemy.name = str.split("(").first().trimmed();
	res.enemy.type = elm.findFirst("i").attribute("class");
	res.enemy.level = -1;
	res.result = str.contains("(0/") ? 1 : 0;
	res.items = getGroupResultMain();
	elm = frm->findFirstElement("td.log div.result div.button div.c");
	if (!elm.isNull()) {
		clickElement(elm);
	}
	res.items.append(getDuelResultExtra());
	return res;
}
Ejemplo n.º 8
0
QTreeWidgetItem* XPathInspector::findTreeItemAndSelect(const QWebElement & elem)
{
	QList<QWebElement> patharr;
	QWebElement current = elem;
	while (!current.isNull())
	{
		patharr.prepend(current);
		current = current.parent();
	}

	QTreeWidgetItem *topitem = NULL;
	for (int i=0; i<tree->topLevelItemCount(); i++)
	{
		QTreeWidgetItem *item = tree->topLevelItem(i);
		QWebElement node = item->data(0, Qt::UserRole).value<QWebElement>();
		if (node == patharr.at(0))
		{
			tree->expandItem(item);
			topitem = item;
			break;
		}
	}

	for (int i=1; i<patharr.count(); i++)	
	{
		if (topitem != NULL)
		{
			for (int j=0; j<topitem->childCount(); j++)
			{
				QWebElement node = topitem->child(j)->data(0, Qt::UserRole).value<QWebElement>();
				if (patharr.at(i) == node)
				{
					topitem = topitem->child(j);
					tree->expandItem(topitem);
					break;
				}
			}
		}
	}

	topitem->setSelected(true);
	return topitem;
}
Ejemplo n.º 9
0
//static
bool Page_Login::fit(const QWebElement& doc) {
//    qDebug("* CHECK Page_Login");
    QWebElement loginForm = doc.findFirst("FORM[id=loginForm]");
    if (loginForm.isNull()) {
//        qDebug("Page_Login does not fit (has no loginForm)");
        return false;
    }
    QWebElement do_cmd = loginForm.findFirst("INPUT[name=do_cmd]");
    if (do_cmd.isNull()) {
//        qDebug("Page_Login does not fit (has no do_cmd)");
        return false;
    }
    if (do_cmd.attribute("value") != "login") {
//        qDebug("Page_Login does not fit (do_cmd != login)");
        return false;
    }
//    qDebug("Page_Login fits");
    return true;
}
Ejemplo n.º 10
0
void LyricsManiaAPI::onGetLyricPageResult()
{
    QNetworkReply* reply = qobject_cast<QNetworkReply*>(QObject::sender());

    bool found = false;
    Lyric* lyric = 0;

    if (reply->error() != QNetworkReply::NoError) {
        qCritical() << "Cannot fetch lyric";
    } else {
        QWebPage page;
        page.settings()->setAttribute(QWebSettings::AutoLoadImages, false);
        page.settings()->setAttribute(QWebSettings::JavascriptEnabled, false);
        page.mainFrame()->setHtml(reply->readAll());

        QWebElement lyricbox = page.mainFrame()->findFirstElement("div[class=lyrics-body]");

        if (lyricbox.isNull()) {
            qCritical() << "Cannot find lyric text in HTML page";
        } else {
            // Remove the video div
            lyricbox.findFirst(QStringLiteral("div")).removeFromDocument();
            // Remove the song title
            lyricbox.findFirst(QStringLiteral("strong")).removeFromDocument();

            lyric = lyrics.take(reply);

            if (!lyric) {
                qCritical() << "Got an invalid lyric object!";
            } else {
                lyric->setText(lyricbox.toPlainText());

                found = true;
            }
        }
    }

    qDebug() << "Lyric found:" << found;
    Q_EMIT lyricFetched(lyric, found);

    reply->deleteLater();
}
Ejemplo n.º 11
0
bool MainWindow::disableSelection()
{
    if (mainSettings->value("view/disable_selection").toBool()) {
        qDebug("Try to disable text selection...");

        // Then webkit loads page and it's "empty" - empty html DOM loaded...
        // So we wait before real page DOM loaded...
        QWebElement bodyElem = view->page()->mainFrame()->findFirstElement("body");
        if (!bodyElem.isNull() && !bodyElem.toInnerXml().trimmed().isEmpty()) {
            QWebElement headElem = view->page()->mainFrame()->findFirstElement("head");
            if (headElem.isNull() || headElem.toInnerXml().trimmed().isEmpty()) {
                qDebug("... html head not loaded ... wait...");
                return false;
            }

            //qDebug() << "... head element content:\n" << headElem.toInnerXml();

            // http://stackoverflow.com/a/5313735
            QString content;
            content = "<style type=\"text/css\">\n";
            content += "body, div, p, span, h1, h2, h3, h4, h5, h6, caption, td, li, dt, dd {\n";
            content += " -moz-user-select: none;\n";
            content += " -khtml-user-select: none;\n";
            content += " -webkit-user-select: none;\n";
            content += " user-select: none;\n";
            content += " }\n";
            content += "</style>\n";

            // Ugly hack, but it's works...
            if (!headElem.toInnerXml().contains(content)) {
                headElem.setInnerXml(headElem.toInnerXml() + content);
                qDebug("... html head loaded ... hack inserted...");
            } else {
                qDebug("... html head loaded ... hack already inserted...");
            }

            //headElem = view->page()->mainFrame()->findFirstElement("head");
            //qDebug() << "... head element content after:\n" << headElem.toInnerXml() ;

        } else {
            qDebug("... html body not loaded ... wait...");
            return false;
        }
    }

    return true;
}
Ejemplo n.º 12
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++;
    }
Ejemplo n.º 13
0
/*!
    Inserts the given \a element before this element.

    If \a element is the child of another element, it is re-parented to the
    parent of this element.

    Calling this function on a null element does nothing.

    \sa appendInside(), prependInside(), appendOutside()
*/
void QWebElement::prependOutside(const QWebElement &element)
{
    if (!m_element || element.isNull())
        return;

    if (!m_element->parent())
        return;

    ExceptionCode exception = 0;
    m_element->parent()->insertBefore(element.m_element, m_element, exception);
}
Ejemplo n.º 14
0
extern QVariantMap toMap(QWebElement el, QStringList css_attrs) {
    QVariantMap map;
    map["isNull"] = false;
    map["classes"] = QVariant(el.classes());
    map["tagName"] = QVariant(el.tagName());
    QRect rect = el.geometry();

    QVariantMap geo;

    geo["width"] = rect.width();
    geo["height"] = rect.height();
    geo["x"] = rect.x();
    geo["y"] = rect.y();
    map["geometry"] = QVariant(geo);

    QVariantMap attrs;
    QStringList attributes = el.attributeNames();
    foreach(QString name,attributes) {
        attrs[name] = el.attribute(name);
    }
Ejemplo n.º 15
0
static bool isEditableElement(QWebPage* page)
{
    const QWebFrame* frame = (page ? page->currentFrame() : 0);
    QWebElement element = (frame ? frame->findFirstElement(QL1S(":focus")) : QWebElement());
    if (!element.isNull()) {
        const QString tagName(element.tagName());
        if (tagName.compare(QL1S("textarea"), Qt::CaseInsensitive) == 0) {
            return true;
        }
        const QString type(element.attribute(QL1S("type")).toLower());
        if (tagName.compare(QL1S("input"), Qt::CaseInsensitive) == 0
            && (type.isEmpty() || type == QL1S("text") || type == QL1S("password"))) {
            return true;
        }
        if (element.evaluateJavaScript("this.isContentEditable").toBool()) {
            return true;
        }
    }
    return false;
}
Ejemplo n.º 16
0
void HtmlExtractor::moveTemplates(const QString &path)
{
    MakeDirectory(path);
    QDir dir(path);
    QWebElementCollection elements = getDocument().findAll("[type=\"text/template\"]");
    if(elements.count())
    {
        for(QWebElementCollection::iterator it = elements.begin(), end=elements.end(); it!=end; ++it)
        {
            QWebElement element = *it;
            QString filename = element.attribute("id").replace("_tpl",".tpl");
            qDebug()<<"moving element : "<<filename;
            move(element, dir.filePath(filename), false);
        }
    }
    else
    {
        qDebug()<<"no element found";
    }
}
Ejemplo n.º 17
0
bool Page_Game_Dozor_LowHealth::fit(const QWebElement& doc) {
//    qDebug("* CHECK Page_Game_Dozor_LowHealth");
    if (doc.findFirst("DIV[id=body] DIV[class=grbody]")
            .toPlainText().trimmed().startsWith(
                u8("У вас слишком мало здоровья."))) {
//        qDebug("CHECK Page_Game_Dozor_LowHealth fits");
        return true;
    }
//    qDebug("CHECK Page_Game_Dozor_LowHealth doesn't fit");
    return false;
}
Ejemplo n.º 18
0
void EnmlFormatter::fixObjectNode(QWebElement &e) {
    QString type = e.attribute("type", "");
    if (type == "application/pdf") {
        qint32 lid = e.attribute("lid", "0").toInt();
        e.removeAttribute("width");
        e.removeAttribute("height");
        e.removeAttribute("lid");
        e.removeAttribute("border");
        if (lid>0) {
            resources.append(lid);
             e.setOuterXml(e.toOuterXml().replace("<object", "<en-media").replace("</object", "</en-media"));
        }
        removeInvalidAttributes(e);
    } else {
        e.removeFromDocument();
    }
}
Ejemplo n.º 19
0
void MWBotWin::checkPolice() {
	QWebElement elm = frm->findFirstElement("a.bubble span.text");
	if (elm.toPlainText().contains(trUtf8("Задержан за бои"))) {
		loadPath(QStringList() << "square" << "police");
		getFastRes();
		if (!opt.police.fine || (info.ore < 5)) {
			if (state.botWork) start();
			log(trUtf8("Вы задержаны. Бот остановлен"));
		} else {
			clickElement("form#fine-form div.button div.c");
			log(trUtf8("Заплачен штраф в полиции"));
		}
		if (opt.police.relations && (info.ore > 20)) {
			elm = frm->findFirstElement("form.police-relations div.button div.c");
			if (!elm.isNull()) {
				clickElement("form.police-relations div.button div.c");
				log(trUtf8("Связи в полиции продлены"));
			}
		}
	}
}
Ejemplo n.º 20
0
/*!
    Prepends \a element as the element's first child.

    If \a element is the child of another element, it is re-parented to this
    element. If \a element is a child of this element, then its position in
    the list of children is changed.

    Calling this function on a null element does nothing.

    \sa appendInside(), prependOutside(), appendOutside()
*/
void QWebElement::prependInside(const QWebElement &element)
{
    if (!m_element || element.isNull())
        return;

    ExceptionCode exception = 0;

    if (m_element->hasChildNodes())
        m_element->insertBefore(element.m_element, m_element->firstChild(), exception);
    else
        m_element->appendChild(element.m_element, exception);
}
Ejemplo n.º 21
0
void MarbleLegendBrowser::setRadioCheckedProperty( const QString& value, const QString& name , bool checked )
{
#ifndef MARBLE_NO_WEBKIT
    QWebElement box = page()->mainFrame()->findFirstElement("input[value="+value+']');
    QWebElementCollection boxes = page()->mainFrame()->findAllElements("input[name="+name+']');
    QString currentValue="";
    for(int i=0; i<boxes.count(); ++i) {
        currentValue = boxes.at(i).attribute("value");
        d->m_checkBoxMap[currentValue]=false;
        emit toggledShowProperty( currentValue, false );
    }
    if (!box.isNull()) {
        if (checked != d->m_checkBoxMap[value]) {
            d->m_checkBoxMap[value] = checked;
            emit toggledShowProperty( value, checked );
        }
    }

    update();
#endif
}
Ejemplo n.º 22
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);
    }
Ejemplo n.º 23
0
static void parseDelayClass(const QWebElement &element, StationScheduleItem &item)
{
    if (!element.isNull()) {
        QWebElement image = element.findFirst("img");
        if (!image.isNull()) {
            int delayClass = 42;
            QString imageName = image.attribute("src");
            if (!imageName.isEmpty()) {
                QRegExp delayClassRegexp("pallinoRit([0-9])\\.png");
                int pos = delayClassRegexp.indexIn(imageName);
                qDebug() << "regexp matched at pos:" << pos << "match:" << delayClassRegexp.cap(0);
                delayClass =  (pos >= 0) ? delayClassRegexp.cap(1).toInt() : 0;
            }
            item.setDelayClass(delayClass);
        } else {
            qDebug() << "img not found";
        }
    } else {
        qDebug() << "div.bloccotreno not found";
    }
}
Ejemplo n.º 24
0
	QString CustomWebView::URLToProperString (const QUrl& url)
	{
		QString string = url.toString ();
		QWebElement equivs = page ()->mainFrame ()->
				findFirstElement ("meta[http-equiv=\"Content-Type\"]");
		if (!equivs.isNull ())
		{
			QString content = equivs.attribute ("content", "text/html; charset=UTF-8");
			const QString charset = "charset=";
			int pos = content.indexOf (charset);
			if (pos >= 0)
				PreviousEncoding_ = content.mid (pos + charset.length ()).toLower ();
		}

		if (PreviousEncoding_ != "utf-8" &&
				PreviousEncoding_ != "utf8" &&
				!PreviousEncoding_.isEmpty ())
			string = url.toEncoded ();

		return string;
	}
Ejemplo n.º 25
0
StationScheduleItem parseResult(const QWebElement &result)
{
    StationScheduleItem item;

    QWebElement current = result.findFirst("h2");
    if (!current.isNull()) {
        item.setTrain(current.toPlainText());
    }
    parseDetailsUrl(result, item);
    current = result.findFirst("div.bloccotreno");
    parseDelayClass(current, item);
    QString rawText = current.toPlainText();
    parseTrain(rawText, item);

    qDebug() << "train:" << item.train();
    qDebug() << "delayClass:" << item.delayClass();
    qDebug() << "detailsUrl:" << item.detailsUrl();
    qDebug() << "departureStation:" << item.departureStation();
    qDebug() << "departureTime:" << item.departureTime();
    qDebug() << "arrivalStation:" << item.arrivalStation();
    qDebug() << "arrivalTime:" << item.arrivalTime();
    qDebug() << "expectedPlatform:" << item.expectedPlatform();
    qDebug() << "actualPlatform:" << item.actualPlatform();
    qDebug() << "delay:" << item.delay();
    return item;
}
Ejemplo n.º 26
0
void AuthenticationDialog::loadFinished()
{
//     Q_D(AuthenticationDialog);
    QUrl url = d->webView->url();

    if (url.host() == "www.facebook.com" && url.path() == "/login.php") {
        if (d->username.isEmpty() && d->password.isEmpty()) {
            return;
        }

        QWebFrame *frame = d->webView->page()->mainFrame();
        if (!d->username.isEmpty()) {
            QWebElement email = frame->findFirstElement("input#email");
            if (!email.isNull()) {
                email.setAttribute("value", d->username);
            }
        }

        if (!d->password.isEmpty()) {
            QWebElement passd = frame->findFirstElement("input#pass");
            if (!passd.isNull()) {
                passd.setAttribute("value", d->password);
            }
        }
        return;
    }
}
Ejemplo n.º 27
0
void lmcMessageLog::removeMessageLog(QString divClass) {
	QWebFrame* frame = page()->mainFrame();
	QWebElement document = frame->documentElement();
	QWebElement body = document.findFirst("body");
	QWebElement element = body.findFirst("div." + divClass);
	element.removeFromDocument();
}
Ejemplo n.º 28
0
QWebElement MyWebView::FindCloserContainer(QWebElement &elem)
{
	// find by elem id
	bool       bIsContainer = false;
    QString strTemp = elem.attribute("id");
    WDomElem * welem = m_pMainWindow->m_treemodel.getElemByName (strTemp);
	// check if valid parent
	if (welem)
	{
		QDomElement delem = welem->getElem();
		if (delem.attribute(g_strClassAttr).compare("WContainerWidget") == 0 ||
			delem.attribute(g_strClassAttr).compare("WAnchor"         ) == 0 ||
			delem.attribute(g_strClassAttr).compare("WGroupBox"       ) == 0 ||
			delem.attribute(g_strClassAttr).compare("WPanel"          ) == 0 ||
			delem.attribute(g_strClassAttr).compare("WMenuItem"       ) == 0 ||
			delem.attribute(g_strClassAttr).compare("WStackedWidget"  ) == 0 ||
			delem.attribute(g_strClassAttr).compare("WTabItem"        ) == 0)
		{
			bIsContainer = true;
		}
	}
	// if container return, else keep looking
	if (bIsContainer)
	{
		return elem;
	}
	else
	{
		if (!elem.parent().isNull())
		{
            QWebElement welemTemp = elem.parent();
            return FindCloserContainer(welemTemp);
		}
		else
		{
			return QWebElement();
		}
	}
}
Ejemplo n.º 29
0
	void CustomWebPage::handleLoadFinished (bool ok)
	{
		QWebElement body = mainFrame ()->findFirstElement ("body");

		if (body.findAll ("*").count () == 1 &&
				body.firstChild ().tagName () == "IMG")
			mainFrame ()->evaluateJavaScript ("function centerImg() {"
					"var img = document.querySelector('img');"
					"img.style.left = Math.floor((document.width - img.width) / 2) + 'px';"
					"img.style.top =  Math.floor((document.height - img.height) / 2) + 'px';"
					"img.style.position = 'absolute';"
					"}"
					"window.addEventListener('resize', centerImg, false);"
					"centerImg();");

		Util::DefaultHookProxy_ptr proxy (new Util::DefaultHookProxy ());
		emit hookLoadFinished (proxy, this, ok);
		if (proxy->IsCancelled ())
			return;

		emit delayedFillForms (mainFrame ());
	}
Ejemplo n.º 30
0
	void UserFiltersModel::blockImage ()
	{
		QAction *blocker = qobject_cast<QAction*> (sender ());
		if (!blocker)
		{
			qWarning () << Q_FUNC_INFO
				<< "sender is not a QAction*"
				<< sender ();
			return;
		}

		QUrl blockUrl = blocker->property ("CleanWeb/URL").value<QUrl> ();
		QWebView *view = qobject_cast<QWebView*> (blocker->
					property ("CleanWeb/View").value<QObject*> ());
		if (InitiateAdd (blockUrl.toString ()) && view)
		{
			QWebFrame *frame = view->page ()->mainFrame ();
			QWebElement elem = frame->findFirstElement ("img[src=\"" + blockUrl.toEncoded () + "\"]");
			if (!elem.isNull ())
				elem.removeFromDocument ();
		}
	}