diff options
author | axis <qt-info@nokia.com> | 2009-06-22 09:52:52 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2009-06-22 09:52:52 (GMT) |
commit | adfbda42cb20bbfea139c831fc9e015208b5ce2c (patch) | |
tree | ab5f3e188073f05d9625a711e0775141b30276ac | |
parent | afceb76c880cf346f92e1c0e95d7fed07fbbe8a0 (diff) | |
parent | 112391d20adb222e6cfd93e0386031a0d27a22bf (diff) | |
download | Qt-adfbda42cb20bbfea139c831fc9e015208b5ce2c.zip Qt-adfbda42cb20bbfea139c831fc9e015208b5ce2c.tar.gz Qt-adfbda42cb20bbfea139c831fc9e015208b5ce2c.tar.bz2 |
Merge branch 'master' of git@scm:qt/qt-s60-public
Conflicts:
dist/changes-4.5.2-tower
29 files changed, 1747 insertions, 56 deletions
diff --git a/demos/embedded/anomaly/README.TXT b/demos/embedded/anomaly/README.TXT new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/demos/embedded/anomaly/README.TXT diff --git a/demos/embedded/anomaly/anomaly.pro b/demos/embedded/anomaly/anomaly.pro new file mode 100644 index 0000000..5fe5625 --- /dev/null +++ b/demos/embedded/anomaly/anomaly.pro @@ -0,0 +1,29 @@ +QT += network \ + webkit +HEADERS += src/BrowserWindow.h \ + src/BrowserView.h \ + src/TitleBar.h \ + src/HomeView.h \ + src/AddressBar.h \ + src/BookmarksView.h \ + src/flickcharm.h \ + src/ZoomStrip.h \ + src/ControlStrip.h +SOURCES += src/Main.cpp \ + src/BrowserWindow.cpp \ + src/BrowserView.cpp \ + src/TitleBar.cpp \ + src/HomeView.cpp \ + src/AddressBar.cpp \ + src/BookmarksView.cpp \ + src/flickcharm.cpp \ + src/ZoomStrip.cpp \ + src/ControlStrip.cpp +RESOURCES += src/anomaly.qrc + +symbian { + HEADERS += $$QT_SOURCE_TREE/examples/network/ftp/sym_iap_util.h + LIBS += -lesock -lconnmon + TARGET.CAPABILITY = NetworkServices + TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 +} diff --git a/demos/embedded/anomaly/src/AddressBar.cpp b/demos/embedded/anomaly/src/AddressBar.cpp new file mode 100644 index 0000000..64734c8 --- /dev/null +++ b/demos/embedded/anomaly/src/AddressBar.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "AddressBar.h" + +#include <QtCore> +#include <QtGui> + +class LineEdit: public QLineEdit +{ +public: + LineEdit(QWidget *parent = 0): QLineEdit(parent) {} + + void paintEvent(QPaintEvent *event) { + QLineEdit::paintEvent(event); + if (text().isEmpty()) { + QPainter p(this); + int flags = Qt::AlignLeft | Qt::AlignVCenter; + p.setPen(palette().color(QPalette::Disabled, QPalette::Text)); + p.drawText(rect().adjusted(10, 0, 0, 0), flags, "Enter address or search terms"); + p.end(); + } + } +}; + +AddressBar::AddressBar(QWidget *parent) + : QWidget(parent) +{ + m_lineEdit = new LineEdit(parent); + connect(m_lineEdit, SIGNAL(returnPressed()), SLOT(processAddress())); + m_toolButton = new QToolButton(parent); + m_toolButton->setText("Go"); + connect(m_toolButton, SIGNAL(clicked()), SLOT(processAddress())); +} + +QSize AddressBar::sizeHint() const +{ + return m_lineEdit->sizeHint(); +} + +void AddressBar::processAddress() +{ + if (!m_lineEdit->text().isEmpty()) + emit addressEntered(m_lineEdit->text()); +} + +void AddressBar::resizeEvent(QResizeEvent *event) +{ + int x, y, w, h; + + m_toolButton->adjustSize(); + x = width() - m_toolButton->width(); + y = 0; + w = m_toolButton->width(); + h = height() - 1; + m_toolButton->setGeometry(x, y, w, h); + m_toolButton->show(); + + x = 0; + y = 0; + w = width() - m_toolButton->width(); + h = height() - 1; + m_lineEdit->setGeometry(x, y, w, h); + m_lineEdit->show(); +} + +void AddressBar::focusInEvent(QFocusEvent *event) +{ + m_lineEdit->setFocus(); + QWidget::focusInEvent(event); +} diff --git a/demos/embedded/anomaly/src/AddressBar.h b/demos/embedded/anomaly/src/AddressBar.h new file mode 100644 index 0000000..632ae1f --- /dev/null +++ b/demos/embedded/anomaly/src/AddressBar.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef ADDRESSBAR_H +#define ADDRESSBAR_H + +#include <QWidget> + +class QLineEdit; +class QToolButton; + +class AddressBar : public QWidget +{ + Q_OBJECT + +public: + AddressBar(QWidget *parent = 0); + QSize sizeHint() const; + +protected: + void resizeEvent(QResizeEvent *event); + void focusInEvent(QFocusEvent *event); + +signals: + void addressEntered(const QString &address); + +private slots: + void processAddress(); + +private: + QLineEdit *m_lineEdit; + QToolButton *m_toolButton; +}; + +#endif // ADDRESSBAR_H diff --git a/demos/embedded/anomaly/src/BookmarksView.cpp b/demos/embedded/anomaly/src/BookmarksView.cpp new file mode 100644 index 0000000..f705383 --- /dev/null +++ b/demos/embedded/anomaly/src/BookmarksView.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "BookmarksView.h" + +#include <QtGui> + +BookmarksView::BookmarksView(QWidget *parent) + : QWidget(parent) +{ + QListWidget *m_iconView = new QListWidget(this); + connect(m_iconView, SIGNAL(itemActivated(QListWidgetItem*)), SLOT(activate(QListWidgetItem*))); + + QVBoxLayout *layout = new QVBoxLayout(this); + setLayout(layout); + layout->addWidget(m_iconView); + + m_iconView->addItem("www.google.com"); + m_iconView->addItem("doc.trolltech.com/4.5"); + m_iconView->addItem("news.bbc.co.uk/text_only.stm"); + m_iconView->addItem("mobile.wikipedia.org"); + m_iconView->addItem("www.qtsoftware.com"); + m_iconView->addItem("en.wikipedia.org"); + + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); +} + +void BookmarksView::activate(QListWidgetItem *item) +{ + QUrl url = item->text().prepend("http://"); + emit urlSelected(url); +} diff --git a/demos/embedded/anomaly/src/BookmarksView.h b/demos/embedded/anomaly/src/BookmarksView.h new file mode 100644 index 0000000..95abdd7 --- /dev/null +++ b/demos/embedded/anomaly/src/BookmarksView.h @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef BOOKMARKSVIEW_H +#define BOOKMARKSVIEW_H + +#include <QWidget> + +class QListWidgetItem; +class QUrl; + +class BookmarksView : public QWidget +{ + Q_OBJECT + +public: + BookmarksView(QWidget *parent = 0); + +signals: + void urlSelected(const QUrl &url); + +private slots: + void activate(QListWidgetItem *item); +}; + +#endif // BOOKMARKSVIEW_H diff --git a/demos/embedded/anomaly/src/BrowserView.cpp b/demos/embedded/anomaly/src/BrowserView.cpp new file mode 100644 index 0000000..e81d834 --- /dev/null +++ b/demos/embedded/anomaly/src/BrowserView.cpp @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "BrowserView.h" + +#include <QtGui> +#include <QtNetwork> +#include <QtWebKit> + +#include "ControlStrip.h" +#include "TitleBar.h" +#include "flickcharm.h" +#include "ZoomStrip.h" + +BrowserView::BrowserView(QWidget *parent) + : QWidget(parent) + , m_titleBar(0) + , m_webView(0) + , m_progress(0) + , m_currentZoom(100) +{ + m_titleBar = new TitleBar(this); + m_webView = new QWebView(this); + m_zoomStrip = new ZoomStrip(this); + m_controlStrip = new ControlStrip(this); + + m_zoomLevels << 30 << 50 << 67 << 80 << 90; + m_zoomLevels << 100; + m_zoomLevels << 110 << 120 << 133 << 150 << 170 << 200 << 240 << 300; + + QTimer::singleShot(0, this, SLOT(initialize())); +} + +void BrowserView::initialize() +{ + connect(m_zoomStrip, SIGNAL(zoomInClicked()), SLOT(zoomIn())); + connect(m_zoomStrip, SIGNAL(zoomOutClicked()), SLOT(zoomOut())); + + connect(m_controlStrip, SIGNAL(menuClicked()), SIGNAL(menuButtonClicked())); + connect(m_controlStrip, SIGNAL(backClicked()), m_webView, SLOT(back())); + connect(m_controlStrip, SIGNAL(forwardClicked()), m_webView, SLOT(forward())); + + QPalette pal = m_webView->palette(); + pal.setBrush(QPalette::Base, Qt::white); + m_webView->setPalette(pal); + + FlickCharm *flickCharm = new FlickCharm(this); + flickCharm->activateOn(m_webView); + + m_webView->setZoomFactor(static_cast<qreal>(m_currentZoom)/100.0); + connect(m_webView, SIGNAL(loadStarted()), SLOT(start())); + connect(m_webView, SIGNAL(loadProgress(int)), SLOT(setProgress(int))); + connect(m_webView, SIGNAL(loadFinished(bool)), SLOT(finish(bool))); + connect(m_webView, SIGNAL(urlChanged(QUrl)), SLOT(updateTitleBar())); + + m_webView->load(QUrl("http://news.bbc.co.uk/text_only.stm")); + m_webView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + m_webView->setFocus(); +} + +void BrowserView::start() +{ + m_progress = 0; + updateTitleBar(); + //m_titleBar->setText(m_webView->url().toString()); +} + +void BrowserView::setProgress(int percent) +{ + m_progress = percent; + updateTitleBar(); + //m_titleBar->setText(QString("Loading %1%").arg(percent)); +} + +void BrowserView::updateTitleBar() +{ + QUrl url = m_webView->url(); + m_titleBar->setHost(url.host()); + m_titleBar->setTitle(m_webView->title()); + m_titleBar->setProgress(m_progress); +} + +void BrowserView::finish(bool ok) +{ + m_progress = 0; + updateTitleBar(); + + // TODO: handle error + if (!ok) { + //m_titleBar->setText("Loading failed."); + } +} + +void BrowserView::zoomIn() +{ + int i = m_zoomLevels.indexOf(m_currentZoom); + Q_ASSERT(i >= 0); + if (i < m_zoomLevels.count() - 1) + m_currentZoom = m_zoomLevels[i + 1]; + + m_webView->setZoomFactor(static_cast<qreal>(m_currentZoom)/100.0); +} + +void BrowserView::zoomOut() +{ + int i = m_zoomLevels.indexOf(m_currentZoom); + Q_ASSERT(i >= 0); + if (i > 0) + m_currentZoom = m_zoomLevels[i - 1]; + + m_webView->setZoomFactor(static_cast<qreal>(m_currentZoom)/100.0); +} + +void BrowserView::resizeEvent(QResizeEvent *event) +{ + QWidget::resizeEvent(event); + + int h1 = m_titleBar->sizeHint().height(); + int h2 = m_controlStrip->sizeHint().height(); + + m_titleBar->setGeometry(0, 0, width(), h1); + m_controlStrip->setGeometry(0, height() - h2, width(), h2); + m_webView->setGeometry(0, h1, width(), height() - h1); + + int zw = m_zoomStrip->sizeHint().width(); + int zh = m_zoomStrip->sizeHint().height(); + m_zoomStrip->move(width() - zw, (height() - zh) / 2); +} + +void BrowserView::navigate(const QUrl &url) +{ + m_webView->load(url); +} diff --git a/demos/embedded/anomaly/src/BrowserView.h b/demos/embedded/anomaly/src/BrowserView.h new file mode 100644 index 0000000..36d3291 --- /dev/null +++ b/demos/embedded/anomaly/src/BrowserView.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef BROWSERVIEW_H +#define BROWSERVIEW_H + +#include <QWidget> +#include <QVector> + +class QUrl; +class QWebView; +class TitleBar; +class ControlStrip; +class ZoomStrip; + +class BrowserView : public QWidget +{ + Q_OBJECT + +public: + BrowserView(QWidget *parent = 0); + +public slots: + void navigate(const QUrl &url); + void zoomIn(); + void zoomOut(); + +private slots: + void initialize(); + void start(); + void setProgress(int percent); + void finish(bool); + void updateTitleBar(); + +signals: + void menuButtonClicked(); + +protected: + void resizeEvent(QResizeEvent *event); + +private: + TitleBar *m_titleBar; + QWebView *m_webView; + ZoomStrip *m_zoomStrip; + ControlStrip *m_controlStrip; + int m_progress; + int m_currentZoom; + QVector<int> m_zoomLevels; +}; + +#endif // BROWSERVIEW_H diff --git a/demos/embedded/anomaly/src/BrowserWindow.cpp b/demos/embedded/anomaly/src/BrowserWindow.cpp new file mode 100644 index 0000000..fd2f833 --- /dev/null +++ b/demos/embedded/anomaly/src/BrowserWindow.cpp @@ -0,0 +1,169 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "BrowserWindow.h" + +#include <QtCore> +#include <QtGui> + +#include "BrowserView.h" +#include "HomeView.h" + +BrowserWindow::BrowserWindow() + : QWidget() + , m_homeView(0) + , m_browserView(0) +{ + m_timeLine = new QTimeLine(300, this); + m_timeLine->setCurveShape(QTimeLine::EaseInOutCurve); + QTimer::singleShot(0, this, SLOT(initialize())); +} + +void BrowserWindow::initialize() +{ + m_homeView = new HomeView(this); + m_browserView = new BrowserView(this); + + m_homeView->hide(); + m_homeView->resize(size()); + m_homeView->move(0, 0); + + m_browserView->hide(); + m_browserView->resize(size()); + m_browserView->move(0, 0); + + connect(m_homeView, SIGNAL(addressEntered(QString)), SLOT(gotoAddress(QString))); + connect(m_homeView, SIGNAL(urlActivated(QUrl)), SLOT(navigate(QUrl))); + + connect(m_browserView, SIGNAL(menuButtonClicked()), SLOT(showHomeView())); + + m_homeView->setVisible(false); + m_browserView->setVisible(false); + slide(0); + + connect(m_timeLine, SIGNAL(frameChanged(int)), SLOT(slide(int))); +} + + +// from Demo Browser +QUrl guessUrlFromString(const QString &string) +{ + QString urlStr = string.trimmed(); + QRegExp test(QLatin1String("^[a-zA-Z]+\\:.*")); + + // Check if it looks like a qualified URL. Try parsing it and see. + bool hasSchema = test.exactMatch(urlStr); + if (hasSchema) { + QUrl url = QUrl::fromEncoded(urlStr.toUtf8(), QUrl::TolerantMode); + if (url.isValid()) + return url; + } + + // Might be a file. + if (QFile::exists(urlStr)) { + QFileInfo info(urlStr); + return QUrl::fromLocalFile(info.absoluteFilePath()); + } + + // Might be a shorturl - try to detect the schema. + if (!hasSchema) { + int dotIndex = urlStr.indexOf(QLatin1Char('.')); + if (dotIndex != -1) { + QString prefix = urlStr.left(dotIndex).toLower(); + QString schema = (prefix == QString("ftp")) ? prefix.toLatin1() : QString("http"); + QString location = schema + "://" + urlStr; + QUrl url = QUrl::fromEncoded(location.toUtf8(), QUrl::TolerantMode); + if (url.isValid()) + return url; + } + } + + // Fall back to QUrl's own tolerant parser. + QUrl url = QUrl::fromEncoded(string.toUtf8(), QUrl::TolerantMode); + + // finally for cases where the user just types in a hostname add http + if (url.scheme().isEmpty()) + url = QUrl::fromEncoded("http://" + string.toUtf8(), QUrl::TolerantMode); + return url; +} + +void BrowserWindow::gotoAddress(const QString &address) +{ + m_browserView->navigate(guessUrlFromString(address)); + showBrowserView(); +} + +void BrowserWindow::navigate(const QUrl &url) +{ + m_browserView->navigate(url); + showBrowserView(); +} + +void BrowserWindow::slide(int pos) +{ + m_browserView->move(pos, 0); + m_homeView->move(pos - width(), 0); + m_browserView->show(); + m_homeView->show(); +} + +void BrowserWindow::showHomeView() +{ + if (m_timeLine->state() != QTimeLine::NotRunning) + return; + + m_timeLine->setFrameRange(0, width()); + m_timeLine->start(); + m_homeView->setFocus(); +} + +void BrowserWindow::showBrowserView() +{ + if (m_timeLine->state() != QTimeLine::NotRunning) + return; + + m_timeLine->setFrameRange(width(), 0); + m_timeLine->start(); + m_browserView->setFocus(); +} + +void BrowserWindow::keyReleaseEvent(QKeyEvent *event) +{ + QWidget::keyReleaseEvent(event); + + if (event->key() == Qt::Key_F3) { + if (m_homeView->isVisible()) + showBrowserView(); + else + showHomeView(); + } +} + +void BrowserWindow::resizeEvent(QResizeEvent *event) +{ + if (m_homeView) + m_homeView->resize(size()); + + if (m_browserView) + m_browserView->resize(size()); +} diff --git a/demos/embedded/anomaly/src/BrowserWindow.h b/demos/embedded/anomaly/src/BrowserWindow.h new file mode 100644 index 0000000..50a6508 --- /dev/null +++ b/demos/embedded/anomaly/src/BrowserWindow.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + + +#ifndef BROWSERWINDOW_H +#define BROWSERWINDOW_H + +#include <QWidget> +class QTimeLine; +class QUrl; + +class BrowserView; +class HomeView; + +class BrowserWindow : public QWidget +{ + Q_OBJECT + +public: + BrowserWindow(); + +private slots: + void initialize(); + void navigate(const QUrl &url); + void gotoAddress(const QString &address); + +public slots: + void showBrowserView(); + void showHomeView(); + void slide(int); + +protected: + void keyReleaseEvent(QKeyEvent *event); + void resizeEvent(QResizeEvent *event); + +private: + HomeView *m_homeView; + BrowserView *m_browserView; + QTimeLine *m_timeLine; +}; + +#endif // BROWSERWINDOW_H diff --git a/demos/embedded/anomaly/src/ControlStrip.cpp b/demos/embedded/anomaly/src/ControlStrip.cpp new file mode 100644 index 0000000..72bc485 --- /dev/null +++ b/demos/embedded/anomaly/src/ControlStrip.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "ControlStrip.h" + +#include <QtCore> +#include <QtGui> + +ControlStrip::ControlStrip(QWidget *parent) + : QWidget(parent) +{ + menuPixmap.load(":/images/edit-find.png"); + backPixmap.load(":/images/go-previous.png"); + forwardPixmap.load(":/images/go-next.png"); +} + +QSize ControlStrip::sizeHint() const +{ + return minimumSizeHint(); +} + +QSize ControlStrip::minimumSizeHint() const +{ + return QSize(320, 48); +} + +void ControlStrip::mousePressEvent(QMouseEvent *event) +{ + int h = height(); + int x = event->pos().x(); + + if (x < h) { + emit menuClicked(); + event->accept(); + return; + } + + if (x > width() - h) { + emit forwardClicked(); + event->accept(); + return; + } + + if ((x < width() - 2 * h) && (x > width() - 3 * h)) { + emit backClicked(); + event->accept(); + return; + } +} + +void ControlStrip::paintEvent(QPaintEvent *event) +{ + int h = height(); + int s = (h - menuPixmap.height()) / 2; + + QPainter p(this); + p.fillRect(event->rect(), QColor(32, 32, 32, 192)); + p.setCompositionMode(QPainter::CompositionMode_SourceOver); + p.drawPixmap(s, s, menuPixmap); + p.drawPixmap(width() - 3 * h + s, s, backPixmap); + p.drawPixmap(width() - h + s, s, forwardPixmap); + p.end(); +} diff --git a/demos/embedded/anomaly/src/ControlStrip.h b/demos/embedded/anomaly/src/ControlStrip.h new file mode 100644 index 0000000..99fc58d --- /dev/null +++ b/demos/embedded/anomaly/src/ControlStrip.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef CONTROLSTRIP_H +#define CONTROLSTRIP_H + +#include <QWidget> + +class ControlStrip : public QWidget +{ + Q_OBJECT + +public: + ControlStrip(QWidget *parent = 0); + + QSize sizeHint() const; + QSize minimumSizeHint() const; + +signals: + void menuClicked(); + void backClicked(); + void forwardClicked(); + +protected: + void paintEvent(QPaintEvent *event); + void mousePressEvent(QMouseEvent *event); + +private: + QPixmap menuPixmap; + QPixmap backPixmap; + QPixmap forwardPixmap; +}; + +#endif // CONTROLSTRIP_H diff --git a/demos/embedded/anomaly/src/HomeView.cpp b/demos/embedded/anomaly/src/HomeView.cpp new file mode 100644 index 0000000..0f59d54 --- /dev/null +++ b/demos/embedded/anomaly/src/HomeView.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "HomeView.h" + +#include <QtCore> +#include <QtGui> + +#include "AddressBar.h" +#include "BookmarksView.h" + +HomeView::HomeView(QWidget *parent) + : QWidget(parent) + , m_addressBar(0) +{ + m_addressBar = new AddressBar(parent); + connect(m_addressBar, SIGNAL(addressEntered(QString)), SLOT(gotoAddress(QString))); + + m_bookmarks = new BookmarksView(parent); + connect(m_bookmarks, SIGNAL(urlSelected(QUrl)), SIGNAL(urlActivated(QUrl))); + + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setMargin(4); + layout->setSpacing(4); + layout->addWidget(m_addressBar); + layout->addWidget(m_bookmarks); +} + +void HomeView::gotoAddress(const QString &address) +{ + emit addressEntered(address); +} + +void HomeView::focusInEvent(QFocusEvent *event) +{ + m_addressBar->setFocus(); + QWidget::focusInEvent(event); +} diff --git a/demos/embedded/anomaly/src/HomeView.h b/demos/embedded/anomaly/src/HomeView.h new file mode 100644 index 0000000..b54f07e --- /dev/null +++ b/demos/embedded/anomaly/src/HomeView.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef HOMEVIEW_H +#define HOMEVIEW_H + +#include <QWidget> + +class QUrl; + +class AddressBar; +class BookmarksView; + +class HomeView : public QWidget +{ + Q_OBJECT + +public: + HomeView(QWidget *parent); + +signals: + void urlActivated(const QUrl &url); + void addressEntered(const QString &address); + +private slots: + void gotoAddress(const QString &address); + +protected: + void focusInEvent(QFocusEvent *event); + +private: + AddressBar *m_addressBar; + BookmarksView *m_bookmarks; +}; + +#endif // HOMEVIEW_H diff --git a/demos/embedded/anomaly/src/Main.cpp b/demos/embedded/anomaly/src/Main.cpp new file mode 100644 index 0000000..2be6143 --- /dev/null +++ b/demos/embedded/anomaly/src/Main.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include <QtCore> +#include <QtGui> +#include <QtWebKit> + +#include "BrowserWindow.h" + +#if defined (Q_OS_SYMBIAN) +#include "sym_iap_util.h" +#endif + +int main(int argc, char *argv[]) +{ +#if !defined(Q_WS_S60) + QApplication::setGraphicsSystem("raster"); +#endif + + QApplication app(argc, argv); + + app.setApplicationName("Anomaly"); + app.setApplicationVersion("0.0.0"); + + BrowserWindow window; +#ifdef Q_OS_SYMBIAN + window.showFullScreen(); + QWebSettings::globalSettings()->setObjectCacheCapacities(128*1024, 1024*1024, 1024*1024); + QWebSettings::globalSettings()->setMaximumPagesInCache(3); + qt_SetDefaultIap(); +#else + window.resize(360, 640); + window.show(); + app.setStyle("windows"); +#endif + + return app.exec(); +} + diff --git a/demos/embedded/anomaly/src/TitleBar.cpp b/demos/embedded/anomaly/src/TitleBar.cpp new file mode 100644 index 0000000..ff7837c --- /dev/null +++ b/demos/embedded/anomaly/src/TitleBar.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "TitleBar.h" + +#include <QtCore> +#include <QtGui> + +TitleBar::TitleBar(QWidget *parent) + : QWidget(parent) + , m_progress(0) +{ + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); +} + +void TitleBar::setHost(const QString &host) +{ + m_host = host; + update(); +} + +void TitleBar::setTitle(const QString &title) +{ + m_title = title; + update(); +} + +void TitleBar::setProgress(int percent) +{ + m_progress = percent; + update(); +} + +QSize TitleBar::sizeHint() const +{ + return minimumSizeHint(); +} + +QSize TitleBar::minimumSizeHint() const +{ + QFontMetrics fm = fontMetrics(); + return QSize(100, fm.height()); +} + +void TitleBar::paintEvent(QPaintEvent *event) +{ + QString title = m_host; + if (!m_title.isEmpty()) + title.append(": ").append(m_title); + + QPalette pal = palette(); + QPainter p(this); + p.fillRect(event->rect(), pal.color(QPalette::Highlight)); + + if (m_progress > 0) { + + QRect box = rect(); + box.setLeft(16); + box.setWidth(width() - box.left() - 110); + + p.setPen(pal.color(QPalette::HighlightedText)); + p.setOpacity(0.8); + p.drawText(box, Qt::AlignLeft + Qt::AlignVCenter, title); + + int x = width() - 100 - 5; + int y = 1; + int h = height() - 4; + + p.setOpacity(1.0); + p.setBrush(Qt::NoBrush); + p.setPen(pal.color(QPalette::HighlightedText)); + p.drawRect(x, y, 100, h); + p.setPen(Qt::NoPen); + p.setBrush(pal.color(QPalette::HighlightedText)); + p.drawRect(x, y, m_progress, h); + } else { + + QRect box = rect(); + box.setLeft(16); + box.setWidth(width() - box.left() - 5); + p.setPen(pal.color(QPalette::HighlightedText)); + p.drawText(box, Qt::AlignLeft + Qt::AlignVCenter, title); + } + + p.end(); +} diff --git a/demos/embedded/anomaly/src/TitleBar.h b/demos/embedded/anomaly/src/TitleBar.h new file mode 100644 index 0000000..10ef2a8 --- /dev/null +++ b/demos/embedded/anomaly/src/TitleBar.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef TITLEBAR_H +#define TITLEBAR_H + +#include <QWidget> + +class TitleBar : public QWidget +{ + Q_OBJECT + +public: + TitleBar(QWidget *parent = 0); + + void setHost(const QString &host); + void setTitle(const QString &title); + void setProgress(int percent); + + QSize sizeHint() const; + QSize minimumSizeHint() const; + +protected: + void paintEvent(QPaintEvent *event); + +private: + QString m_host; + QString m_title; + int m_progress; +}; + +#endif // TITLEBAR_H diff --git a/demos/embedded/anomaly/src/ZoomStrip.cpp b/demos/embedded/anomaly/src/ZoomStrip.cpp new file mode 100644 index 0000000..80bfdea --- /dev/null +++ b/demos/embedded/anomaly/src/ZoomStrip.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "ZoomStrip.h" + +#include <QtCore> +#include <QtGui> + +ZoomStrip::ZoomStrip(QWidget *parent) + : QWidget(parent) +{ + zoomInPixmap.load(":/images/list-add.png"); + zoomOutPixmap.load(":/images/list-remove.png"); +} + +QSize ZoomStrip::sizeHint() const +{ + return minimumSizeHint(); +} + +QSize ZoomStrip::minimumSizeHint() const +{ + return QSize(48, 96); +} + +void ZoomStrip::mousePressEvent(QMouseEvent *event) +{ + if (event->pos().y() < height() / 2) + emit zoomInClicked(); + else + emit zoomOutClicked(); +} + +void ZoomStrip::paintEvent(QPaintEvent *event) +{ + int w = width(); + int s = (w - zoomInPixmap.width()) / 2; + + QPainter p(this); + p.fillRect(event->rect(), QColor(128, 128, 128, 128)); + p.drawPixmap(s, s, zoomInPixmap); + p.drawPixmap(s, s + w, zoomOutPixmap); + p.end(); +} diff --git a/demos/embedded/anomaly/src/ZoomStrip.h b/demos/embedded/anomaly/src/ZoomStrip.h new file mode 100644 index 0000000..fdf0328 --- /dev/null +++ b/demos/embedded/anomaly/src/ZoomStrip.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef ZOOMSTRIP_H +#define ZOOMSTRIP_H + +#include <QWidget> + +class ZoomStrip : public QWidget +{ + Q_OBJECT + +public: + ZoomStrip(QWidget *parent = 0); + + QSize sizeHint() const; + QSize minimumSizeHint() const; + +signals: + void zoomInClicked(); + void zoomOutClicked(); + +protected: + void paintEvent(QPaintEvent *event); + void mousePressEvent(QMouseEvent *event); + +private: + QPixmap zoomInPixmap; + QPixmap zoomOutPixmap; +}; + +#endif // ZOOMSTRIP_H diff --git a/demos/embedded/anomaly/src/anomaly.qrc b/demos/embedded/anomaly/src/anomaly.qrc new file mode 100644 index 0000000..601a34e --- /dev/null +++ b/demos/embedded/anomaly/src/anomaly.qrc @@ -0,0 +1,9 @@ +<RCC> + <qresource prefix="/" > + <file>images/go-next.png</file> + <file>images/go-previous.png</file> + <file>images/edit-find.png</file> + <file>images/list-add.png</file> + <file>images/list-remove.png</file> + </qresource> +</RCC> diff --git a/demos/embedded/anomaly/src/flickcharm.cpp b/demos/embedded/anomaly/src/flickcharm.cpp new file mode 100644 index 0000000..620ef88 --- /dev/null +++ b/demos/embedded/anomaly/src/flickcharm.cpp @@ -0,0 +1,309 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Graphics Dojo project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "flickcharm.h" + +#include <QAbstractScrollArea> +#include <QApplication> +#include <QBasicTimer> +#include <QEvent> +#include <QHash> +#include <QList> +#include <QMouseEvent> +#include <QScrollBar> +#include <QWebFrame> +#include <QWebView> + +#include <QDebug> + +struct FlickData { + typedef enum { Steady, Pressed, ManualScroll, AutoScroll, Stop } State; + State state; + QWidget *widget; + QPoint pressPos; + QPoint offset; + QPoint dragPos; + QPoint speed; + QList<QEvent*> ignored; +}; + +class FlickCharmPrivate +{ +public: + QHash<QWidget*, FlickData*> flickData; + QBasicTimer ticker; +}; + +FlickCharm::FlickCharm(QObject *parent): QObject(parent) +{ + d = new FlickCharmPrivate; +} + +FlickCharm::~FlickCharm() +{ + delete d; +} + +void FlickCharm::activateOn(QWidget *widget) +{ + QAbstractScrollArea *scrollArea = dynamic_cast<QAbstractScrollArea*>(widget); + if (scrollArea) { + scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + QWidget *viewport = scrollArea->viewport(); + + viewport->installEventFilter(this); + scrollArea->installEventFilter(this); + + d->flickData.remove(viewport); + d->flickData[viewport] = new FlickData; + d->flickData[viewport]->widget = widget; + d->flickData[viewport]->state = FlickData::Steady; + + return; + } + + QWebView *webView = dynamic_cast<QWebView*>(widget); + if (webView) { + QWebFrame *frame = webView->page()->mainFrame(); + frame->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); + frame->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); + + webView->installEventFilter(this); + + d->flickData.remove(webView); + d->flickData[webView] = new FlickData; + d->flickData[webView]->widget = webView; + d->flickData[webView]->state = FlickData::Steady; + + return; + } + + qWarning() << "FlickCharm only works on QAbstractScrollArea (and derived classes)"; + qWarning() << "or QWebView (and derived classes)"; +} + +void FlickCharm::deactivateFrom(QWidget *widget) +{ + QAbstractScrollArea *scrollArea = dynamic_cast<QAbstractScrollArea*>(widget); + if (scrollArea) { + QWidget *viewport = scrollArea->viewport(); + + viewport->removeEventFilter(this); + scrollArea->removeEventFilter(this); + + delete d->flickData[viewport]; + d->flickData.remove(viewport); + + return; + } + + QWebView *webView = dynamic_cast<QWebView*>(widget); + if (webView) { + webView->removeEventFilter(this); + + delete d->flickData[webView]; + d->flickData.remove(webView); + + return; + } +} + +static QPoint scrollOffset(QWidget *widget) +{ + int x = 0, y = 0; + + QAbstractScrollArea *scrollArea = dynamic_cast<QAbstractScrollArea*>(widget); + if (scrollArea) { + x = scrollArea->horizontalScrollBar()->value(); + y = scrollArea->verticalScrollBar()->value(); + } + + QWebView *webView = dynamic_cast<QWebView*>(widget); + if (webView) { + QWebFrame *frame = webView->page()->mainFrame(); + x = frame->evaluateJavaScript("window.scrollX").toInt(); + y = frame->evaluateJavaScript("window.scrollY").toInt(); + } + + return QPoint(x, y); +} + +static void setScrollOffset(QWidget *widget, const QPoint &p) +{ + QAbstractScrollArea *scrollArea = dynamic_cast<QAbstractScrollArea*>(widget); + if (scrollArea) { + scrollArea->horizontalScrollBar()->setValue(p.x()); + scrollArea->verticalScrollBar()->setValue(p.y()); + } + + QWebView *webView = dynamic_cast<QWebView*>(widget); + QWebFrame *frame = webView ? webView->page()->mainFrame() : 0; + if (frame) + frame->evaluateJavaScript(QString("window.scrollTo(%1,%2);").arg(p.x()).arg(p.y())); +} + +static QPoint deaccelerate(const QPoint &speed, int a = 1, int max = 64) +{ + int x = qBound(-max, speed.x(), max); + int y = qBound(-max, speed.y(), max); + x = (x == 0) ? x : (x > 0) ? qMax(0, x - a) : qMin(0, x + a); + y = (y == 0) ? y : (y > 0) ? qMax(0, y - a) : qMin(0, y + a); + return QPoint(x, y); +} + +bool FlickCharm::eventFilter(QObject *object, QEvent *event) +{ + if (!object->isWidgetType()) + return false; + + QEvent::Type type = event->type(); + if (type != QEvent::MouseButtonPress && + type != QEvent::MouseButtonRelease && + type != QEvent::MouseMove) + return false; + + QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(event); + if (!mouseEvent || mouseEvent->modifiers() != Qt::NoModifier) + return false; + + QWidget *viewport = dynamic_cast<QWidget*>(object); + FlickData *data = d->flickData.value(viewport); + if (!viewport || !data || data->ignored.removeAll(event)) + return false; + + bool consumed = false; + switch (data->state) { + + case FlickData::Steady: + if (mouseEvent->type() == QEvent::MouseButtonPress) + if (mouseEvent->buttons() == Qt::LeftButton) { + consumed = true; + data->state = FlickData::Pressed; + data->pressPos = mouseEvent->pos(); + data->offset = scrollOffset(data->widget); + } + break; + + case FlickData::Pressed: + if (mouseEvent->type() == QEvent::MouseButtonRelease) { + consumed = true; + data->state = FlickData::Steady; + + QMouseEvent *event1 = new QMouseEvent(QEvent::MouseButtonPress, + data->pressPos, Qt::LeftButton, + Qt::LeftButton, Qt::NoModifier); + QMouseEvent *event2 = new QMouseEvent(*mouseEvent); + + data->ignored << event1; + data->ignored << event2; + QApplication::postEvent(object, event1); + QApplication::postEvent(object, event2); + } + if (mouseEvent->type() == QEvent::MouseMove) { + consumed = true; + data->state = FlickData::ManualScroll; + data->dragPos = QCursor::pos(); + if (!d->ticker.isActive()) + d->ticker.start(20, this); + } + break; + + case FlickData::ManualScroll: + if (mouseEvent->type() == QEvent::MouseMove) { + consumed = true; + QPoint delta = mouseEvent->pos() - data->pressPos; + setScrollOffset(data->widget, data->offset - delta); + } + if (mouseEvent->type() == QEvent::MouseButtonRelease) { + consumed = true; + data->state = FlickData::AutoScroll; + } + break; + + case FlickData::AutoScroll: + if (mouseEvent->type() == QEvent::MouseButtonPress) { + consumed = true; + data->state = FlickData::Stop; + data->speed = QPoint(0, 0); + data->pressPos = mouseEvent->pos(); + data->offset = scrollOffset(data->widget); + } + if (mouseEvent->type() == QEvent::MouseButtonRelease) { + consumed = true; + data->state = FlickData::Steady; + data->speed = QPoint(0, 0); + } + break; + + case FlickData::Stop: + if (mouseEvent->type() == QEvent::MouseButtonRelease) { + consumed = true; + data->state = FlickData::Steady; + } + if (mouseEvent->type() == QEvent::MouseMove) { + consumed = true; + data->state = FlickData::ManualScroll; + data->dragPos = QCursor::pos(); + if (!d->ticker.isActive()) + d->ticker.start(20, this); + } + break; + + default: + break; + } + + return consumed; +} + +void FlickCharm::timerEvent(QTimerEvent *event) +{ + int count = 0; + QHashIterator<QWidget*, FlickData*> item(d->flickData); + while (item.hasNext()) { + item.next(); + FlickData *data = item.value(); + + if (data->state == FlickData::ManualScroll) { + count++; + data->speed = QCursor::pos() - data->dragPos; + data->dragPos = QCursor::pos(); + } + + if (data->state == FlickData::AutoScroll) { + count++; + data->speed = deaccelerate(data->speed); + QPoint p = scrollOffset(data->widget); + setScrollOffset(data->widget, p - data->speed); + if (data->speed == QPoint(0, 0)) + data->state = FlickData::Steady; + } + } + + if (!count) + d->ticker.stop(); + + QObject::timerEvent(event); +} diff --git a/demos/embedded/anomaly/src/flickcharm.h b/demos/embedded/anomaly/src/flickcharm.h new file mode 100644 index 0000000..3b3831f --- /dev/null +++ b/demos/embedded/anomaly/src/flickcharm.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Graphics Dojo project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef FLICKCHARM_H +#define FLICKCHARM_H + +#include <QObject> + +class FlickCharmPrivate; +class QWidget; + +class FlickCharm: public QObject +{ + Q_OBJECT +public: + FlickCharm(QObject *parent = 0); + ~FlickCharm(); + void activateOn(QWidget *widget); + void deactivateFrom(QWidget *widget); + bool eventFilter(QObject *object, QEvent *event); + +protected: + void timerEvent(QTimerEvent *event); + +private: + FlickCharmPrivate *d; +}; + +#endif // FLICKCHARM_H diff --git a/demos/embedded/anomaly/src/images/edit-find.png b/demos/embedded/anomaly/src/images/edit-find.png Binary files differnew file mode 100644 index 0000000..5594785 --- /dev/null +++ b/demos/embedded/anomaly/src/images/edit-find.png diff --git a/demos/embedded/anomaly/src/images/go-next.png b/demos/embedded/anomaly/src/images/go-next.png Binary files differnew file mode 100644 index 0000000..a68e2db --- /dev/null +++ b/demos/embedded/anomaly/src/images/go-next.png diff --git a/demos/embedded/anomaly/src/images/go-previous.png b/demos/embedded/anomaly/src/images/go-previous.png Binary files differnew file mode 100644 index 0000000..c37bc04 --- /dev/null +++ b/demos/embedded/anomaly/src/images/go-previous.png diff --git a/demos/embedded/anomaly/src/images/list-add.png b/demos/embedded/anomaly/src/images/list-add.png Binary files differnew file mode 100644 index 0000000..2acdd8f --- /dev/null +++ b/demos/embedded/anomaly/src/images/list-add.png diff --git a/demos/embedded/anomaly/src/images/list-remove.png b/demos/embedded/anomaly/src/images/list-remove.png Binary files differnew file mode 100644 index 0000000..c5524f7 --- /dev/null +++ b/demos/embedded/anomaly/src/images/list-remove.png diff --git a/demos/embedded/embedded.pro b/demos/embedded/embedded.pro index 8214dd3..8a79298 100644 --- a/demos/embedded/embedded.pro +++ b/demos/embedded/embedded.pro @@ -7,6 +7,8 @@ contains(QT_CONFIG, svg) { desktopservices } +SUBDIRS += anomaly + # install sources.files = README *.pro sources.path = $$[QT_INSTALL_DEMOS]/embedded diff --git a/dist/changes-4.5.2-tower b/dist/changes-4.5.2-tower index c3d5673..edc029b 100644 --- a/dist/changes-4.5.2-tower +++ b/dist/changes-4.5.2-tower @@ -4,8 +4,6 @@ Qt 4.5.2-tower The Qt for S60 "Tower" release is the fifth pre-release from the Qt for S60 porting project. "Tower" is based on the Qt 4.5 codebase. -Up to and including SHA: not yet started :D - Lists just S60 fixes, for general 4.5.0 changes go to: http://www.qtsoftware.com/developer/changes/changes-4.5.0 @@ -30,8 +28,11 @@ New modules - QtSql * Implemented QtSql module with sqlite3 backend. For now backend is provided only in binary format. + - QtWebkit - * Experimental webkit build for s60. Can be enabled by passing -webkit to configure. + * Experimental webkit build for s60. Can be enabled by passing -webkit + to configure. + - Phonon * The Phonon library is now part of Qt, but it comes without a backend. This means that applications can build and run against the Phonon @@ -61,17 +62,18 @@ Ported classes - QSound * Implemented CMdaAudioPlayerUtility based Symbian backend for QSound. + - QLocalSocket and QLocalServer - * Added support for QLocalSocket and QLocalServer on Symbian + * Added support for QLocalSocket and QLocalServer on Symbian. Features -------- - QApplication - * Implemented QApplication::beep() for Symbian + * Implemented QApplication::beep() for Symbian. - QSslSocket * Added support for -openssl option i.e. runtime resolving of OpenSSL - symbols + symbols. - QWidget * Basic widgets are now navigatable and usable via keypad on SDK 3 @@ -87,32 +89,34 @@ Optimizations * Optimized drawing operations for RVCT builds, particulary for ARMV6. - qwidget_s60.cpp - * Avoid unnecessary calls to FocusChanged in Symbian + * Avoid unnecessary calls to FocusChanged in Symbian. **************************************************************************** * Code clean-up * **************************************************************************** - Cleanup qeventdispatcher_unix.cpp - * 247268: All qeventdispatcher_unix.cpp changes were reverted since, + * 247268: All qeventdispatcher_unix.cpp changes were reverted since this file is not anymore used in Symbian OS branch. + - Cleanup QtNetwork workarounds implemented earlier due to Open C bugs. - * 247287: Removed getaddrinfo workaround - * 247288: Removed waitForConnected workaround - * 247289: Removed qt_socket_accept workaround - * 247290: Removed qt_socket_connect workaround - * 247290: Removed E32IONREAD workaround - * 247293: Removed nativeHasPendingDatagrams workaround + * 247287: Removed getaddrinfo workaround. + * 247288: Removed waitForConnected workaround. + * 247289: Removed qt_socket_accept workaround. + * 247290: Removed qt_socket_connect workaround. + * 247290: Removed E32IONREAD workaround. + * 247293: Removed nativeHasPendingDatagrams workaround. * 247295: Removed QNativeSocketEnginePrivate::nativeRead EPIPE - workaround + workaround. + - Other code clean-ups * 247278: Removed unnecessary includes from qbackingstore.cpp. - * Fixed Q_OS_SYMBIAN ifdef usage in qfiledialog_p.h + * Fixed Q_OS_SYMBIAN ifdef usage in qfiledialog_p.h. * 247272: Removed qtestnetworkservers.h dependency, used - network-settings.h + network-settings.h. * Revert "Work around compiler bug on Nokia Metrowerks compiler." - * Remove UI highlights being inverted colors based on highlight text colors. - + * Remove UI highlights being inverted colors based on highlight text + colors. **************************************************************************** * Build issues * @@ -122,33 +126,31 @@ Optimizations * QT_NO_DEBUG now properly defined in release mode. - QTest * Fixed testlib export macros for RVCT builds. -- namespaces - * Now builds when -qtnamespace option is defined + +- Namespaces + * Now builds when -qtnamespace option is defined. **************************************************************************** * Changes to existing classes * **************************************************************************** - QDesktopServices - * Fixed forwardslash/backslash usage as an path separator + * Fixed forwardslash/backslash usage as an path separator. - QPluginLoader * QPluginLoader will look for plugin stubs from the same folder on other drives if it can't find them from the indicated drive. -- QEventDispatcher - * Lowered the timeout for reprioritizing the process to 100ms - - QNetworkInterface - * Fixed R-handle leak in Symbian version of qnetworkinterface_unix.cpp + * Fixed R-handle leak in Symbian version of qnetworkinterface_unix.cpp. * Introduced a new qnetworkinterface_symbian.cpp, because there wasn't - really anything common to UNIX equivalent + really anything common to UNIX equivalent. - QHostInfo * Added support for host lookups with multiple ipv4 addresses. - QUdpSocket - * Updated BindFlag documentation to reflect behaviour on Symbian OS + * Updated BindFlag documentation to reflect behaviour on Symbian OS. - QLocale * Removed workaround for missing tzname symbol, fixes QLocal timeZone @@ -158,7 +160,7 @@ Optimizations * Fixed temporary file rename in Symbian OS. - QThread - * Fix for thread termination in Symbian OS. + * Fixed thread termination in Symbian OS. - QIoDevice * Fixed compilation error when QIODEVICE_DEBUG is defined. @@ -166,13 +168,16 @@ Optimizations - QS60Style * Added subElementRect implementation for SE_ItemViewItemCheckIndicator. * Added support for E90 layouts. - * Added support for QScrollArea, QTextEditor, QGroupBox, QTreeView, QToolBar and QDial styling. + * Added support for QScrollArea, QTextEditor, QGroupBox, QTreeView, + QToolBar and QDial styling. * Better support for theme and layout changes. * Better support for themed palettes and themed text colors. * Better support for multiselection in item views. * Better theming for QTable and QPanel. - * Better support of highlight graphics and texts for QLists, QTreeViews, QCalendarWidgets and QComboBoxes. - * Support polishing fonts. Fonts are no longer changed within the drawing code. + * Better support of highlight graphics and texts for QLists, QTreeViews, + QCalendarWidgets and QComboBoxes. + * Support polishing fonts. Fonts are no longer changed within the drawing + code. * Draw spinbox arrowbuttons side-by-side, instead one on top of the other. * Harmonize widget drawing so that widgets are of similar height. * Support check states for QLists and QPushButtons. @@ -183,12 +188,13 @@ Optimizations * Separate theme background for QDialogs. * Clarify QToolButton pressed state. * Removed linedrawing of panels and groupboxes. - * Fix palette-polution for a style that is activated from an application after S60Style has been in use. + * Fix palette-polution for a style that is activated from an application + after S60Style has been in use. * Fix for frame masks with color depth other than EGrey2. * Fix for squeezed QTabBars. * Fix memory leak when color skinning graphics. * Show focus/Editfocus visualization for KeyPad navigation on - SDK 3 FP 1 and FP 2 + SDK 3 FP 1 and FP 2. - QDesktopServices * Switched QDesktopServices mail-to URL handling to RSendAs in Symbian, @@ -211,36 +217,37 @@ Optimizations - QApplication * 252798: Fixed layout when orientation changed via AknAppUi::SetOrientationL. - * Generating MouseEvents has gone through several changes + * Generating MouseEvents has gone through several changes. - QUdpSocket * Wrote hack for QUdpSocket::writeDatagram return value in Symbian OS. - QNativeSocketEnginePrivate (non-public) - * Changed select to listen also expectfds in Symbain OS for given - sockets (Workaround to Open C bug). - * Fix to Open C bug: Socket connect failure is indicated exception set. + * Socket connect and listen failure is indicated in exception set. + (Workaround to Open C bug) - QEventDispatcherSymbian (non-public) - * Fixed ASSERT panic in Symbian event dispatcher - * 246600: Fix problem in eventdispatcher destructor / AO canceling - * Fixed active scheduler removal when calling QThread::terminate + * Lowered the timeout for reprioritizing the process to 100ms. + * Fixed ASSERT panic in Symbian event dispatcher. + * 246600: Fix problem in eventdispatcher destructor / AO canceling. + * Fixed active scheduler removal when calling QThread::terminate. * Fix to Open C bug: select sometimes returns -1 and errno is - ECONNREFUSED + ECONNREFUSED. * Fix a crash when using QEventLoop::ExcludeSocketNotifiers flag. * Changed to round robin scheduling for Qt's active objects. Other active objects will still be scheduled like before. - QWidget - * Added API for setting softkeys + * Added API for setting softkeys. - QMenuBar - * Native menus are handled properly even when application has multiple QMainWindows - * Fixed a bug causing both native and qt menu to be created - * Fix for disappearing options menu after coming back from dialog + * Native menus are handled properly even when application has multiple + QMainWindows. + * Fixed a bug causing both native and qt menu to be created. + * Fix for disappearing options menu after coming back from dialog. - QFontDataBase - * Now, also fonts from the user's /resources/fonts direactories are + * Now, also fonts from the user's /resources/fonts directories are available. - QFontMetrics @@ -249,15 +256,16 @@ Optimizations **************************************************************************** * Examples and demos * **************************************************************************** + - Drilldown - * Added to demonstrate QtSql usage in Symbian OS + * Added to demonstrate QtSql usage in Symbian OS. - Deform, Pathstroke, and Wiggly * Removed Symbian specific animation timer fixes since more generic fix was made to event dispatcher. - Ftp - * Enabled default iap setting for FTP example + * Enabled default IAP setting for FTP example. - DesktopServices * Implemented content filters for desktopservices example. @@ -269,17 +277,17 @@ Optimizations - Fluidlauncher * Removed ugly workaround to make emulator deployment work correctly, since the issue has been fixed in qmake. - * Included drilldown to demonstrate QtSql usage - * Updated screenshots to S60 style - * Added softkeys example + * Included drilldown to demonstrate QtSql usage. + * Updated screenshots to S60 style. + * Added softkeys example. - Softkeys - * New example showing how to use softkeys API in QWidget - + * New example showing how to use softkeys API in QWidget. **************************************************************************** * Tools * **************************************************************************** + - qmake * Support for generating Symbian "test" targets: CONFIG += symbian_test. * Support for Symbian Build System, version 2 (aka Raptor) via @@ -306,13 +314,15 @@ Optimizations * Now creates packages with .sis suffix. - Patch_capabilities script - * Will now patch also vendor id. + * Will now patch also vendor id in binaries and the UID in the pkg file. + **************************************************************************** * Documentation * **************************************************************************** + - qmake-manual - * 250370: Added documentation for ICON keyword + * 250370: Added documentation for ICON keyword. **************************************************************************** * Plugins * |