adding MyWebWidget
authorWesley Thierry <wesleyt@symbian.org>
Mon, 25 Oct 2010 10:35:17 -0700
changeset 2 fa1a8300ce01
parent 1 3e3364c5ae1c
child 5 3d8bce9e1a9f
adding MyWebWidget
MixedView/MixedView.pro
Mywebwidget3/main.cpp
Mywebwidget3/mytoolbar.cpp
Mywebwidget3/mytoolbar.h
Mywebwidget3/mywebwidget.cpp
Mywebwidget3/mywebwidget.h
Mywebwidget3/mywebwidget3.pro
--- a/MixedView/MixedView.pro	Wed Oct 20 14:02:46 2010 -0700
+++ b/MixedView/MixedView.pro	Mon Oct 25 10:35:17 2010 -0700
@@ -4,7 +4,7 @@
 #
 #-------------------------------------------------
 
-QT       += core gui multimedia
+QT       += core gui multimedia network
 
 TARGET = MixedView
 TEMPLATE = app
@@ -17,7 +17,7 @@
 
 FORMS    += mainwindow.ui
 
-INCLUDEPATH+=../../../src/sensors ../../src/multimedia ../../src/multimedia/audio
+INCLUDEPATH+=../../../src/network ../../../src/sensors ../../src/multimedia ../../src/multimedia/audio
 
 
 CONFIG += mobility
@@ -26,10 +26,9 @@
 symbian {
     TARGET.UID3 = 0xe4cef592
     LIBS += -lcone -leikcore -lavkon
-    TARGET.CAPABILITY += LocalServices ReadUserData WriteUserData NetworkServices UserEnvironment Location ReadDeviceData
+    TARGET.CAPABILITY += AllFiles LocalServices ReadUserData WriteUserData NetworkServices UserEnvironment Location ReadDeviceData
     TARGET.EPOCSTACKSIZE = 0x14000
-    TARGET.EPOCHEAPSIZE = 0x020000 0x800000
+    TARGET.EPOCHEAPSIZE = 0x020000 0x10000000
 }
 
-RESOURCES += \
-    resources.qrc
+RESOURCES += resources.qrc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Mywebwidget3/main.cpp	Mon Oct 25 10:35:17 2010 -0700
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2010 Symbian Foundation.
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation - Initial contribution
+*
+* Description:
+* Project main function.
+*/
+
+#include <QtGui/QApplication>
+#include "mywebwidget.h"
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+
+    MyWebWidget w;
+
+#if defined(Q_WS_S60)
+    w.showMaximized();
+#else
+    w.show();
+#endif
+
+    return a.exec();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Mywebwidget3/mytoolbar.cpp	Mon Oct 25 10:35:17 2010 -0700
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2010 Symbian Foundation.
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation - Initial contribution
+*
+* Description:
+* Implementation of the MyToolBar class.
+*/
+
+#include <QtGui/QPushButton>
+#include <QtGui/QLabel>
+#include <QtGui/QHBoxLayout>
+#include <QtGui/QAction>
+#include <QtGui/QApplication>
+#include <QGeoPositionInfo>
+#include <QGeoPositionInfoSource>
+
+#include "mytoolbar.h"
+
+const QString locString("My Location: ");
+
+MyToolBar::MyToolBar(QWidget* parent)
+    :QWidget(parent)
+{
+    m_backButton = new QPushButton("Back",this);
+    m_locationLabel = new QLabel(this);
+
+    m_location = QGeoPositionInfoSource::createDefaultSource(this);
+    m_location->setUpdateInterval(10000);
+    m_location->startUpdates();
+
+    m_layout = new QHBoxLayout;
+    m_layout->addWidget(m_backButton);
+    m_layout->addWidget(m_locationLabel);
+    m_layout->insertSpacing(1,10);
+    setLayout(m_layout);
+    m_layout->addStretch();
+
+    connect(m_backButton,SIGNAL(clicked()),SLOT(onBackPressed()));
+    connect(m_location,SIGNAL(positionUpdated(QGeoPositionInfo)),SLOT(onPositionUpdated(QGeoPositionInfo)));
+}
+
+MyToolBar::~MyToolBar()
+{
+
+}
+
+void MyToolBar::onPositionUpdated(const QGeoPositionInfo& posInfo)
+{
+    QGeoCoordinate coordinate = posInfo.coordinate();
+    QString label_coordinate = coordinate.toString();
+    m_locationLabel->setText(locString+" "+label_coordinate);
+}
+
+void MyToolBar::onBackPressed()
+{
+    emit goBack();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Mywebwidget3/mytoolbar.h	Mon Oct 25 10:35:17 2010 -0700
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2010 Symbian Foundation.
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation - Initial contribution
+*
+* Description:
+* Declaration of the MyToolBar class.
+*/
+
+#ifndef MYTOOLBAR_H
+#define MYTOOLBAR_H
+
+#include <qmobilityglobal.h>
+#include <QtGui/QWidget>
+
+QTM_BEGIN_NAMESPACE
+class QGeoPositionInfo;
+class QGeoPositionInfoSource;
+QTM_END_NAMESPACE
+
+QTM_USE_NAMESPACE
+
+class QHBoxLayout;
+class QPushButton;
+class QLabel;
+
+class MyToolBar : public QWidget
+{
+    Q_OBJECT
+
+public:
+    MyToolBar(QWidget *parent = 0);
+    ~MyToolBar();
+
+signals:
+    void goBack();
+    void showLocation();
+
+private slots:
+    void onBackPressed();
+    void onPositionUpdated(const QGeoPositionInfo& posInfo);
+
+private:
+    QPushButton* m_backButton;
+    QLabel* m_locationLabel;
+    QHBoxLayout* m_layout;
+    QGeoPositionInfoSource* m_location;
+};
+
+#endif // MYTOOLBAR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Mywebwidget3/mywebwidget.cpp	Mon Oct 25 10:35:17 2010 -0700
@@ -0,0 +1,90 @@
+/*
+* Copyright (c) 2010 Symbian Foundation.
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation - Initial contribution
+*
+* Description:
+* Implementation of the MyWebWidget class.
+*/
+
+#include <QtGui/QLineEdit>
+#include <QtWebKit/QWebView>
+#include <QtGui/QVBoxLayout>
+#include <QtGui/QLabel>
+#include <QtCore/QUrl>
+#include <QtGui/QAction>
+#include <QtWebKit/QWebHistory>
+
+#include "mytoolbar.h" //added
+#include "mywebwidget.h"
+
+MyWebWidget::MyWebWidget(QWidget *parent)
+    : QWidget(parent)
+{
+    m_softkeyAction = new QAction( tr("Options"), this );
+    m_softkeyAction->setSoftKeyRole(QAction::PositiveSoftKey);
+    addAction(m_softkeyAction);
+
+    m_lineEdit = new QLineEdit(this);
+    m_lineEdit->setStyleSheet("background-color:white; padding: 6px ; color:blue");
+    m_lineEdit->setText("Enter url ...");
+
+    m_view = new QWebView(this);
+    m_view->load(QUrl("http://blog.symbian.org"));
+
+    m_layout = new QVBoxLayout();
+
+    m_layout->addWidget(m_lineEdit);
+    m_layout->addWidget(m_view);
+    m_layout->insertSpacing(1,10);
+
+    //add toolbar
+    m_toolbar = new MyToolBar(this);
+    m_layout->addWidget(m_toolbar);
+
+    setLayout(m_layout);
+    m_layout->addStretch();
+
+    connect(m_lineEdit,SIGNAL(editingFinished()),SLOT(openUrl()));
+    connect(m_view,SIGNAL(loadFinished(bool)),SLOT(onLoadFinished(bool)));
+
+    //connect the toolbar as well
+    connect(m_toolbar,SIGNAL(goBack()),SLOT(loadPreviousPage()));
+}
+
+MyWebWidget::~MyWebWidget()
+{
+
+}
+
+//added
+void MyWebWidget::loadPreviousPage()
+{
+    if(m_view->history()->canGoBack())
+    {
+        m_view->history()->back();
+    }
+}
+
+void MyWebWidget::openUrl()
+{
+    QString url(m_lineEdit->text());
+    if(!url.contains("http://",Qt::CaseInsensitive))
+        url.prepend("http://");
+    m_view->load(QUrl(url));
+
+}
+
+void MyWebWidget::onLoadFinished(bool finished)
+{
+    if(finished){
+        m_lineEdit->clear();
+        m_lineEdit->setText(tr("Enter url ..."));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Mywebwidget3/mywebwidget.h	Mon Oct 25 10:35:17 2010 -0700
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2010 Symbian Foundation.
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation - Initial contribution
+*
+* Description:
+* Declaration of the MyWebWidget class.
+*/
+
+#ifndef MYWEBWIDGET_H
+#define MYWEBWIDGET_H
+
+#include <QtGui/QWidget>
+
+class QWebView;
+class QLineEdit;
+class QVBoxLayout;
+class QLabel;
+class QAction;
+class QWebHistory;
+class QGeoPositionInfoSource;
+class MyToolBar; //added
+
+class MyWebWidget : public QWidget
+{
+    Q_OBJECT
+
+public:
+    MyWebWidget(QWidget *parent = 0);
+    ~MyWebWidget();
+
+private slots:
+    void openUrl();
+    void onLoadFinished(bool finished);
+    void loadPreviousPage();
+
+private:
+    QAction* m_softkeyAction;
+    QWebView* m_view;
+    QLineEdit* m_lineEdit;
+    QLabel* m_label;
+    QVBoxLayout* m_layout;
+    MyToolBar* m_toolbar;
+    QWebHistory* m_history;
+};
+
+#endif // MYWEBWIDGET_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Mywebwidget3/mywebwidget3.pro	Mon Oct 25 10:35:17 2010 -0700
@@ -0,0 +1,28 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2010-10-06T10:31:49
+#
+#-------------------------------------------------
+
+QT       += core gui webkit
+
+TARGET = mywebwidget3
+TEMPLATE = app
+
+
+SOURCES += main.cpp\
+        mywebwidget.cpp \
+    mytoolbar.cpp
+
+HEADERS  += mywebwidget.h \
+    mytoolbar.h
+
+CONFIG += mobility
+MOBILITY = location
+
+symbian {
+    TARGET.UID3 = 0xe1b774b2
+    TARGET.CAPABILITY += LocalServices ReadUserData WriteUserData NetworkServices UserEnvironment Location ReadDeviceData
+    TARGET.EPOCSTACKSIZE = 0x14000
+    TARGET.EPOCHEAPSIZE = 0x020000 0x4000000
+}