Commit 7e8a945e authored by Daniel Teske's avatar Daniel Teske Committed by Eike Ziller

Html5Wizard: Remove it

This wizard is from a different era. Nowadays webkit is on the way
towards deprecation and the replacement isn't ready yet.

Change-Id: Ifac9a42463562fefaa4a33eb7be2a09e0d8af1aa
Reviewed-by: default avatarAlessandro Portale <alessandro.portale@digia.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent e30e3e3b
greaterThan(QT_MAJOR_VERSION, 4):QT += widgets webkitwidgets
# Add more folders to ship with the application, here
# DEPLOYMENTFOLDERS #
folder_01.source = html
DEPLOYMENTFOLDERS = folder_01
# DEPLOYMENTFOLDERS_END #
# Define TOUCH_OPTIMIZED_NAVIGATION for touch optimization and flicking
# TOUCH_OPTIMIZED_NAVIGATION #
DEFINES += TOUCH_OPTIMIZED_NAVIGATION
# The .cpp file which was generated for your project. Feel free to hack it.
SOURCES += main.cpp
# Please do not modify the following two lines. Required for deployment.
include(html5applicationviewer/html5applicationviewer.pri)
# REMOVE_NEXT_LINE (wizard will remove the include and merge the touchnavigation code into html5applicationviewer.cpp, instead) #
include(html5applicationviewer/touchnavigation/touchnavigation.pri)
# REMOVE_NEXT_LINE (wizard will remove the include and append deployment.pri to qmlapplicationviewer.pri, instead) #
include(../shared/deployment.pri)
qtcAddDeployment()
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body { margin: 0; font-size: 2em; background-color: white; }
h1 { text-align: center; color: red; }
h1 + h1 { color: green; }
h1:last-child { color: blue; }
#quit { background-color: gray; color: white; font-weight: bold; display: block; text-align: right; }
</style>
<script type="text/javascript">
var counter = 0;
function toggleElement()
{
var elements = document.getElementsByTagName('h1');
for (var i = 0; i < elements.length; ++i)
elements[i].style.display = (counter % elements.length) == i ? '' : 'none';
counter++;
setTimeout('toggleElement()', 1000);
}
window.onload = function()
{
document.getElementById("quit").onmousedown = function()
{
Qt.quit();
};
toggleElement();
}
</script>
</head>
<body>
<a id="quit">X</a>
<h1>Hello</h1>
<h1>HTML5</h1>
<h1>World</h1>
</body>
</html>
/*
This file was generated by the Html5 Application wizard of Qt Creator.
Html5ApplicationViewer is a convenience class containing mobile device specific
code such as screen orientation handling.
It is recommended not to modify this file, since newer versions of Qt Creator
may offer an updated version of it.
*/
#include "html5applicationviewer.h"
#include <QCoreApplication>
#include <QDir>
#include <QFileInfo>
#include <QVBoxLayout>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsLinearLayout>
#include <QGraphicsWebView>
#include <QWebFrame>
#ifdef TOUCH_OPTIMIZED_NAVIGATION
#include <QTimer>
#include <QGraphicsSceneMouseEvent>
#include <QWebElement>
#include "navigationcontroller.h"
#include "webtouchevent.h"
#include "webtouchnavigation.h"
#include "webtouchphysics.h"
#include "webtouchphysicsinterface.h"
#include "webtouchscroller.h"
#endif // TOUCH_OPTIMIZED_NAVIGATION
class Html5ApplicationViewerPrivate : public QGraphicsView
{
Q_OBJECT
public:
Html5ApplicationViewerPrivate(QWidget *parent = 0);
void resizeEvent(QResizeEvent *event);
static QString adjustPath(const QString &path);
public slots:
void quit();
private slots:
void addToJavaScript();
signals:
void quitRequested();
public:
QGraphicsWebView *m_webView;
#ifdef TOUCH_OPTIMIZED_NAVIGATION
NavigationController *m_controller;
#endif // TOUCH_OPTIMIZED_NAVIGATION
};
Html5ApplicationViewerPrivate::Html5ApplicationViewerPrivate(QWidget *parent)
: QGraphicsView(parent)
{
QGraphicsScene *scene = new QGraphicsScene;
setScene(scene);
setFrameShape(QFrame::NoFrame);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_webView = new QGraphicsWebView;
m_webView->setAcceptTouchEvents(true);
m_webView->setAcceptHoverEvents(false);
setAttribute(Qt::WA_AcceptTouchEvents, true);
scene->addItem(m_webView);
scene->setActiveWindow(m_webView);
#ifdef TOUCH_OPTIMIZED_NAVIGATION
m_controller = new NavigationController(parent, m_webView);
#endif // TOUCH_OPTIMIZED_NAVIGATION
connect(m_webView->page()->mainFrame(),
SIGNAL(javaScriptWindowObjectCleared()), SLOT(addToJavaScript()));
}
void Html5ApplicationViewerPrivate::resizeEvent(QResizeEvent *event)
{
m_webView->resize(event->size());
}
QString Html5ApplicationViewerPrivate::adjustPath(const QString &path)
{
#ifdef Q_OS_UNIX
#ifdef Q_OS_MAC
if (!QDir::isAbsolutePath(path))
return QCoreApplication::applicationDirPath()
+ QLatin1String("/../Resources/") + path;
#else
const QString pathInInstallDir = QCoreApplication::applicationDirPath()
+ QLatin1String("/../") + path;
if (pathInInstallDir.contains(QLatin1String("opt"))
&& pathInInstallDir.contains(QLatin1String("bin"))
&& QFileInfo(pathInInstallDir).exists()) {
return pathInInstallDir;
}
#endif
#endif
return QFileInfo(path).absoluteFilePath();
}
void Html5ApplicationViewerPrivate::quit()
{
emit quitRequested();
}
void Html5ApplicationViewerPrivate::addToJavaScript()
{
m_webView->page()->mainFrame()->addToJavaScriptWindowObject("Qt", this);
}
Html5ApplicationViewer::Html5ApplicationViewer(QWidget *parent)
: QWidget(parent)
, m_d(new Html5ApplicationViewerPrivate(this))
{
connect(m_d, SIGNAL(quitRequested()), SLOT(close()));
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(m_d);
layout->setMargin(0);
setLayout(layout);
}
Html5ApplicationViewer::~Html5ApplicationViewer()
{
delete m_d;
}
void Html5ApplicationViewer::loadFile(const QString &fileName)
{
m_d->m_webView->setUrl(QUrl::fromLocalFile(Html5ApplicationViewerPrivate::adjustPath(fileName)));
}
void Html5ApplicationViewer::loadUrl(const QUrl &url)
{
m_d->m_webView->setUrl(url);
}
void Html5ApplicationViewer::setOrientation(ScreenOrientation orientation)
{
Qt::WidgetAttribute attribute;
switch (orientation) {
#if QT_VERSION < 0x040702
// Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
case ScreenOrientationLockPortrait:
attribute = static_cast<Qt::WidgetAttribute>(128);
break;
case ScreenOrientationLockLandscape:
attribute = static_cast<Qt::WidgetAttribute>(129);
break;
default:
case ScreenOrientationAuto:
attribute = static_cast<Qt::WidgetAttribute>(130);
break;
#elif QT_VERSION < 0x050000
case ScreenOrientationLockPortrait:
attribute = Qt::WA_LockPortraitOrientation;
break;
case ScreenOrientationLockLandscape:
attribute = Qt::WA_LockLandscapeOrientation;
break;
default:
case ScreenOrientationAuto:
attribute = Qt::WA_AutoOrientation;
break;
#else
default:
attribute = Qt::WidgetAttribute();
#endif
};
setAttribute(attribute, true);
}
void Html5ApplicationViewer::showExpanded()
{
#if defined(Q_WS_MAEMO_5)
showMaximized();
#else
show();
#endif
}
QGraphicsWebView *Html5ApplicationViewer::webView() const
{
return m_d->m_webView;
}
#include "html5applicationviewer.moc"
/*
This file was generated by the Html5 Application wizard of Qt Creator.
Html5ApplicationViewer is a convenience class containing mobile device specific
code such as screen orientation handling.
It is recommended not to modify this file, since newer versions of Qt Creator
may offer an updated version of it.
*/
#ifndef HTML5APPLICATIONVIEWER_H
#define HTML5APPLICATIONVIEWER_H
#include <QWidget>
#include <QUrl>
class QGraphicsWebView;
class Html5ApplicationViewer : public QWidget
{
Q_OBJECT
public:
enum ScreenOrientation {
ScreenOrientationLockPortrait,
ScreenOrientationLockLandscape,
ScreenOrientationAuto
};
explicit Html5ApplicationViewer(QWidget *parent = 0);
virtual ~Html5ApplicationViewer();
void loadFile(const QString &fileName);
void loadUrl(const QUrl &url);
// Note that this will only have an effect on Fremantle.
void setOrientation(ScreenOrientation orientation);
void showExpanded();
QGraphicsWebView *webView() const;
private:
class Html5ApplicationViewerPrivate *m_d;
};
#endif // HTML5APPLICATIONVIEWER_H
# This file was generated by the Html5 Application wizard of Qt Creator.
# The code below adds the Html5ApplicationViewer to the project.
# It is recommended not to modify this file, since newer versions of Qt Creator
# may offer an updated version of it.
QT += webkit
SOURCES += $$PWD/html5applicationviewer.cpp
HEADERS += $$PWD/html5applicationviewer.h
INCLUDEPATH += $$PWD
/*
This file was generated by the Html5 Application wizard of Qt Creator.
Html5ApplicationViewer is a convenience class containing mobile device specific
code such as screen orientation handling.
It is recommended not to modify this file, since newer versions of Qt Creator
may offer an updated version of it.
*/
#include <QGraphicsWebView>
#include <QWebPage>
#include "navigationcontroller.h"
#include "webnavigation.h"
#include "webtouchnavigation.h"
class NavigationControllerPrivate
{
public:
NavigationControllerPrivate(QWidget *parent, QGraphicsWebView *webView);
~NavigationControllerPrivate();
QWebPage *m_webPage;
QWidget *m_webWidget;
QGraphicsWebView *m_graphicsWebView;
WebNavigation *m_webNavigation;
};
NavigationControllerPrivate::NavigationControllerPrivate(QWidget *parent, QGraphicsWebView *webView)
: m_webPage(0)
, m_webWidget(0)
, m_graphicsWebView(webView)
, m_webNavigation(0)
{
Q_UNUSED(parent);
m_graphicsWebView->setAcceptTouchEvents(true);
m_webPage = new QWebPage;
m_graphicsWebView->setPage(m_webPage);
m_webNavigation = new WebNavigation(m_graphicsWebView, m_webPage);
m_webNavigation->setParent(m_graphicsWebView);
}
NavigationControllerPrivate::~NavigationControllerPrivate()
{
if (m_webNavigation)
delete m_webNavigation;
if (m_webPage)
delete m_webPage;
if (m_graphicsWebView)
delete m_graphicsWebView;
}
NavigationController::NavigationController(QWidget *parent, QGraphicsWebView *webView)
: m_d(new NavigationControllerPrivate(parent, webView))
{
}
NavigationController::~NavigationController()
{
delete m_d;
}
QWebPage* NavigationController::webPage() const
{
return m_d->m_webPage;
}
QGraphicsWebView* NavigationController::graphicsWebView() const
{
return m_d->m_graphicsWebView;
}
/*
This file was generated by the Html5 Application wizard of Qt Creator.
Html5ApplicationViewer is a convenience class containing mobile device specific
code such as screen orientation handling.
It is recommended not to modify this file, since newer versions of Qt Creator
may offer an updated version of it.
*/
#ifndef NAVIGATIONCONTROLLER_H
#define NAVIGATIONCONTROLLER_H
#include <QObject>
class QGraphicsWebView;
class QWebPage;
class NavigationController : public QObject
{
Q_OBJECT
public:
NavigationController(QWidget *parent, QGraphicsWebView *webView);
virtual ~NavigationController();
QWidget *webWidget() const;
QWebPage* webPage() const;
QGraphicsWebView* graphicsWebView() const;
signals:
void pauseNavigation();
void resumeNavigation();
private:
class NavigationControllerPrivate *m_d;
};
#endif // NAVIGATIONCONTROLLER_H
# This file was generated by the Html5 Application wizard of Qt Creator.
# The code below adds the Html5ApplicationViewer to the project.
# It is recommended not to modify this file, since newer versions of Qt Creator
# may offer an updated version of it.
SOURCES += \
$$PWD/webtouchphysicsinterface.cpp \
$$PWD/webtouchphysics.cpp \
$$PWD/webtouchevent.cpp \
$$PWD/webtouchscroller.cpp \
$$PWD/webtouchnavigation.cpp \
$$PWD/navigationcontroller.cpp \
$$PWD/webnavigation.cpp
HEADERS += \
$$PWD/webtouchphysicsinterface.h \
$$PWD/webtouchphysics.h \
$$PWD/webtouchevent.h \
$$PWD/webtouchscroller.h \
$$PWD/webtouchnavigation.h \
$$PWD/navigationcontroller.h \
$$PWD/webnavigation.h
INCLUDEPATH += $$PWD
/*
This file was generated by the Html5 Application wizard of Qt Creator.
Html5ApplicationViewer is a convenience class containing mobile device specific
code such as screen orientation handling.
It is recommended not to modify this file, since newer versions of Qt Creator
may offer an updated version of it.
*/
#include <QWebPage>
#include "webnavigation.h"
#include "webtouchnavigation.h"
WebNavigation::WebNavigation(QObject *parent, QWebPage *webPage)
: m_viewObject(parent)
, m_webPage(webPage)
, m_webTouchNavigation(0)
{
m_webTouchNavigation = new WebTouchNavigation(m_viewObject, m_webPage);
m_viewObject->installEventFilter(m_webTouchNavigation);
}
WebNavigation::~WebNavigation()
{
delete m_webTouchNavigation;
}
/*
This file was generated by the Html5 Application wizard of Qt Creator.
Html5ApplicationViewer is a convenience class containing mobile device specific
code such as screen orientation handling.
It is recommended not to modify this file, since newer versions of Qt Creator
may offer an updated version of it.
*/
#ifndef WEBNAVIGATION_H
#define WEBNAVIGATION_H
#include <QObject>
class QWebPage;
class WebTouchNavigation;
class WebNavigation : public QObject
{
Q_OBJECT
public:
WebNavigation(QObject *parent, QWebPage *webPage);
virtual ~WebNavigation();
private:
QObject *m_viewObject;
QWebPage *m_webPage;
WebTouchNavigation *m_webTouchNavigation;
};
#endif // WEBNAVIGATION_H
/*
This file was generated by the Html5 Application wizard of Qt Creator.
Html5ApplicationViewer is a convenience class containing mobile device specific
code such as screen orientation handling.
It is recommended not to modify this file, since newer versions of Qt Creator
may offer an updated version of it.
*/
#include "webtouchevent.h"
WebTouchEvent::WebTouchEvent()
: m_type(QEvent::None)
, m_button(Qt::NoButton)
, m_buttons(Qt::NoButton)
, m_graphicsSceneEvent(false)
, m_fired(false)
, m_editable(false)
, m_modifier(Qt::NoModifier)
{}
WebTouchEvent::WebTouchEvent(const QMouseEvent *mouseEvent)
{
Q_ASSERT(mouseEvent != 0);
m_type = mouseEvent->type();
m_pos = mouseEvent->pos();
m_button = mouseEvent->button();
m_buttons = mouseEvent->buttons();
m_modifier = mouseEvent->modifiers();
m_fired = false;
m_editable = false;
m_graphicsSceneEvent = false;
}
WebTouchEvent::WebTouchEvent(const QGraphicsSceneMouseEvent *graphicsSceneMouseEvent)
{
Q_ASSERT(graphicsSceneMouseEvent != 0);
m_type = graphicsSceneMouseEvent->type();
m_pos = graphicsSceneMouseEvent->pos().toPoint();
m_button = graphicsSceneMouseEvent->button();
m_buttons = graphicsSceneMouseEvent->buttons();
m_modifier = graphicsSceneMouseEvent->modifiers();
m_scenePos = graphicsSceneMouseEvent->scenePos();
m_screenPos = graphicsSceneMouseEvent->screenPos();
m_buttonDownPos = graphicsSceneMouseEvent->buttonDownPos(graphicsSceneMouseEvent->button());
m_buttonDownScenePos = graphicsSceneMouseEvent->buttonDownScenePos(graphicsSceneMouseEvent->button());
m_buttonDownScreenPos = graphicsSceneMouseEvent->buttonDownScreenPos(graphicsSceneMouseEvent->button());
m_lastPos = graphicsSceneMouseEvent->lastPos();
m_lastScenePos = graphicsSceneMouseEvent->lastScenePos();
m_lastScreenPos = graphicsSceneMouseEvent->lastScreenPos();
m_fired = false;
m_editable = false;
m_graphicsSceneEvent = true;
}
/*
This file was generated by the Html5 Application wizard of Qt Creator.
Html5ApplicationViewer is a convenience class containing mobile device specific
code such as screen orientation handling.
It is recommended not to modify this file, since newer versions of Qt Creator
may offer an updated version of it.
*/
#ifndef WEBTOUCHEVENT_H
#define WEBTOUCHEVENT_H
#include <QEvent>
#include <QGraphicsSceneMouseEvent>
#include <QMouseEvent>
#include <QPoint>
class WebTouchEvent
{
public:
WebTouchEvent();
WebTouchEvent(const QMouseEvent *mouseEvent);
WebTouchEvent(const QGraphicsSceneMouseEvent *graphicsSceneMouseEvent);
QPoint m_pos;
QEvent::Type m_type;
Qt::MouseButton m_button;
Qt::MouseButtons m_buttons;
bool m_graphicsSceneEvent;
bool m_fired;
bool m_editable;
Qt::KeyboardModifiers m_modifier;
//Graphics scene event members
QPointF m_scenePos;
QPoint m_screenPos;