diff options
Diffstat (limited to 'examples/webkit')
-rw-r--r-- | examples/webkit/fancybrowser/mainwindow.h | 2 | ||||
-rwxr-xr-x | examples/webkit/formextractor/form.html | 24 | ||||
-rw-r--r-- | examples/webkit/formextractor/formextractor.cpp | 29 | ||||
-rw-r--r-- | examples/webkit/formextractor/formextractor.h | 4 | ||||
-rw-r--r-- | examples/webkit/formextractor/mainwindow.cpp | 2 | ||||
-rw-r--r-- | examples/webkit/previewer/mainwindow.cpp | 6 |
6 files changed, 30 insertions, 37 deletions
diff --git a/examples/webkit/fancybrowser/mainwindow.h b/examples/webkit/fancybrowser/mainwindow.h index 0e880cd..ecd2308 100644 --- a/examples/webkit/fancybrowser/mainwindow.h +++ b/examples/webkit/fancybrowser/mainwindow.h @@ -41,8 +41,8 @@ #include <QtGui> -QT_BEGIN_NAMESPACE class QWebView; +QT_BEGIN_NAMESPACE class QLineEdit; QT_END_NAMESPACE diff --git a/examples/webkit/formextractor/form.html b/examples/webkit/formextractor/form.html index 18ddff1..6b0bbde 100755 --- a/examples/webkit/formextractor/form.html +++ b/examples/webkit/formextractor/form.html @@ -1,22 +1,4 @@ -<html><script> -function extractFormValues() -{ - var firstName = document.getElementById("firstname").value; - var lastName = document.getElementById("lastname").value; - var maleGender = document.getElementById("genderMale"); - var femaleGender = document.getElementById("genderFemale"); - - var gender = ""; - if (maleGender.checked) - gender = maleGender.value; - else if (femaleGender.checked) - gender = femaleGender.value; - - var updates = document.getElementById("updates").checked; - - formExtractor.setValues(firstName, lastName, gender, updates); -} -</script><body> +<html><body> <h1> The Green People Book Club </h1> @@ -24,7 +6,7 @@ The Green People Book Club <p> Welcome to The Green People Book Club. Please register to obtain a membership with us. </p> - <form onsubmit="extractFormValues()"> + <form onsubmit="formExtractor.submit()"> <table> <tbody><tr> <td> @@ -61,4 +43,4 @@ Welcome to The Green People Book Club. Please register to obtain a membership wi <input type="submit" value="Submit"> </form> -</body></html>
\ No newline at end of file +</body></html> diff --git a/examples/webkit/formextractor/formextractor.cpp b/examples/webkit/formextractor/formextractor.cpp index a1c2df3..ead88b1 100644 --- a/examples/webkit/formextractor/formextractor.cpp +++ b/examples/webkit/formextractor/formextractor.cpp @@ -41,6 +41,8 @@ #include "formextractor.h" +#include <QWebElement> + FormExtractor::FormExtractor(QWidget *parent, Qt::WFlags flags) : QWidget(parent, flags) { @@ -55,17 +57,28 @@ FormExtractor::~FormExtractor() { } -void FormExtractor::setValues(const QString &firstName, const QString &lastName, - const QString &gender, bool updates) +void FormExtractor::submit() { - ui.firstNameEdit->setText(firstName); - ui.lastNameEdit->setText(lastName); - ui.genderEdit->setText(gender); + QWebFrame *frame = ui.webView->page()->mainFrame(); - if (updates == false) - ui.updatesEdit->setText("No"); - else + 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.scriptableProperty("value").toString()); + ui.lastNameEdit->setText(lastName.scriptableProperty("value").toString()); + + if (maleGender.scriptableProperty("checked").toBool()) + ui.genderEdit->setText(maleGender.scriptableProperty("value").toString()); + else if (femaleGender.scriptableProperty("checked").toBool()) + ui.genderEdit->setText(femaleGender.scriptableProperty("value").toString()); + + if (updates.scriptableProperty("checked").toBool()) ui.updatesEdit->setText("Yes"); + else + ui.updatesEdit->setText("No"); } void FormExtractor::populateJavaScriptWindowObject() diff --git a/examples/webkit/formextractor/formextractor.h b/examples/webkit/formextractor/formextractor.h index e39cf8a..58a54b7 100644 --- a/examples/webkit/formextractor/formextractor.h +++ b/examples/webkit/formextractor/formextractor.h @@ -55,9 +55,7 @@ public: ~FormExtractor(); public slots: - void setValues(const QString &firstName, const QString &lastName, - const QString &gender, bool updates); - + void submit(); void populateJavaScriptWindowObject(); private: diff --git a/examples/webkit/formextractor/mainwindow.cpp b/examples/webkit/formextractor/mainwindow.cpp index 4b3ab0c..bc92f85 100644 --- a/examples/webkit/formextractor/mainwindow.cpp +++ b/examples/webkit/formextractor/mainwindow.cpp @@ -54,7 +54,7 @@ void MainWindow::createActions() { exitAct = new QAction(tr("E&xit"), this); exitAct->setStatusTip(tr("Exit the application")); - exitAct->setShortcut(tr("Ctrl+Q")); + exitAct->setShortcuts(QKeySequence::Quit); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); aboutAct = new QAction(tr("&About"), this); diff --git a/examples/webkit/previewer/mainwindow.cpp b/examples/webkit/previewer/mainwindow.cpp index 32ce01c..0bef996 100644 --- a/examples/webkit/previewer/mainwindow.cpp +++ b/examples/webkit/previewer/mainwindow.cpp @@ -61,7 +61,7 @@ MainWindow::MainWindow() void MainWindow::createActions() { openAct = new QAction(tr("&Open..."), this); - openAct->setShortcut(tr("Ctrl+O")); + openAct->setShortcuts(QKeySequence::Open); openAct->setStatusTip(tr("Open an existing HTML file")); connect(openAct, SIGNAL(triggered()), this, SLOT(open())); @@ -72,13 +72,13 @@ void MainWindow::createActions() //! [1] saveAct = new QAction(tr("&Save"), this); - saveAct->setShortcut(tr("Ctrl+S")); + saveAct->setShortcuts(QKeySequence::Save); saveAct->setStatusTip(tr("Save the HTML file to disk")); connect(saveAct, SIGNAL(triggered()), this, SLOT(save())); exitAct = new QAction(tr("E&xit"), this); exitAct->setStatusTip(tr("Exit the application")); - exitAct->setShortcut(tr("Ctrl+Q")); + exitAct->setShortcuts(QKeySequence::Quit); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); aboutAct = new QAction(tr("&About"), this); |