diff --git a/share/qtcreator/templates/html5app/app.pro b/share/qtcreator/templates/html5app/app.pro new file mode 100644 index 00000000000..a31378fc0fc --- /dev/null +++ b/share/qtcreator/templates/html5app/app.pro @@ -0,0 +1,34 @@ +# Add more folders to ship with the application, here +# DEPLOYMENTFOLDERS # +folder_01.source = html +DEPLOYMENTFOLDERS = folder_01 +# DEPLOYMENTFOLDERS_END # + +# Avoid auto screen rotation +# ORIENTATIONLOCK # +DEFINES += ORIENTATIONLOCK + +# TARGETUID3 # +symbian:TARGET.UID3 = 0xE1111234 +symbian:TARGET.CAPABILITY += NetworkServices + +# Smart Installer package's UID +# This UID is from the protected range and therefore the package will +# fail to install if self-signed. By default qmake uses the unprotected +# range value if unprotected UID is defined for the application and +# 0x2002CCCF value if protected UID is given to the application +#symbian:DEPLOYMENT.installer_header = 0x2002CCCF + +# If your application uses the Qt Mobility libraries, uncomment the following +# lines and add the respective components to the MOBILITY variable. +# CONFIG += mobility +# MOBILITY += + +# 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) +# INCLUDE_DEPLOYMENT_PRI (wizard will remove the include and append deployment.pri to qmlapplicationviewer.pri, instead) # +include(../shared/deployment.pri) +qtcAddDeployment() diff --git a/share/qtcreator/templates/html5app/html/index.html b/share/qtcreator/templates/html5app/html/index.html new file mode 100644 index 00000000000..44d46fa214e --- /dev/null +++ b/share/qtcreator/templates/html5app/html/index.html @@ -0,0 +1,38 @@ + + + + + + + + X +

Hello

+

Html5

+

World

+ + diff --git a/share/qtcreator/templates/html5app/html5applicationviewer/html5applicationviewer.cpp b/share/qtcreator/templates/html5app/html5applicationviewer/html5applicationviewer.cpp new file mode 100644 index 00000000000..a39d62759bb --- /dev/null +++ b/share/qtcreator/templates/html5app/html5applicationviewer/html5applicationviewer.cpp @@ -0,0 +1,179 @@ +/* + 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 +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(Q_OS_SYMBIAN) && defined(ORIENTATIONLOCK) +#include +#include +#include +#include +#endif // Q_OS_SYMBIAN && ORIENTATIONLOCK + +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; +}; + +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; + scene->addItem(m_webView); + 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 pathInShareDir = QCoreApplication::applicationDirPath() + + QLatin1String("/../share/") + + QFileInfo(QCoreApplication::applicationFilePath()).fileName() + + QLatin1Char('/') + path; + if (QFileInfo(pathInShareDir).exists()) + return pathInShareDir; +#endif +#endif + return path; +} + +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(Html5ApplicationViewerPrivate::adjustPath(fileName))); +} + +void Html5ApplicationViewer::loadUrl(const QUrl &url) +{ + m_d->m_webView->setUrl(url); +} + +void Html5ApplicationViewer::setOrientation(ScreenOrientation orientation) +{ +#ifdef Q_OS_SYMBIAN + if (orientation != ScreenOrientationAuto) { +#if defined(ORIENTATIONLOCK) + const CAknAppUiBase::TAppUiOrientation uiOrientation = + (orientation == ScreenOrientationLockPortrait) ? CAknAppUi::EAppUiOrientationPortrait + : CAknAppUi::EAppUiOrientationLandscape; + CAknAppUi* appUi = dynamic_cast (CEikonEnv::Static()->AppUi()); + TRAPD(error, + if (appUi) + appUi->SetOrientationL(uiOrientation); + ); + Q_UNUSED(error) +#else // ORIENTATIONLOCK + qWarning("'ORIENTATIONLOCK' needs to be defined on Symbian when locking the orientation."); +#endif // ORIENTATIONLOCK + } +#elif defined(Q_WS_MAEMO_5) + Qt::WidgetAttribute attribute; + switch (orientation) { + case ScreenOrientationLockPortrait: + attribute = Qt::WA_Maemo5PortraitOrientation; + break; + case ScreenOrientationLockLandscape: + attribute = Qt::WA_Maemo5LandscapeOrientation; + break; + case ScreenOrientationAuto: + default: + attribute = Qt::WA_Maemo5AutoOrientation; + break; + } + setAttribute(attribute, true); +#else // Q_OS_SYMBIAN + Q_UNUSED(orientation); +#endif // Q_OS_SYMBIAN +} + +void Html5ApplicationViewer::showExpanded() +{ +#ifdef Q_OS_SYMBIAN + showFullScreen(); +#elif defined(Q_WS_MAEMO_5) + showMaximized(); +#else + show(); +#endif +} + +QGraphicsWebView *Html5ApplicationViewer::webView() const +{ + return m_d->m_webView; +} + +#include "html5applicationviewer.moc" diff --git a/share/qtcreator/templates/html5app/html5applicationviewer/html5applicationviewer.h b/share/qtcreator/templates/html5app/html5applicationviewer/html5applicationviewer.h new file mode 100644 index 00000000000..66902da24f2 --- /dev/null +++ b/share/qtcreator/templates/html5app/html5applicationviewer/html5applicationviewer.h @@ -0,0 +1,43 @@ +/* + 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 +#include + +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); + + void setOrientation(ScreenOrientation orientation); + void showExpanded(); + + QGraphicsWebView *webView() const; + +private: + class Html5ApplicationViewerPrivate *m_d; +}; + +#endif // HTML5APPLICATIONVIEWER_H diff --git a/share/qtcreator/templates/html5app/html5applicationviewer/html5applicationviewer.pri b/share/qtcreator/templates/html5app/html5applicationviewer/html5applicationviewer.pri new file mode 100644 index 00000000000..1886697e55d --- /dev/null +++ b/share/qtcreator/templates/html5app/html5applicationviewer/html5applicationviewer.pri @@ -0,0 +1,10 @@ +# 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 diff --git a/share/qtcreator/templates/html5app/main.cpp b/share/qtcreator/templates/html5app/main.cpp new file mode 100644 index 00000000000..b2df9112ccd --- /dev/null +++ b/share/qtcreator/templates/html5app/main.cpp @@ -0,0 +1,15 @@ +#include +#include "html5applicationviewer.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + Html5ApplicationViewer viewer; + viewer.setOrientation(Html5ApplicationViewer::ScreenOrientationAuto); // ORIENTATION + viewer.showExpanded(); + viewer.loadFile(QLatin1String("html/index.html")); // HTMLFILE +// viewer.loadUrl(QUrl(QLatin1String("http://dev.sencha.com/deploy/touch/examples/kitchensink/"))); + + return app.exec(); +}