summaryrefslogtreecommitdiffstats
path: root/examples/webkit
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2009-04-24 11:34:15 (GMT)
committeraxis <qt-info@nokia.com>2009-04-24 11:34:15 (GMT)
commit8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76 (patch)
treea17e1a767a89542ab59907462206d7dcf2e504b2 /examples/webkit
downloadQt-8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76.zip
Qt-8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76.tar.gz
Qt-8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76.tar.bz2
Long live Qt for S60!
Diffstat (limited to 'examples/webkit')
-rwxr-xr-xexamples/webkit/formextractor/form.html64
-rw-r--r--examples/webkit/formextractor/formextractor.cpp74
-rw-r--r--examples/webkit/formextractor/formextractor.h67
-rw-r--r--examples/webkit/formextractor/formextractor.pro18
-rw-r--r--examples/webkit/formextractor/formextractor.qrc5
-rw-r--r--examples/webkit/formextractor/formextractor.ui159
-rw-r--r--examples/webkit/formextractor/main.cpp53
-rw-r--r--examples/webkit/formextractor/mainwindow.cpp87
-rw-r--r--examples/webkit/formextractor/mainwindow.h75
-rw-r--r--examples/webkit/previewer/main.cpp53
-rw-r--r--examples/webkit/previewer/mainwindow.cpp197
-rw-r--r--examples/webkit/previewer/mainwindow.h87
-rw-r--r--examples/webkit/previewer/previewer.cpp65
-rw-r--r--examples/webkit/previewer/previewer.h65
-rw-r--r--examples/webkit/previewer/previewer.pro15
-rw-r--r--examples/webkit/previewer/previewer.ui99
-rw-r--r--examples/webkit/webkit.pro11
17 files changed, 1194 insertions, 0 deletions
diff --git a/examples/webkit/formextractor/form.html b/examples/webkit/formextractor/form.html
new file mode 100755
index 0000000..18ddff1
--- /dev/null
+++ b/examples/webkit/formextractor/form.html
@@ -0,0 +1,64 @@
+<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>
+<h1>
+The Green People Book Club
+</h1>
+
+<p>
+Welcome to The Green People Book Club. Please register to obtain a membership with us.
+</p>
+ <form onsubmit="extractFormValues()">
+ <table>
+ <tbody><tr>
+ <td>
+ First name:
+ </td>
+ <td>
+ <input type="text" id="firstname">
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Last name:
+ </td>
+ <td>
+ <input type="text" id="lastname">
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Gender:
+ </td>
+ <td>
+ <input type="radio" name="gender" id="genderMale" value="Male"> Male
+ <input type="radio" name="gender" id="genderFemale" value="Female"> Female
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <input type="checkbox" id="updates" value="receive">
+ Check here if you would like to receive regular updates from us:
+ </td>
+ </tr>
+ </tbody></table>
+ <input type="submit" value="Submit">
+ </form>
+
+</body></html> \ No newline at end of file
diff --git a/examples/webkit/formextractor/formextractor.cpp b/examples/webkit/formextractor/formextractor.cpp
new file mode 100644
index 0000000..d5ecc29
--- /dev/null
+++ b/examples/webkit/formextractor/formextractor.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "formextractor.h"
+
+FormExtractor::FormExtractor(QWidget *parent, Qt::WFlags flags)
+ : QWidget(parent, flags)
+{
+ ui.setupUi(this);
+ ui.webView->setUrl(QUrl("qrc:/form.html"));
+ connect(ui.webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()),
+ this, SLOT(populateJavaScriptWindowObject()));
+ resize(300, 300);
+}
+
+FormExtractor::~FormExtractor()
+{
+}
+
+void FormExtractor::setValues(const QString &firstName, const QString &lastName,
+ const QString &gender, bool updates)
+{
+ ui.firstNameEdit->setText(firstName);
+ ui.lastNameEdit->setText(lastName);
+ ui.genderEdit->setText(gender);
+
+ if (updates == false)
+ ui.updatesEdit->setText("No");
+ else
+ ui.updatesEdit->setText("Yes");
+}
+
+void FormExtractor::populateJavaScriptWindowObject()
+{
+ ui.webView->page()->mainFrame()->addToJavaScriptWindowObject("formExtractor", this);
+}
diff --git a/examples/webkit/formextractor/formextractor.h b/examples/webkit/formextractor/formextractor.h
new file mode 100644
index 0000000..5b11565
--- /dev/null
+++ b/examples/webkit/formextractor/formextractor.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FORMEXTRACTOR_H
+#define FORMEXTRACTOR_H
+
+#include <QtGui/QWidget>
+#include <QWebFrame>
+#include "ui_formextractor.h"
+
+class FormExtractor : public QWidget
+{
+ Q_OBJECT
+
+public:
+ FormExtractor(QWidget *parent = 0, Qt::WFlags flags = 0);
+ ~FormExtractor();
+
+public slots:
+ void setValues(const QString &firstName, const QString &lastName,
+ const QString &gender, bool updates);
+
+ void populateJavaScriptWindowObject();
+
+private:
+ Ui::Form ui;
+};
+
+#endif // FORMEXTRACTOR_H
diff --git a/examples/webkit/formextractor/formextractor.pro b/examples/webkit/formextractor/formextractor.pro
new file mode 100644
index 0000000..ddd39b4
--- /dev/null
+++ b/examples/webkit/formextractor/formextractor.pro
@@ -0,0 +1,18 @@
+QT += webkit
+TARGET = formExtractor
+TEMPLATE = app
+SOURCES += main.cpp \
+ formextractor.cpp \
+ mainwindow.cpp
+HEADERS += formextractor.h \
+ mainwindow.h
+FORMS += formextractor.ui
+RESOURCES += formextractor.qrc
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/webkit/formextractor
+sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro form.html images
+sources.path = $$[QT_INSTALL_EXAMPLES]/webkit/formextractor
+INSTALLS += target sources
+
+include($$QT_SOURCE_TREE/examples/examplebase.pri)
diff --git a/examples/webkit/formextractor/formextractor.qrc b/examples/webkit/formextractor/formextractor.qrc
new file mode 100644
index 0000000..e35f4b2
--- /dev/null
+++ b/examples/webkit/formextractor/formextractor.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+ <qresource>
+ <file>form.html</file>
+ </qresource>
+ </RCC> \ No newline at end of file
diff --git a/examples/webkit/formextractor/formextractor.ui b/examples/webkit/formextractor/formextractor.ui
new file mode 100644
index 0000000..5c4afec
--- /dev/null
+++ b/examples/webkit/formextractor/formextractor.ui
@@ -0,0 +1,159 @@
+<ui version="4.0" >
+ <class>Form</class>
+ <widget class="QWidget" name="Form" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>680</width>
+ <height>218</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout" >
+ <item>
+ <widget class="QGroupBox" name="webFormGroupBox" >
+ <property name="title" >
+ <string>Web Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2" >
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout" >
+ <item>
+ <widget class="QWebView" name="webView" >
+ <property name="minimumSize" >
+ <size>
+ <width>200</width>
+ <height>150</height>
+ </size>
+ </property>
+ <property name="maximumSize" >
+ <size>
+ <width>400</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="url" >
+ <url>
+ <string>about:blank</string>
+ </url>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>28</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="dataGroupBox" >
+ <property name="title" >
+ <string>Extracted Data</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3" >
+ <item>
+ <layout class="QFormLayout" name="formLayout" >
+ <property name="fieldGrowthPolicy" >
+ <enum>QFormLayout::FieldsStayAtSizeHint</enum>
+ </property>
+ <item row="0" column="0" >
+ <widget class="QLabel" name="firstNameLabel" >
+ <property name="text" >
+ <string>First Name</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QLineEdit" name="firstNameEdit" >
+ <property name="readOnly" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="lastNameLabel" >
+ <property name="text" >
+ <string>Last Name</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QLineEdit" name="lastNameEdit" >
+ <property name="readOnly" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="genderLabel" >
+ <property name="text" >
+ <string>Gender</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QLineEdit" name="genderEdit" >
+ <property name="readOnly" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="updatesLabel" >
+ <property name="text" >
+ <string>Receive Updates</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <widget class="QLineEdit" name="updatesEdit" >
+ <property name="readOnly" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>20</width>
+ <height>24</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>QWebView</class>
+ <extends>QWidget</extends>
+ <header>QtWebKit/QWebView</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/webkit/formextractor/main.cpp b/examples/webkit/formextractor/main.cpp
new file mode 100644
index 0000000..aa7847d
--- /dev/null
+++ b/examples/webkit/formextractor/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QApplication>
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ Q_INIT_RESOURCE(formextractor);
+ QApplication app(argc, argv);
+ MainWindow mainWindow;
+ mainWindow.setWindowTitle("Form Extractor");
+ mainWindow.show();
+ return app.exec();
+}
diff --git a/examples/webkit/formextractor/mainwindow.cpp b/examples/webkit/formextractor/mainwindow.cpp
new file mode 100644
index 0000000..222d9b2
--- /dev/null
+++ b/examples/webkit/formextractor/mainwindow.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ createActions();
+ createMenus();
+ centralWidget = new FormExtractor(this);
+ setCentralWidget(centralWidget);
+}
+
+void MainWindow::createActions()
+{
+ exitAct = new QAction(tr("E&xit"), this);
+ exitAct->setStatusTip(tr("Exit the application"));
+ exitAct->setShortcut(tr("Ctrl+Q"));
+ connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
+
+ aboutAct = new QAction(tr("&About"), this);
+ aboutAct->setStatusTip(tr("Show the application's About box"));
+ connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
+
+ aboutQtAct = new QAction(tr("About &Qt"), this);
+ aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
+ connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
+}
+
+void MainWindow::createMenus()
+{
+ fileMenu = menuBar()->addMenu(tr("&File"));
+ fileMenu->addAction(exitAct);
+
+ menuBar()->addSeparator();
+
+ helpMenu = menuBar()->addMenu(tr("&Help"));
+ helpMenu->addAction(aboutAct);
+ helpMenu->addAction(aboutQtAct);
+}
+
+void MainWindow::about()
+{
+ QMessageBox::about(this, tr("About Form Extractor"),
+ tr("The <b>Form Extractor</b> example demonstrates how to "
+ "extract data from a web form using QtWebKit."));
+
+}
diff --git a/examples/webkit/formextractor/mainwindow.h b/examples/webkit/formextractor/mainwindow.h
new file mode 100644
index 0000000..7918870
--- /dev/null
+++ b/examples/webkit/formextractor/mainwindow.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include "formextractor.h"
+
+QT_BEGIN_NAMESPACE
+class QAction;
+class QMenu;
+QT_END_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+private slots:
+ void about();
+
+private:
+ FormExtractor *centralWidget;
+ QMenu *fileMenu;
+ QMenu *helpMenu;
+ QAction *exitAct;
+ QAction *aboutAct;
+ QAction *aboutQtAct;
+
+ void createActions();
+ void createMenus();
+};
+
+#endif // MAINWINDOW_H
diff --git a/examples/webkit/previewer/main.cpp b/examples/webkit/previewer/main.cpp
new file mode 100644
index 0000000..87612e2
--- /dev/null
+++ b/examples/webkit/previewer/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include "mainwindow.h"
+
+//! [0]
+int main(int argc, char * argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *mainWindow = new MainWindow;
+ mainWindow->show();
+ return app.exec();
+}
+//! [0]
diff --git a/examples/webkit/previewer/mainwindow.cpp b/examples/webkit/previewer/mainwindow.cpp
new file mode 100644
index 0000000..abe7941
--- /dev/null
+++ b/examples/webkit/previewer/mainwindow.cpp
@@ -0,0 +1,197 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QtWebKit>
+#include "mainwindow.h"
+
+//! [0]
+MainWindow::MainWindow()
+{
+ createActions();
+ createMenus();
+ centralWidget = new Previewer(this);
+ setCentralWidget(centralWidget);
+
+ connect(centralWidget->webView, SIGNAL(loadFinished(bool)),
+ this, SLOT(updateTextEdit()));
+ setStartupText();
+}
+//! [0]
+
+//! [1]
+void MainWindow::createActions()
+{
+ openAct = new QAction(tr("&Open..."), this);
+ openAct->setShortcut(tr("Ctrl+O"));
+ openAct->setStatusTip(tr("Open an existing HTML file"));
+ connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
+
+ openUrlAct = new QAction(tr("&Open URL..."), this);
+ openUrlAct->setShortcut(tr("Ctrl+U"));
+ openUrlAct->setStatusTip(tr("Open a URL"));
+ connect(openUrlAct, SIGNAL(triggered()), this, SLOT(openUrl()));
+//! [1]
+
+ saveAct = new QAction(tr("&Save"), this);
+ saveAct->setShortcut(tr("Ctrl+S"));
+ 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"));
+ connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
+
+ aboutAct = new QAction(tr("&About"), this);
+ aboutAct->setStatusTip(tr("Show the application's About box"));
+ connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
+
+ aboutQtAct = new QAction(tr("About &Qt"), this);
+ aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
+ connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
+}
+
+//! [2]
+void MainWindow::createMenus()
+{
+ fileMenu = menuBar()->addMenu(tr("&File"));
+ fileMenu->addAction(openAct);
+ fileMenu->addAction(openUrlAct);
+ fileMenu->addAction(saveAct);
+ fileMenu->addSeparator();
+ fileMenu->addAction(exitAct);
+
+ menuBar()->addSeparator();
+
+ helpMenu = menuBar()->addMenu(tr("&Help"));
+ helpMenu->addAction(aboutAct);
+ helpMenu->addAction(aboutQtAct);
+}
+//! [2]
+
+//! [3]
+void MainWindow::about()
+{
+ QMessageBox::about(this, tr("About Previewer"),
+ tr("The <b>Previewer</b> example demonstrates how to "
+ "view HTML documents using a QWebView."));
+}
+//! [3]
+
+//! [4]
+void MainWindow::open()
+{
+ QString fileName = QFileDialog::getOpenFileName(this);
+ if (!fileName.isEmpty()) {
+ // read from file
+ QFile file(fileName);
+
+ if (!file.open(QIODevice::ReadOnly)) {
+ QMessageBox::information(this, tr("Unable to open file"),
+ file.errorString());
+ return;
+ }
+
+ QTextStream out(&file);
+ QString output = out.readAll();
+
+ // display contents
+ centralWidget->plainTextEdit->setPlainText(output);
+ centralWidget->setBaseUrl(QUrl::fromLocalFile(fileName));
+ }
+}
+//! [4]
+
+//! [5]
+void MainWindow::openUrl()
+{
+ bool ok;
+ QString url = QInputDialog::getText(this, tr("Enter a URL"),
+ tr("URL:"), QLineEdit::Normal, "http://", &ok);
+
+ if (ok && !url.isEmpty()) {
+ centralWidget->webView->setUrl(url);
+ }
+}
+//! [5]
+
+//! [6]
+void MainWindow::save()
+{
+ QString content = centralWidget->plainTextEdit->toPlainText();
+ QString fileName = QFileDialog::getSaveFileName(this);
+
+ if (!fileName.isEmpty()) {
+ // save to file
+ QFile file(fileName);
+
+ if (!file.open(QIODevice::WriteOnly)) {
+ QMessageBox::information(this, tr("Unable to open file"),
+ file.errorString());
+ return;
+ }
+
+ QTextStream in(&file);
+ in << content;
+ }
+}
+//! [6]
+
+//! [7]
+void MainWindow::updateTextEdit()
+{
+ QWebFrame *mainFrame = centralWidget->webView->page()->mainFrame();
+ QString frameText = mainFrame->toHtml();
+ centralWidget->plainTextEdit->setPlainText(frameText);
+}
+//! [7]
+
+//! [8]
+void MainWindow::setStartupText()
+{
+ QString string = "<html><body><h1>HTML Previewer</h1>"
+ " <p>This example shows you how to use QWebView to"
+ " preview HTML data written in a QPlainTextEdit.</p>"
+ " </body></html>";
+ centralWidget->webView->setHtml(string);
+}
+//! [8]
diff --git a/examples/webkit/previewer/mainwindow.h b/examples/webkit/previewer/mainwindow.h
new file mode 100644
index 0000000..3a0a4b1
--- /dev/null
+++ b/examples/webkit/previewer/mainwindow.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include "previewer.h"
+
+QT_BEGIN_NAMESPACE
+class QAction;
+class QMenu;
+QT_END_NAMESPACE
+
+//! [0]
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+private slots:
+ void open();
+ void openUrl();
+ void save();
+ void about();
+ void updateTextEdit();
+//! [0]
+
+//! [1]
+private:
+ Previewer *centralWidget;
+ QMenu *fileMenu;
+ QMenu *helpMenu;
+ QAction *openAct;
+ QAction *openUrlAct;
+ QAction *saveAct;
+ QAction *exitAct;
+ QAction *aboutAct;
+ QAction *aboutQtAct;
+
+ void createActions();
+ void createMenus();
+ void setStartupText();
+};
+//! [1]
+
+#endif
diff --git a/examples/webkit/previewer/previewer.cpp b/examples/webkit/previewer/previewer.cpp
new file mode 100644
index 0000000..51419d7
--- /dev/null
+++ b/examples/webkit/previewer/previewer.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include "previewer.h"
+
+//! [0]
+Previewer::Previewer(QWidget *parent)
+ : QWidget(parent)
+{
+ setupUi(this);
+}
+//! [0]
+
+void Previewer::setBaseUrl(const QUrl &url)
+{
+ baseUrl = url;
+}
+
+//! [1]
+void Previewer::on_previewButton_clicked()
+{
+ // Update the contents in web viewer
+ QString text = plainTextEdit->toPlainText();
+ webView->setHtml(text, baseUrl);
+}
+//! [1]
diff --git a/examples/webkit/previewer/previewer.h b/examples/webkit/previewer/previewer.h
new file mode 100644
index 0000000..ae70f9f
--- /dev/null
+++ b/examples/webkit/previewer/previewer.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PREVIEWER_H
+#define PREVIEWER_H
+
+#include "ui_previewer.h"
+
+//! [0]
+class Previewer : public QWidget, public Ui::Form
+{
+ Q_OBJECT
+
+public:
+ Previewer(QWidget *parent = 0);
+
+ void setBaseUrl(const QUrl &url);
+
+public slots:
+ void on_previewButton_clicked();
+
+private:
+ QUrl baseUrl;
+};
+//! [0]
+
+#endif
diff --git a/examples/webkit/previewer/previewer.pro b/examples/webkit/previewer/previewer.pro
new file mode 100644
index 0000000..4c8a09d
--- /dev/null
+++ b/examples/webkit/previewer/previewer.pro
@@ -0,0 +1,15 @@
+QT += webkit
+HEADERS = previewer.h \
+ mainwindow.h
+SOURCES = main.cpp \
+ previewer.cpp \
+ mainwindow.cpp
+FORMS = previewer.ui
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/webkit/previewer
+sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro images
+sources.path = $$[QT_INSTALL_EXAMPLES]/webkit/previewer
+INSTALLS += target sources
+
+include($$QT_SOURCE_TREE/examples/examplebase.pri)
diff --git a/examples/webkit/previewer/previewer.ui b/examples/webkit/previewer/previewer.ui
new file mode 100644
index 0000000..d4c9992
--- /dev/null
+++ b/examples/webkit/previewer/previewer.ui
@@ -0,0 +1,99 @@
+<ui version="4.0" >
+ <class>Form</class>
+ <widget class="QWidget" name="Form" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>911</width>
+ <height>688</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_4" >
+ <item>
+ <widget class="QSplitter" name="splitter" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <widget class="QGroupBox" name="editorBox" >
+ <property name="title" >
+ <string>HTML Editor</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_2" >
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2" >
+ <item>
+ <widget class="QPlainTextEdit" name="plainTextEdit" />
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout" >
+ <item>
+ <widget class="QPushButton" name="clearButton" >
+ <property name="text" >
+ <string>Clear</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="previewButton" >
+ <property name="text" >
+ <string>Preview</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QGroupBox" name="previewerBox" >
+ <property name="title" >
+ <string>HTML Preview</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_3" >
+ <item>
+ <widget class="QWebView" name="webView" >
+ <property name="url" >
+ <url>
+ <string>about:blank</string>
+ </url>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>QWebView</class>
+ <extends>QWidget</extends>
+ <header>QtWebKit/QWebView</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>clearButton</sender>
+ <signal>clicked()</signal>
+ <receiver>plainTextEdit</receiver>
+ <slot>clear()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>56</x>
+ <y>653</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>98</x>
+ <y>551</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/examples/webkit/webkit.pro b/examples/webkit/webkit.pro
new file mode 100644
index 0000000..6e26d36
--- /dev/null
+++ b/examples/webkit/webkit.pro
@@ -0,0 +1,11 @@
+TEMPLATE = subdirs
+SUBDIRS += formextractor \
+ previewer
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/webkit
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS webkit.pro README
+sources.path = $$[QT_INSTALL_EXAMPLES]/webkit
+INSTALLS += target sources
+
+include($$QT_SOURCE_TREE/examples/examplebase.pri)