diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-01-19 08:02:40 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-01-19 08:02:40 (GMT) |
commit | 530fd3831f012337d7460c4387ce82083ab3e144 (patch) | |
tree | 5982ace32770fe05e5357b28099f3971f454b69f /demos | |
parent | 630114a8c65e492b7b9008e056895302865ba528 (diff) | |
parent | 3cb3c9a7922cd96744ff0e15790103dbb68b3bf9 (diff) | |
download | Qt-530fd3831f012337d7460c4387ce82083ab3e144.zip Qt-530fd3831f012337d7460c4387ce82083ab3e144.tar.gz Qt-530fd3831f012337d7460c4387ce82083ab3e144.tar.bz2 |
Merge branch '4.6' of ../qt into kinetic-declarativeui
Diffstat (limited to 'demos')
-rw-r--r-- | demos/embedded/anomaly/anomaly.pro | 6 | ||||
-rw-r--r-- | demos/embedded/anomaly/src/BrowserView.cpp | 5 | ||||
-rw-r--r-- | demos/embedded/anomaly/src/BrowserView.h | 4 | ||||
-rw-r--r-- | demos/embedded/anomaly/src/webview.cpp | 80 | ||||
-rw-r--r-- | demos/embedded/anomaly/src/webview.h | 66 |
5 files changed, 156 insertions, 5 deletions
diff --git a/demos/embedded/anomaly/anomaly.pro b/demos/embedded/anomaly/anomaly.pro index 2871ba7..165ce89 100644 --- a/demos/embedded/anomaly/anomaly.pro +++ b/demos/embedded/anomaly/anomaly.pro @@ -8,7 +8,8 @@ HEADERS += src/BrowserWindow.h \ src/BookmarksView.h \ src/flickcharm.h \ src/ZoomStrip.h \ - src/ControlStrip.h + src/ControlStrip.h \ + src/webview.h SOURCES += src/Main.cpp \ src/BrowserWindow.cpp \ src/BrowserView.cpp \ @@ -18,7 +19,8 @@ SOURCES += src/Main.cpp \ src/BookmarksView.cpp \ src/flickcharm.cpp \ src/ZoomStrip.cpp \ - src/ControlStrip.cpp + src/ControlStrip.cpp \ + src/webview.cpp RESOURCES += src/anomaly.qrc symbian { diff --git a/demos/embedded/anomaly/src/BrowserView.cpp b/demos/embedded/anomaly/src/BrowserView.cpp index ab52e81..0945b89 100644 --- a/demos/embedded/anomaly/src/BrowserView.cpp +++ b/demos/embedded/anomaly/src/BrowserView.cpp @@ -48,6 +48,7 @@ #include "ControlStrip.h" #include "TitleBar.h" #include "flickcharm.h" +#include "webview.h" #include "ZoomStrip.h" #if defined (Q_OS_SYMBIAN) @@ -62,7 +63,7 @@ BrowserView::BrowserView(QWidget *parent) , m_currentZoom(100) { m_titleBar = new TitleBar(this); - m_webView = new QWebView(this); + m_webView = new WebView(this); m_zoomStrip = new ZoomStrip(this); m_controlStrip = new ControlStrip(this); @@ -95,7 +96,7 @@ void BrowserView::initialize() connect(m_webView, SIGNAL(loadFinished(bool)), SLOT(finish(bool))); connect(m_webView, SIGNAL(urlChanged(QUrl)), SLOT(updateTitleBar())); - m_webView->setHtml("Will try to load page soon!"); + m_webView->setHtml("about:blank"); m_webView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_webView->setFocus(); #ifdef Q_OS_SYMBIAN diff --git a/demos/embedded/anomaly/src/BrowserView.h b/demos/embedded/anomaly/src/BrowserView.h index fdc126d..5ab1dd7 100644 --- a/demos/embedded/anomaly/src/BrowserView.h +++ b/demos/embedded/anomaly/src/BrowserView.h @@ -49,6 +49,7 @@ class QUrl; class QWebView; class TitleBar; class ControlStrip; +class WebView; class ZoomStrip; class BrowserView : public QWidget @@ -81,7 +82,7 @@ protected: private: TitleBar *m_titleBar; - QWebView *m_webView; + WebView *m_webView; ZoomStrip *m_zoomStrip; ControlStrip *m_controlStrip; int m_progress; @@ -90,3 +91,4 @@ private: }; #endif // BROWSERVIEW_H + diff --git a/demos/embedded/anomaly/src/webview.cpp b/demos/embedded/anomaly/src/webview.cpp new file mode 100644 index 0000000..5cb913b --- /dev/null +++ b/demos/embedded/anomaly/src/webview.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demos 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "webview.h" + +#include <QPaintEvent> +#include <QWebFrame> + +WebView::WebView(QWidget *parent) + : QWebView(parent) + , inLoading(false) +{ + connect(this, SIGNAL(loadStarted()), this, SLOT(newPageLoading())); + connect(this, SIGNAL(loadFinished(bool)), this, SLOT(pageLoaded(bool))); + page()->setPreferredContentsSize(QSize(1024, 768)); +} + +void WebView::paintEvent(QPaintEvent *event) +{ + if (inLoading && loadingTime.elapsed() < 750) { + QPainter painter(this); + painter.setBrush(Qt::white); + painter.setPen(Qt::NoPen); + foreach (const QRect &rect, event->region().rects()) { + painter.drawRect(rect); + } + } else { + QWebView::paintEvent(event); + } +} + +void WebView::newPageLoading() +{ + inLoading = true; + loadingTime.start(); +} + +void WebView::pageLoaded(bool) +{ + inLoading = false; + update(); +} diff --git a/demos/embedded/anomaly/src/webview.h b/demos/embedded/anomaly/src/webview.h new file mode 100644 index 0000000..ecd9f5a --- /dev/null +++ b/demos/embedded/anomaly/src/webview.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demos 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WEBVIEW_H +#define WEBVIEW_H + +#include <QWebView> +#include <QTime> + +class WebView : public QWebView +{ + Q_OBJECT +public: + WebView(QWidget *parent = 0); + +protected: + void paintEvent(QPaintEvent *event); + +private slots: + void newPageLoading(); + void pageLoaded(bool ok); + +private: + QTime loadingTime; + bool inLoading; +}; + +#endif // WEBVIEW_H |