コード例 #1
0
ファイル: qwebframeproto.cpp プロジェクト: xtuple/qt-client
void QWebFrameProto::setScrollPosition(const QPoint & pos)
{
  scriptDeprecated("QWebFrame will not be available in future versions");
  QWebFrame *item = qscriptvalue_cast<QWebFrame*>(thisObject());
  if (item)
    item->setScrollPosition(pos);
}
コード例 #2
0
ファイル: session_tab.cpp プロジェクト: mlapshin/revisor
bool SessionTab::sendMouseEvent(QMouseEvent::Type type, const QPoint& point, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
{
  QWebFrame* frame = webPage->mainFrame();
  QPoint relativePoint;

  unsigned int scrollX = 0;
  unsigned int scrollY = 0;

  QPoint savedScrollPos = frame->scrollPosition();

  unsigned int w = frame->geometry().width() - frame->scrollBarGeometry(Qt::Vertical).width();
  unsigned int h = frame->geometry().height() - frame->scrollBarGeometry(Qt::Horizontal).height();

  // unsigned int maxScrollX = frame->scrollBarMaximum(Qt::Horizontal);
  // unsigned int maxScrollY = frame->scrollBarMaximum(Qt::Vertical);

  if (point.x() > (w - 1)) {
    scrollX = point.x() - w + 1;
    relativePoint.setX(w - 1);
  } else {
    relativePoint.setX(point.x());
  }

  if (point.y() > (h - 1)) {
    scrollY = point.y() - h + 1;
    relativePoint.setY(h - 1);
  } else {
    relativePoint.setY(point.y());
  }

  QMouseEvent event(type, relativePoint, button, buttons, modifiers);
  frame->setScrollPosition(QPoint(scrollX, scrollY));

  bool ret = sendEvent(&event);

  qDebug() << "Mouse event" << type << relativePoint;
  frame->setScrollPosition(savedScrollPos);

  return ret;
}
コード例 #3
0
void
message_view::page_down()
{
  QWebFrame* frame = m_bodyv->page()->mainFrame();
  if (!frame)
    return;
  QPoint pos = frame->scrollPosition();
  int y = m_bodyv->geometry().height() + pos.y();
  if (y > frame->contentsSize().height()-frame->geometry().height())
    y = frame->contentsSize().height()-frame->geometry().height();
  pos.setY(y);
  frame->setScrollPosition(pos);
}
コード例 #4
0
ファイル: customwebview.cpp プロジェクト: Akon32/leechcraft
	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_);
		}
	}
コード例 #5
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;
    }
コード例 #6
0
ファイル: WebTabPanel.cpp プロジェクト: mrrooster/Yasst
void WebTabPanel::handleLoadFinished(bool) {
	QWebFrame *frame = web->page()->mainFrame();
	QString url=frame->url().toString();
	//QMessageBox::information (0,"assdf",tr("Handle load finished, state: ")+QString::number(state)+tr(", url: ")+frame->url().toString());
	infoArea->hide();
	progress->hide();
	loadingText->hide();
	if (url=="http://twitter.com/login") {
		if (!tweets->getAuthenticatingFetcher()) {
			state=-1;
			return;
		}
		QString user = tweets->getAuthenticatingFetcher()->getUsername();
		QString pass = tweets->getAuthenticatingFetcher()->getPassword();

		// Homepage login
		//frame->evaluateJavaScript(tr("var f=document.getElementById('signin');document.getElementById('username').value=\"")+user+tr("\";document.getElementById('password').value=\"")+pass+tr("\";f.submit();"));
		// redirect page login
		loadingText->setText("Please wait, signing in to twitter...");
		frame->evaluateJavaScript(tr("var f=document.forms[1];f['username_or_email'].value=\"")+user+tr("\";f['session[password]'].value=\"")+pass+tr("\";f.submit();"));
		state=1;//loggin in

	} else if (url=="http://twitter.com/invitations/find_on_twitter") {
		// Now at being passed to twitter state
		state=2;//Searching
		web->show();
		frame->evaluateJavaScript(tr("function $(s){return document.getElementById(s);}function __yasstlinks() {var i=['home_link','profile_link','settings_link','help_link','sign_out_link'];for (var b in i) {b=$(i[b]);b.style.display='none';}i=$('footer').firstChild.nextSibling.nextSibling.nextSibling.firstChild.nextSibling;while(i.nextSibling){i.parentNode.removeChild(i.nextSibling);}}__yasstlinks();"));
		frame->setScrollPosition(QPoint(0,0));
		//QTimer::singleShot(1000,this,SLOT(resetScroll()));
		web->setEnabled(true);
		handleTimeout();
	} else if (url.startsWith(tr("http://twitter.com/"))) {
		state=3;//Search results or user info.
		frame->evaluateJavaScript(tr("function $(s){return document.getElementById(s);}function __yasstlinks() {var i=['home_link','profile_link','settings_link','help_link','sign_out_link'];for (var b in i) {b=$(i[b]);b.style.display='none';}i=$('footer').firstChild.nextSibling.nextSibling.nextSibling.firstChild.nextSibling;while(i.nextSibling){i.parentNode.removeChild(i.nextSibling);}}__yasstlinks();"));
		frame->evaluateJavaScript(tr("function __yasst() {i=$('timeline');i.innerHTML='<style>.follow-actions input{display:none;} a.__yasst-followsingle {text-decoration:none; visibility:visible !important; -webkit-appearance: none; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -webkit-box-align: center; -webkit-box-sizing: border-box; -webkit-rtl-ordering: logical; -webkit-user-select: text; background-color: rgb(230, 230, 230); border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; color: black; cursor: pointer; display: inline-block; font-family: \\'Lucida Grande\\'; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; height: 23px; letter-spacing: normal; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 8px; padding-right: 8px; padding-top: 4px; text-align: center; text-indent: 0px; text-shadow: none; text-transform: none; vertical-align: top; white-space: pre; width: 48px; word-spacing: 0px;} a:hover.__yasst-follow,a:hover.__yasst-followsingle{background-color: rgb(204, 204, 204);} a.__yasst-follow{visibility: visible !important; -webkit-appearance: none; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -webkit-box-align: center; -webkit-box-sizing: border-box; -webkit-rtl-ordering: logical; -webkit-user-select: text; background-color: rgb(230, 230, 230); border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; color: black; cursor: pointer; display: none; font-family: \\'Lucida Grande\\'; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; height: auto; letter-spacing: normal; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 8px; padding-right: 8px; padding-top: 4px; text-align: center; text-indent: 0px; text-shadow: none; text-transform: none; vertical-align: top; white-space: pre; width: 80px; word-spacing: 0px;}</style>'+$('timeline').innerHTML;var e=document.getElementById('follow_control');if (e!=null) {var u=e.parentNode.parentNode.className;u=u.substr(u.lastIndexOf(' ')+1);var l=document.createElement('div');l.innerHTML='<a class=\\\"__yasst-followsingle\\\" href=\\\"twitter:/follow/'+u+'\\\">Follow</a>';e.parentNode.parentNode.insertBefore(l,e.parentNode);} else {		e=i.getElementsByClassName('follow-actions');for(b=0;b<e.length;b++) {var u=e[b].parentNode.parentNode.className;u=u.substr(u.lastIndexOf(' ')+6);var l=document.createElement('div');var c=e[b].childNodes;for(var x=0;x<c.length;x++) {if (c[x].nodeName=='FORM') {var d=c[x].action.substr(c[x].action.lastIndexOf('/')+1);var f=c[x].firstChild.childNodes;l.innerHTML='<a class=\\\"__yasst-follow\\\" href=\\\"twitter:/follow/'+u+'\\\">Follow</a>';for(var y=0;y<f.length;y++) {if(f[y].nodeName=='INPUT'&&f[y].type=='submit') {f[y].parentNode.insertBefore(l,f[y]);}}}}}}}__yasst();"));
		web->setEnabled(true);
		//frame->setScrollPosition(QPoint(0,0));
		//QTimer::singleShot(1000,this,SLOT(resetScroll()));
	}
}
コード例 #7
0
ファイル: webview.cpp プロジェクト: hytham/qt-webkit-kiosk
void WebView::scrollHome()
{
    QWebFrame* frame = this->page()->mainFrame();
    frame->setScrollPosition(QPoint(0, 0));
}
コード例 #8
0
ファイル: webview.cpp プロジェクト: hytham/qt-webkit-kiosk
void WebView::scrollPageUp()
{
    QWebFrame* frame = this->page()->mainFrame();
    QPoint point = frame->scrollPosition();
    frame->setScrollPosition(point - QPoint(0, this->page()->mainFrame()->geometry().height()));
}
コード例 #9
0
ファイル: webview.cpp プロジェクト: hytham/qt-webkit-kiosk
void WebView::scrollUp()
{
    QWebFrame* frame = this->page()->mainFrame();
    QPoint point = frame->scrollPosition();
    frame->setScrollPosition(point - QPoint(0, 100));
}
コード例 #10
0
ファイル: webview.cpp プロジェクト: hytham/qt-webkit-kiosk
void WebView::scrollEnd()
{
    QWebFrame* frame = this->page()->mainFrame();
    frame->setScrollPosition(QPoint(0, frame->contentsSize().height()));
}
コード例 #11
0
 void setScrollPosition(const QPoint& point, const QPoint& /* overShootDelta */)
 {
     QWebFrame* frame = currentFrame();
     if (frame)
         frame->setScrollPosition(point);
 }