summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2010-01-07 09:57:01 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2010-01-07 09:57:01 (GMT)
commit570338ab3cbca8df3ca8f89579a8f460915e5a1e (patch)
tree8421aa1d9e8eef2b1d05727750d52e3ed1d0f0d8 /demos
parent2f3af7ba11de16fe23906d1bef5ccb6c37e8ccc7 (diff)
parent78221020e2fd9370b0915a32cde81a95bdf44d87 (diff)
downloadQt-570338ab3cbca8df3ca8f89579a8f460915e5a1e.zip
Qt-570338ab3cbca8df3ca8f89579a8f460915e5a1e.tar.gz
Qt-570338ab3cbca8df3ca8f89579a8f460915e5a1e.tar.bz2
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'demos')
-rw-r--r--demos/declarative/flickr/flickr-desktop.qml6
-rw-r--r--demos/embedded/anomaly/src/BrowserWindow.cpp147
-rw-r--r--demos/embedded/anomaly/src/BrowserWindow.h12
-rw-r--r--demos/embedded/anomaly/src/flickcharm.cpp287
-rw-r--r--demos/embedded/fluidlauncher/fluidlauncher.pro5
-rw-r--r--demos/embedded/weatherinfo/weatherinfo.cpp3
6 files changed, 258 insertions, 202 deletions
diff --git a/demos/declarative/flickr/flickr-desktop.qml b/demos/declarative/flickr/flickr-desktop.qml
index 9c85237..10babeb 100644
--- a/demos/declarative/flickr/flickr-desktop.qml
+++ b/demos/declarative/flickr/flickr-desktop.qml
@@ -12,11 +12,13 @@ Item {
id: photoDelegate
Item {
id: wrapper; width: 85; height: 85
- scale: wrapper.PathView.scale; z: wrapper.PathView.z
+ scale: wrapper.PathView.scale ? wrapper.PathView.scale : 1
+ z: wrapper.PathView.z ? wrapper.PathView.z : 0
transform: Rotation {
id: itemRotation; origin.x: wrapper.width/2; origin.y: wrapper.height/2
- axis.y: 1; axis.z: 0; angle: wrapper.PathView.angle
+ axis.y: 1; axis.z: 0
+ angle: wrapper.PathView.angle ? wrapper.PathView.angle : 0
}
Connection {
diff --git a/demos/embedded/anomaly/src/BrowserWindow.cpp b/demos/embedded/anomaly/src/BrowserWindow.cpp
index 1036735..30b6b91 100644
--- a/demos/embedded/anomaly/src/BrowserWindow.cpp
+++ b/demos/embedded/anomaly/src/BrowserWindow.cpp
@@ -43,92 +43,44 @@
#include <QtCore>
#include <QtGui>
+#include <QPropertyAnimation>
+#include <QResizeEvent>
#include "BrowserView.h"
#include "HomeView.h"
BrowserWindow::BrowserWindow()
- : QWidget()
- , m_homeView(0)
- , m_browserView(0)
+ : m_slidingSurface(new QWidget(this))
+ , m_homeView(new HomeView(m_slidingSurface))
+ , m_browserView(new BrowserView(m_slidingSurface))
+ , m_animation(new QPropertyAnimation(this, "slideValue"))
{
- 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_slidingSurface->setAutoFillBackground(true);
- 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);
+ m_animation->setDuration(200);
+ connect(m_animation, SIGNAL(finished()), SLOT(animationFinished()));
- connect(m_timeLine, SIGNAL(frameChanged(int)), SLOT(slide(int)));
+ setSlideValue(0.0f);
}
-
-// from Demo Browser
-QUrl guessUrlFromString(const QString &string)
+void BrowserWindow::gotoAddress(const QString &address)
{
- 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;
+ m_browserView->navigate(QUrl::fromUserInput(address));
+ showBrowserView();
}
-void BrowserWindow::gotoAddress(const QString &address)
+void BrowserWindow::animationFinished()
{
- m_browserView->navigate(guessUrlFromString(address));
- showBrowserView();
+ m_animation->setDirection(QAbstractAnimation::Forward);
}
void BrowserWindow::navigate(const QUrl &url)
@@ -137,31 +89,44 @@ void BrowserWindow::navigate(const QUrl &url)
showBrowserView();
}
-void BrowserWindow::slide(int pos)
+void BrowserWindow::setSlideValue(qreal slideRatio)
{
- m_browserView->move(pos, 0);
- m_homeView->move(pos - width(), 0);
- m_browserView->show();
- m_homeView->show();
+ // we use a ratio to handle resize corectly
+ const int pos = -qRound(slideRatio * width());
+ m_slidingSurface->scroll(pos - m_homeView->x(), 0);
+
+ if (qFuzzyCompare(slideRatio, static_cast<qreal>(1.0f))) {
+ m_browserView->show();
+ m_homeView->hide();
+ } else if (qFuzzyCompare(slideRatio, static_cast<qreal>(0.0f))) {
+ m_homeView->show();
+ m_browserView->hide();
+ } else {
+ m_browserView->show();
+ m_homeView->show();
+ }
}
-void BrowserWindow::showHomeView()
+qreal BrowserWindow::slideValue() const
{
- if (m_timeLine->state() != QTimeLine::NotRunning)
- return;
+ Q_ASSERT(m_slidingSurface->x() < width());
+ return static_cast<qreal>(qAbs(m_homeView->x())) / width();
+}
- m_timeLine->setFrameRange(0, width());
- m_timeLine->start();
+void BrowserWindow::showHomeView()
+{
+ m_animation->setStartValue(slideValue());
+ m_animation->setEndValue(0.0f);
+ m_animation->start();
m_homeView->setFocus();
}
void BrowserWindow::showBrowserView()
{
- if (m_timeLine->state() != QTimeLine::NotRunning)
- return;
+ m_animation->setStartValue(slideValue());
+ m_animation->setEndValue(1.0f);
+ m_animation->start();
- m_timeLine->setFrameRange(width(), 0);
- m_timeLine->start();
m_browserView->setFocus();
}
@@ -170,18 +135,32 @@ void BrowserWindow::keyReleaseEvent(QKeyEvent *event)
QWidget::keyReleaseEvent(event);
if (event->key() == Qt::Key_F3) {
- if (m_homeView->isVisible())
- showBrowserView();
- else
+ if (m_animation->state() == QAbstractAnimation::Running) {
+ const QAbstractAnimation::Direction direction = m_animation->direction() == QAbstractAnimation::Forward
+ ? QAbstractAnimation::Forward
+ : QAbstractAnimation::Backward;
+ m_animation->setDirection(direction);
+ } else if (qFuzzyCompare(slideValue(), static_cast<qreal>(1.0f)))
showHomeView();
+ else
+ showBrowserView();
+ event->accept();
}
}
void BrowserWindow::resizeEvent(QResizeEvent *event)
{
- if (m_homeView)
- m_homeView->resize(size());
+ const QSize oldSize = event->oldSize();
+ const qreal oldSlidingRatio = static_cast<qreal>(qAbs(m_homeView->x())) / oldSize.width();
+
+ const QSize newSize = event->size();
+ m_slidingSurface->resize(newSize.width() * 2, newSize.height());
+
+ m_homeView->resize(newSize);
+ m_homeView->move(0, 0);
+
+ m_browserView->resize(newSize);
+ m_browserView->move(newSize.width(), 0);
- if (m_browserView)
- m_browserView->resize(size());
+ setSlideValue(oldSlidingRatio);
}
diff --git a/demos/embedded/anomaly/src/BrowserWindow.h b/demos/embedded/anomaly/src/BrowserWindow.h
index 9647efb..2b77939 100644
--- a/demos/embedded/anomaly/src/BrowserWindow.h
+++ b/demos/embedded/anomaly/src/BrowserWindow.h
@@ -43,7 +43,7 @@
#define BROWSERWINDOW_H
#include <QWidget>
-class QTimeLine;
+class QPropertyAnimation;
class QUrl;
class BrowserView;
@@ -52,28 +52,32 @@ class HomeView;
class BrowserWindow : public QWidget
{
Q_OBJECT
+ Q_PROPERTY(qreal slideValue READ slideValue WRITE setSlideValue)
public:
BrowserWindow();
private slots:
- void initialize();
void navigate(const QUrl &url);
void gotoAddress(const QString &address);
+ void animationFinished();
public slots:
void showBrowserView();
void showHomeView();
- void slide(int);
protected:
void keyReleaseEvent(QKeyEvent *event);
void resizeEvent(QResizeEvent *event);
private:
+ void setSlideValue(qreal);
+ qreal slideValue() const;
+
+ QWidget *m_slidingSurface;
HomeView *m_homeView;
BrowserView *m_browserView;
- QTimeLine *m_timeLine;
+ QPropertyAnimation *m_animation;
};
#endif // BROWSERWINDOW_H
diff --git a/demos/embedded/anomaly/src/flickcharm.cpp b/demos/embedded/anomaly/src/flickcharm.cpp
index 0b9e68e..b7e2151 100644
--- a/demos/embedded/anomaly/src/flickcharm.cpp
+++ b/demos/embedded/anomaly/src/flickcharm.cpp
@@ -49,20 +49,112 @@
#include <QList>
#include <QMouseEvent>
#include <QScrollBar>
+#include <QTime>
#include <QWebFrame>
#include <QWebView>
#include <QDebug>
+const int fingerAccuracyThreshold = 3;
+
struct FlickData {
- typedef enum { Steady, Pressed, ManualScroll, AutoScroll, Stop } State;
+ typedef enum {
+ Steady, // Interaction without scrolling
+ ManualScroll, // Scrolling manually with the finger on the screen
+ AutoScroll, // Scrolling automatically
+ AutoScrollAcceleration // Scrolling automatically but a finger is on the screen
+ } State;
State state;
QWidget *widget;
QPoint pressPos;
- QPoint offset;
- QPoint dragPos;
+ QPoint lastPos;
QPoint speed;
+ QTime speedTimer;
QList<QEvent*> ignored;
+ QTime accelerationTimer;
+ bool lastPosValid:1;
+ bool waitingAcceleration:1;
+
+ FlickData()
+ : lastPosValid(false)
+ , waitingAcceleration(false)
+ {}
+
+ void resetSpeed()
+ {
+ speed = QPoint();
+ lastPosValid = false;
+ }
+ void updateSpeed(const QPoint &newPosition)
+ {
+ if (lastPosValid) {
+ const int timeElapsed = speedTimer.elapsed();
+ if (timeElapsed) {
+ const QPoint newPixelDiff = (newPosition - lastPos);
+ const QPoint pixelsPerSecond = newPixelDiff * (1000 / timeElapsed);
+ // fingers are inacurates, we ignore small changes to avoid stopping the autoscroll because
+ // of a small horizontal offset when scrolling vertically
+ const int newSpeedY = (qAbs(pixelsPerSecond.y()) > fingerAccuracyThreshold) ? pixelsPerSecond.y() : 0;
+ const int newSpeedX = (qAbs(pixelsPerSecond.x()) > fingerAccuracyThreshold) ? pixelsPerSecond.x() : 0;
+ if (state == AutoScrollAcceleration) {
+ const int max = 4000; // px by seconds
+ const int oldSpeedY = speed.y();
+ const int oldSpeedX = speed.x();
+ if ((oldSpeedY <= 0 && newSpeedY <= 0) || (oldSpeedY >= 0 && newSpeedY >= 0)
+ && (oldSpeedX <= 0 && newSpeedX <= 0) || (oldSpeedX >= 0 && newSpeedX >= 0)) {
+ speed.setY(qBound(-max, (oldSpeedY + (newSpeedY / 4)), max));
+ speed.setX(qBound(-max, (oldSpeedX + (newSpeedX / 4)), max));
+ } else {
+ speed = QPoint();
+ }
+ } else {
+ const int max = 2500; // px by seconds
+ // we average the speed to avoid strange effects with the last delta
+ if (!speed.isNull()) {
+ speed.setX(qBound(-max, (speed.x() / 4) + (newSpeedX * 3 / 4), max));
+ speed.setY(qBound(-max, (speed.y() / 4) + (newSpeedY * 3 / 4), max));
+ } else {
+ speed = QPoint(newSpeedX, newSpeedY);
+ }
+ }
+ }
+ } else {
+ lastPosValid = true;
+ }
+ speedTimer.start();
+ lastPos = newPosition;
+ }
+
+ // scroll by dx, dy
+ // return true if the widget was scrolled
+ bool scrollWidget(const int dx, const int dy)
+ {
+ QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget);
+ if (scrollArea) {
+ const int x = scrollArea->horizontalScrollBar()->value();
+ const int y = scrollArea->verticalScrollBar()->value();
+ scrollArea->horizontalScrollBar()->setValue(x - dx);
+ scrollArea->verticalScrollBar()->setValue(y - dy);
+ return (scrollArea->horizontalScrollBar()->value() != x
+ || scrollArea->verticalScrollBar()->value() != y);
+ }
+
+ QWebView *webView = qobject_cast<QWebView*>(widget);
+ if (webView) {
+ QWebFrame *frame = webView->page()->mainFrame();
+ const QPoint position = frame->scrollPosition();
+ frame->setScrollPosition(position - QPoint(dx, dy));
+ return frame->scrollPosition() != position;
+ }
+ return false;
+ }
+
+ bool scrollTo(const QPoint &newPosition)
+ {
+ const QPoint delta = newPosition - lastPos;
+ updateSpeed(newPosition);
+ return scrollWidget(delta.x(), delta.y());
+ }
};
class FlickCharmPrivate
@@ -70,6 +162,13 @@ class FlickCharmPrivate
public:
QHash<QWidget*, FlickData*> flickData;
QBasicTimer ticker;
+ QTime timeCounter;
+ void startTicker(QObject *object)
+ {
+ if (!ticker.isActive())
+ ticker.start(15, object);
+ timeCounter.start();
+ }
};
FlickCharm::FlickCharm(QObject *parent): QObject(parent)
@@ -148,46 +247,14 @@ void FlickCharm::deactivateFrom(QWidget *widget)
}
}
-static QPoint scrollOffset(QWidget *widget)
+static QPoint deaccelerate(const QPoint &speed, const int deltatime)
{
- int x = 0, y = 0;
-
- QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget);
- if (scrollArea) {
- x = scrollArea->horizontalScrollBar()->value();
- y = scrollArea->verticalScrollBar()->value();
- }
-
- QWebView *webView = qobject_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 = qobject_cast<QAbstractScrollArea*>(widget);
- if (scrollArea) {
- scrollArea->horizontalScrollBar()->setValue(p.x());
- scrollArea->verticalScrollBar()->setValue(p.y());
- }
+ const int deltaSpeed = deltatime;
- QWebView *webView = qobject_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);
+ int x = speed.x();
+ int y = speed.y();
+ x = (x == 0) ? x : (x > 0) ? qMax(0, x - deltaSpeed) : qMin(0, x + deltaSpeed);
+ y = (y == 0) ? y : (y > 0) ? qMax(0, y - deltaSpeed) : qMin(0, y + deltaSpeed);
return QPoint(x, y);
}
@@ -196,22 +263,24 @@ 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;
+ const QEvent::Type type = event->type();
- QMouseEvent *mouseEvent = 0;
- switch (event->type()) {
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonRelease:
- case QEvent::MouseMove:
- mouseEvent = static_cast<QMouseEvent*>(event);
- break;
+ switch (type) {
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseMove:
+ case QEvent::MouseButtonRelease:
+ break;
+ case QEvent::MouseButtonDblClick: // skip double click
+ return true;
+ default:
+ return false;
}
- if (!mouseEvent || mouseEvent->modifiers() != Qt::NoModifier)
+ QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
+ if (type == QEvent::MouseMove && mouseEvent->buttons() != Qt::LeftButton)
+ return false;
+
+ if (mouseEvent->modifiers() != Qt::NoModifier)
return false;
QWidget *viewport = qobject_cast<QWidget*>(object);
@@ -219,89 +288,83 @@ bool FlickCharm::eventFilter(QObject *object, QEvent *event)
if (!viewport || !data || data->ignored.removeAll(event))
return false;
+ const QPoint mousePos = mouseEvent->pos();
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) {
+ if (type == QEvent::MouseButtonPress) {
+ consumed = true;
+ data->pressPos = mousePos;
+ } else if (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);
+ QMouseEvent *event2 = new QMouseEvent(QEvent::MouseButtonRelease,
+ data->pressPos, Qt::LeftButton,
+ Qt::LeftButton, Qt::NoModifier);
data->ignored << event1;
data->ignored << event2;
QApplication::postEvent(object, event1);
QApplication::postEvent(object, event2);
- }
- if (mouseEvent->type() == QEvent::MouseMove) {
+ } else if (type == QEvent::MouseMove) {
consumed = true;
- data->state = FlickData::ManualScroll;
- data->dragPos = QCursor::pos();
- if (!d->ticker.isActive())
- d->ticker.start(20, this);
+ data->scrollTo(mousePos);
+
+ const QPoint delta = mousePos - data->pressPos;
+ if (delta.x() > fingerAccuracyThreshold || delta.y() > fingerAccuracyThreshold)
+ data->state = FlickData::ManualScroll;
}
break;
case FlickData::ManualScroll:
- if (mouseEvent->type() == QEvent::MouseMove) {
+ if (type == QEvent::MouseMove) {
consumed = true;
- QPoint delta = mouseEvent->pos() - data->pressPos;
- setScrollOffset(data->widget, data->offset - delta);
- }
- if (mouseEvent->type() == QEvent::MouseButtonRelease) {
+ data->scrollTo(mousePos);
+ } else if (type == QEvent::MouseButtonRelease) {
consumed = true;
data->state = FlickData::AutoScroll;
+ data->lastPosValid = false;
+ d->startTicker(this);
}
break;
case FlickData::AutoScroll:
- if (mouseEvent->type() == QEvent::MouseButtonPress) {
+ if (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) {
+ data->state = FlickData::AutoScrollAcceleration;
+ data->waitingAcceleration = true;
+ data->accelerationTimer.start();
+ data->updateSpeed(mousePos);
+ data->pressPos = mousePos;
+ } else if (type == QEvent::MouseButtonRelease) {
consumed = true;
data->state = FlickData::Steady;
- data->speed = QPoint(0, 0);
+ data->resetSpeed();
}
break;
- case FlickData::Stop:
- if (mouseEvent->type() == QEvent::MouseButtonRelease) {
+ case FlickData::AutoScrollAcceleration:
+ if (type == QEvent::MouseMove) {
consumed = true;
- data->state = FlickData::Steady;
- }
- if (mouseEvent->type() == QEvent::MouseMove) {
+ data->updateSpeed(mousePos);
+ data->accelerationTimer.start();
+ if (data->speed.isNull())
+ data->state = FlickData::ManualScroll;
+ } else if (type == QEvent::MouseButtonRelease) {
consumed = true;
- data->state = FlickData::ManualScroll;
- data->dragPos = QCursor::pos();
- if (!d->ticker.isActive())
- d->ticker.start(20, this);
+ data->state = FlickData::AutoScroll;
+ data->waitingAcceleration = false;
+ data->lastPosValid = false;
}
break;
-
default:
break;
}
-
- return consumed;
+ data->lastPos = mousePos;
+ return true;
}
void FlickCharm::timerEvent(QTimerEvent *event)
@@ -311,25 +374,29 @@ void FlickCharm::timerEvent(QTimerEvent *event)
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::AutoScrollAcceleration
+ && data->waitingAcceleration
+ && data->accelerationTimer.elapsed() > 40) {
+ data->state = FlickData::ManualScroll;
+ data->resetSpeed();
}
+ if (data->state == FlickData::AutoScroll || data->state == FlickData::AutoScrollAcceleration) {
+ const int timeElapsed = d->timeCounter.elapsed();
+ const QPoint delta = (data->speed) * timeElapsed / 1000;
+ bool hasScrolled = data->scrollWidget(delta.x(), delta.y());
- 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))
+ if (data->speed.isNull() || !hasScrolled)
data->state = FlickData::Steady;
+ else
+ count++;
+ data->speed = deaccelerate(data->speed, timeElapsed);
}
}
if (!count)
d->ticker.stop();
+ else
+ d->timeCounter.start();
QObject::timerEvent(event);
}
diff --git a/demos/embedded/fluidlauncher/fluidlauncher.pro b/demos/embedded/fluidlauncher/fluidlauncher.pro
index b47f6a0..bb8835b 100644
--- a/demos/embedded/fluidlauncher/fluidlauncher.pro
+++ b/demos/embedded/fluidlauncher/fluidlauncher.pro
@@ -163,6 +163,11 @@ symbian {
resource.sources += $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/anomaly.rsc
mifs.sources += \
$${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/anomaly.mif
+
+ # Since Fluidlauncher itself doesn't link webkit, we won't get dependency automatically
+ executables.pkg_prerules += \
+ "; Dependency to Qt Webkit" \
+ "(0x200267C2), $${QT_MAJOR_VERSION}, $${QT_MINOR_VERSION}, $${QT_PATCH_VERSION}, {\"QtWebKit\"}"
}
contains(QT_CONFIG, phonon) {
diff --git a/demos/embedded/weatherinfo/weatherinfo.cpp b/demos/embedded/weatherinfo/weatherinfo.cpp
index 842f05b..3b78a5f 100644
--- a/demos/embedded/weatherinfo/weatherinfo.cpp
+++ b/demos/embedded/weatherinfo/weatherinfo.cpp
@@ -105,9 +105,8 @@ private slots:
void delayedInit() {
#if defined(Q_OS_SYMBIAN)
qt_SetDefaultIap();
-#else
- request("Oslo");
#endif
+ request("Oslo");
}
private slots: