Changeset 651 for trunk/examples/webkit/googlechat
- Timestamp:
- Mar 8, 2010, 12:52:58 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.2 (added) merged: 650 /branches/vendor/nokia/qt/current merged: 649 /branches/vendor/nokia/qt/4.6.1 removed
- Property svn:mergeinfo changed
-
trunk/examples/webkit/googlechat/form.ui
r561 r651 49 49 <set>Qt::AlignCenter</set> 50 50 </property> 51 <property name="wordWrap"> 52 <bool>true</bool> 53 </property> 51 54 </widget> 52 55 </item> … … 160 163 <property name="text"> 161 164 <string>Login</string> 165 </property> 166 <property name="default"> 167 <bool>true</bool> 162 168 </property> 163 169 </widget> -
trunk/examples/webkit/googlechat/googlechat.cpp
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 81 81 } 82 82 83 QString GoogleChat::evalJS(const QString &js) { 84 QWebFrame *frame = form.webView->page()->mainFrame(); 85 return frame->evaluateJavaScript(js).toString(); 83 QWebElement GoogleChat::document() const { 84 return form.webView->page()->mainFrame()->documentElement(); 86 85 } 87 86 … … 113 112 114 113 QString userEmail = userName + "@gmail.com"; 115 evalJS(QString("document.getElementById('Email').value = \"%1\";").arg(userEmail)); 116 evalJS(QString("document.getElementById('Passwd').value = \"%1\";").arg(password)); 117 evalJS("document.getElementById('gaia_loginform').submit();"); 114 115 document().findFirst("#Email").setAttribute("value", userEmail); 116 document().findFirst("#Passwd").setAttribute("value", password); 117 document().findFirst("#gaia_loginform").evaluateJavaScript("this.submit();"); 118 118 119 } 119 120 … … 125 126 126 127 if (ok) { 127 Q String s1 = evalJS("document.getElementById('Email').name");128 Q String s2 = evalJS("document.getElementById('Passwd').name");129 Q String s3 = evalJS("document.getElementById('gaia_loginform').id");130 if ( s1 == "Email" && s2 == "Passwd" && s3 == "gaia_loginform") {128 QWebElement email = document().findFirst("#Email"); 129 QWebElement passwd = document().findFirst("#Passwd"); 130 QWebElement loginForm = document().findFirst("#gaia_loginform"); 131 if (!email.isNull() && !passwd.isNull() && !loginForm.isNull()) { 131 132 form.stackedWidget->setCurrentIndex(1); 133 form.userNameEdit->setFocus(); 132 134 form.webView->disconnect(); 133 135 return; … … 140 142 void GoogleChat::hideElements() 141 143 { 142 evalJS("var e = document.getElementsByClassName('footer-footer')[0]; e.parentElement.removeChild(e)");143 evalJS("var e = document.getElementsByClassName('title-bar-bg title-bar')[0]; e.parentElement.removeChild(e)");144 document().findFirst(".footer-footer").removeFromDocument(); 145 document().findFirst(".title-bar-bg .title-bar").removeFromDocument(); 144 146 QTimer::singleShot(2000, this, SLOT(hideElements())); 145 147 } … … 153 155 } else { 154 156 // check for any error message 155 QString c = evalJS("document.getElementsByClassName('errormsg').length"); 156 if (c == "0") { 157 158 QWebElement e = document().findFirst(".errormsg"); 159 if (e.isNull()) { 157 160 form.stackedWidget->setCurrentIndex(2); 158 161 QTimer::singleShot(500, this, SLOT(hideElements())); … … 160 163 } 161 164 162 QString err = "Unknown login failure."; 163 if (c == "1") { 164 err = evalJS("document.getElementsByClassName('errormsg')[0].textContent"); 165 QString err = "Unknown login failure."; 166 const QString errorMessage = e.toPlainText(); 167 if (!errorMessage.isEmpty()) { 168 err = errorMessage; 165 169 err = err.simplified(); 166 170 } -
trunk/examples/webkit/googlechat/googlechat.h
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 41 41 42 42 #include <QWidget> 43 #include <QWebElement> 43 44 44 45 #include "ui_form.h" … … 54 55 void showStatus(const QString &msg); 55 56 void showError(const QString &msg); 56 Q String evalJS(const QString &js);57 QWebElement document() const; 57 58 58 59 private slots: -
trunk/examples/webkit/googlechat/main.cpp
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com)
Note:
See TracChangeset
for help on using the changeset viewer.