# HG changeset patch # User Wesley Thierry # Date 1288028117 25200 # Node ID fa1a8300ce01cc5ade37511c2e4bdff83bd88765 # Parent 3e3364c5ae1cd7e821ef389488878c602755da62 adding MyWebWidget diff -r 3e3364c5ae1c -r fa1a8300ce01 MixedView/MixedView.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 diff -r 3e3364c5ae1c -r fa1a8300ce01 Mywebwidget3/main.cpp --- /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 +#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(); +} diff -r 3e3364c5ae1c -r fa1a8300ce01 Mywebwidget3/mytoolbar.cpp --- /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 +#include +#include +#include +#include +#include +#include + +#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(); +} diff -r 3e3364c5ae1c -r fa1a8300ce01 Mywebwidget3/mytoolbar.h --- /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 +#include + +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 diff -r 3e3364c5ae1c -r fa1a8300ce01 Mywebwidget3/mywebwidget.cpp --- /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 +#include +#include +#include +#include +#include +#include + +#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 ...")); + } +} diff -r 3e3364c5ae1c -r fa1a8300ce01 Mywebwidget3/mywebwidget.h --- /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 + +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 diff -r 3e3364c5ae1c -r fa1a8300ce01 Mywebwidget3/mywebwidget3.pro --- /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 +}