rhodes 5.5.0.3 → 5.5.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/lib/commonAPI/coreapi/ext/platform/android/src/com/rho/notification/NotificationSingleton.java +20 -8
- data/lib/commonAPI/coreapi/ext/platform/iphone/cpp_based_impl/SystemImpl.mm +1 -2
- data/lib/commonAPI/coreapi/ext/system.xml +1 -1
- data/platform/android/build/android.rake +1 -0
- data/platform/iphone/Classes/AppManager/AppManager.m +44 -3
- data/platform/iphone/Classes/NativeView/RhoNativeViewManager.mm +4 -3
- data/platform/iphone/Classes/NativeView/RhoNativeViewManagerOC.h +1 -1
- data/platform/iphone/Classes/RhoMainView.h +8 -2
- data/platform/iphone/Classes/RhoUIWebView.h +75 -0
- data/platform/iphone/Classes/RhoUIWebView.m +142 -0
- data/platform/iphone/Classes/RhoWKWebView.h +87 -0
- data/platform/iphone/Classes/RhoWKWebView.m +187 -0
- data/platform/iphone/Classes/RhoWebView.h +72 -0
- data/platform/iphone/Classes/RhoWebViewFabrique.h +35 -0
- data/platform/iphone/Classes/RhoWebViewFabrique.m +87 -0
- data/platform/iphone/Classes/Rhodes.m +17 -6
- data/platform/iphone/Classes/Signature.old/SignatureDelegate.m +11 -4
- data/platform/iphone/Classes/Signature/SignatureDelegate.m +3 -4
- data/platform/iphone/Classes/SimpleMainView.h +7 -5
- data/platform/iphone/Classes/SimpleMainView.m +174 -179
- data/platform/iphone/Classes/SplitView/RightViewController.h +2 -2
- data/platform/iphone/Classes/SplitView/RightViewController.m +9 -10
- data/platform/iphone/Classes/SplitView/SplittedMainView.h +2 -3
- data/platform/iphone/Classes/SplitView/SplittedMainView.m +10 -7
- data/platform/iphone/Classes/TabbedMainView.h +2 -1
- data/platform/iphone/Classes/TabbedMainView.m +13 -10
- data/platform/iphone/Classes/URLProtocol/CRhoURLProtocol.m +21 -5
- data/platform/iphone/Classes/WebView.m +1 -1
- data/platform/iphone/RhoAppBaseLib/RhoAppBaseLib.xcodeproj/project.pbxproj +40 -3
- data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +4 -0
- data/platform/iphone/rbuild/iphone.rake +51 -0
- data/platform/shared/common/RhoNativeViewManager.h +9 -9
- data/platform/shared/common/RhodesApp.cpp +13 -1
- data/platform/shared/net/HttpServer.cpp +12 -2
- data/platform/shared/qt/rhodes/ExternalWebView.ui +11 -2
- data/platform/shared/qt/rhodes/QtMainWindow.cpp +9 -7
- data/platform/shared/qt/rhodes/QtMainWindow.ui +13 -4
- data/platform/shared/qt/rhodes/qkineticscroller.cpp +1245 -0
- data/platform/shared/qt/rhodes/qkineticscroller.h +165 -0
- data/platform/shared/qt/rhodes/qkineticscroller_p.h +168 -0
- data/platform/shared/qt/rhodes/qtflickgesture.cpp +696 -0
- data/platform/shared/qt/rhodes/qtflickgesture_p.h +107 -0
- data/platform/shared/qt/rhodes/qtscroller.cpp +2080 -0
- data/platform/shared/qt/rhodes/qtscroller.h +138 -0
- data/platform/shared/qt/rhodes/qtscroller_p.h +205 -0
- data/platform/shared/qt/rhodes/qtscrollerfilter.cpp +350 -0
- data/platform/shared/qt/rhodes/qtscrollerfilter_p.h +110 -0
- data/platform/shared/qt/rhodes/qtscrollerproperties.cpp +412 -0
- data/platform/shared/qt/rhodes/qtscrollerproperties.h +135 -0
- data/platform/shared/qt/rhodes/qtscrollerproperties_p.h +90 -0
- data/platform/shared/qt/rhodes/qtscrollevent.cpp +190 -0
- data/platform/shared/qt/rhodes/qtscrollevent.h +100 -0
- data/platform/shared/qt/rhodes/qtscrollevent_p.h +33 -0
- data/platform/shared/qt/rhodes/qwebviewkineticscroller.cpp +347 -0
- data/platform/shared/qt/rhodes/qwebviewkineticscroller.h +90 -0
- data/platform/shared/qt/rhodes/qwebviewselectionsuppressor.h +113 -0
- data/platform/shared/qt/rhodes/rhodes.pro +19 -0
- data/res/generators/rhogen.rb +307 -15
- data/res/generators/templates/application/app/Settings/err_sync.erb +12 -6
- data/res/generators/templates/application/app/Settings/home.erb +32 -17
- data/res/generators/templates/application/app/Settings/index.erb +55 -26
- data/res/generators/templates/application/app/Settings/javascript_index.html +111 -0
- data/res/generators/templates/application/app/Settings/javascript_login.html +65 -0
- data/res/generators/templates/application/app/Settings/login.erb +25 -19
- data/res/generators/templates/application/app/Settings/reset.erb +18 -9
- data/res/generators/templates/application/app/Settings/wait.erb +10 -7
- data/res/generators/templates/application/app/index.erb +32 -20
- data/res/generators/templates/application/app/javascript_index.html +66 -0
- data/res/generators/templates/application/app/javascript_index.js +250 -0
- data/res/generators/templates/application/app/layout.erb +12 -67
- data/res/generators/templates/application/javascript_build.yml +41 -0
- data/res/generators/templates/application/javascript_rhoconfig.txt +123 -0
- data/res/generators/templates/application/public/bootstrap-3.3.7/css/bootstrap-theme.css +587 -0
- data/res/generators/templates/application/public/bootstrap-3.3.7/css/bootstrap-theme.css.map +1 -0
- data/res/generators/templates/application/public/bootstrap-3.3.7/css/bootstrap-theme.min.css +6 -0
- data/res/generators/templates/application/public/bootstrap-3.3.7/css/bootstrap-theme.min.css.map +1 -0
- data/res/generators/templates/application/public/bootstrap-3.3.7/css/bootstrap.css +6757 -0
- data/res/generators/templates/application/public/bootstrap-3.3.7/css/bootstrap.css.map +1 -0
- data/res/generators/templates/application/public/bootstrap-3.3.7/css/bootstrap.min.css +6 -0
- data/res/generators/templates/application/public/bootstrap-3.3.7/css/bootstrap.min.css.map +1 -0
- data/res/generators/templates/application/public/bootstrap-3.3.7/fonts/glyphicons-halflings-regular.eot +0 -0
- data/res/generators/templates/application/public/bootstrap-3.3.7/fonts/glyphicons-halflings-regular.svg +288 -0
- data/res/generators/templates/application/public/bootstrap-3.3.7/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/res/generators/templates/application/public/bootstrap-3.3.7/fonts/glyphicons-halflings-regular.woff +0 -0
- data/res/generators/templates/application/public/bootstrap-3.3.7/fonts/glyphicons-halflings-regular.woff2 +0 -0
- data/res/generators/templates/application/public/bootstrap-3.3.7/js/bootstrap.js +2377 -0
- data/res/generators/templates/application/public/bootstrap-3.3.7/js/bootstrap.min.js +7 -0
- data/res/generators/templates/application/public/bootstrap-3.3.7/js/npm.js +13 -0
- data/res/generators/templates/application/public/css/style.css +3 -0
- data/res/generators/templates/application/public/jquery/jquery-3.1.1.min.js +4 -0
- data/res/generators/templates/application/public/jquery/jquery-3.1.1.min.map +1 -0
- data/res/generators/templates/application/rhoconfig.txt +16 -0
- data/res/generators/templates/iphone_project/Bremen7.xcodeproj/project.pbxproj +4 -0
- data/res/generators/templates/model/edit.erb +22 -21
- data/res/generators/templates/model/index.erb +24 -22
- data/res/generators/templates/model/javascript_edit.html +65 -0
- data/res/generators/templates/model/javascript_index.html +56 -0
- data/res/generators/templates/model/javascript_index.js +83 -0
- data/res/generators/templates/model/javascript_model.js +16 -0
- data/res/generators/templates/model/javascript_new.html +64 -0
- data/res/generators/templates/model/javascript_show.html +66 -0
- data/res/generators/templates/model/new.erb +22 -19
- data/res/generators/templates/model/show.erb +22 -14
- data/res/prebuild_base_app/app/index.erb +31 -18
- data/res/prebuild_base_app/app/layout.erb +11 -56
- data/version +1 -1
- metadata +59 -24
- data/res/generators/templates/application/public/css/android.css +0 -418
- data/res/generators/templates/application/public/css/iphone.css +0 -378
- data/res/generators/templates/application/public/css/jqmobile-patch.css +0 -62
- data/res/generators/templates/application/public/css/re_webkit.css +0 -736
- data/res/generators/templates/application/public/css/re_webkit_flat.css +0 -753
- data/res/generators/templates/application/public/css/windows_mobile.css +0 -327
- data/res/generators/templates/application/public/jqmobile/images/ajax-loader.gif +0 -0
- data/res/generators/templates/application/public/jqmobile/images/icon-search-black.png +0 -0
- data/res/generators/templates/application/public/jqmobile/images/icons-18-black.png +0 -0
- data/res/generators/templates/application/public/jqmobile/images/icons-18-white.png +0 -0
- data/res/generators/templates/application/public/jqmobile/images/icons-36-black.png +0 -0
- data/res/generators/templates/application/public/jqmobile/images/icons-36-white.png +0 -0
- data/res/generators/templates/application/public/jqmobile/jquery.mobile-1.4.5.min.css +0 -3
- data/res/generators/templates/application/public/jqmobile/jquery.mobile-1.4.5.min.js +0 -10
- data/res/generators/templates/application/public/jqmobile/jquery.mobile-1.4.5.min.map +0 -1
- data/res/generators/templates/application/public/jqmobile/jquery.mobile.structure-1.4.5.min.css +0 -3
- data/res/generators/templates/application/public/jqmobile/jquery.mobile.theme-1.4.5.min.css +0 -3
- data/res/generators/templates/application/public/jquery/jquery-1.9.1.min.js +0 -5
- data/res/generators/templates/application/public/jquery/jquery-1.9.1.min.map +0 -1
- data/res/generators/templates/application/public/js/application.js +0 -1
- data/res/generators/templates/application/public/js/jqmobile-patch.js +0 -466
- data/res/generators/templates/application/public/js/syncengine.js +0 -504
@@ -0,0 +1,138 @@
|
|
1
|
+
/****************************************************************************
|
2
|
+
**
|
3
|
+
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
4
|
+
** All rights reserved.
|
5
|
+
** Contact: Nokia Corporation (qt-info@nokia.com)
|
6
|
+
**
|
7
|
+
** This file is part of the QtGui module of the Qt Toolkit.
|
8
|
+
**
|
9
|
+
** $QT_BEGIN_LICENSE:LGPL$
|
10
|
+
** No Commercial Usage
|
11
|
+
** This file contains pre-release code and may not be distributed.
|
12
|
+
** You may use this file in accordance with the terms and conditions
|
13
|
+
** contained in the Technology Preview License Agreement accompanying
|
14
|
+
** this package.
|
15
|
+
**
|
16
|
+
** GNU Lesser General Public License Usage
|
17
|
+
** Alternatively, this file may be used under the terms of the GNU Lesser
|
18
|
+
** General Public License version 2.1 as published by the Free Software
|
19
|
+
** Foundation and appearing in the file LICENSE.LGPL included in the
|
20
|
+
** packaging of this file. Please review the following information to
|
21
|
+
** ensure the GNU Lesser General Public License version 2.1 requirements
|
22
|
+
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
23
|
+
**
|
24
|
+
** In addition, as a special exception, Nokia gives you certain additional
|
25
|
+
** rights. These rights are described in the Nokia Qt LGPL Exception
|
26
|
+
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
27
|
+
**
|
28
|
+
** If you have questions regarding the use of this file, please contact
|
29
|
+
** Nokia at qt-info@nokia.com.
|
30
|
+
**
|
31
|
+
**
|
32
|
+
**
|
33
|
+
**
|
34
|
+
**
|
35
|
+
**
|
36
|
+
**
|
37
|
+
**
|
38
|
+
** $QT_END_LICENSE$
|
39
|
+
**
|
40
|
+
****************************************************************************/
|
41
|
+
|
42
|
+
#ifndef QTSCROLLER_H
|
43
|
+
#define QTSCROLLER_H
|
44
|
+
|
45
|
+
#include <QtCore/QObject>
|
46
|
+
#include <QtCore/QPointF>
|
47
|
+
#include "qtscrollerproperties.h"
|
48
|
+
|
49
|
+
class QWidget;
|
50
|
+
class QtScrollerPrivate;
|
51
|
+
class QtScrollerProperties;
|
52
|
+
class QtFlickGestureRecognizer;
|
53
|
+
|
54
|
+
class QtScroller : public QObject
|
55
|
+
{
|
56
|
+
Q_OBJECT
|
57
|
+
Q_PROPERTY(State state READ state NOTIFY stateChanged)
|
58
|
+
Q_PROPERTY(QtScrollerProperties scrollerProperties READ scrollerProperties WRITE setScrollerProperties NOTIFY scrollerPropertiesChanged)
|
59
|
+
Q_ENUMS(State)
|
60
|
+
|
61
|
+
public:
|
62
|
+
enum State
|
63
|
+
{
|
64
|
+
Inactive,
|
65
|
+
Pressed,
|
66
|
+
Dragging,
|
67
|
+
Scrolling
|
68
|
+
};
|
69
|
+
|
70
|
+
enum ScrollerGestureType
|
71
|
+
{
|
72
|
+
TouchGesture,
|
73
|
+
LeftMouseButtonGesture,
|
74
|
+
RightMouseButtonGesture,
|
75
|
+
MiddleMouseButtonGesture
|
76
|
+
};
|
77
|
+
|
78
|
+
enum Input
|
79
|
+
{
|
80
|
+
InputPress = 1,
|
81
|
+
InputMove,
|
82
|
+
InputRelease
|
83
|
+
};
|
84
|
+
|
85
|
+
static bool hasScroller(QObject *target);
|
86
|
+
|
87
|
+
static QtScroller *scroller(QObject *target);
|
88
|
+
static const QtScroller *scroller(const QObject *target);
|
89
|
+
|
90
|
+
static Qt::GestureType grabGesture(QObject *target, ScrollerGestureType gestureType = TouchGesture);
|
91
|
+
static Qt::GestureType grabbedGesture(QObject *target);
|
92
|
+
static void ungrabGesture(QObject *target);
|
93
|
+
|
94
|
+
static QList<QtScroller *> activeScrollers();
|
95
|
+
|
96
|
+
QObject *target() const;
|
97
|
+
|
98
|
+
State state() const;
|
99
|
+
|
100
|
+
bool handleInput(Input input, const QPointF &position, qint64 timestamp = 0);
|
101
|
+
|
102
|
+
void stop();
|
103
|
+
QPointF velocity() const;
|
104
|
+
QPointF finalPosition() const;
|
105
|
+
QPointF pixelPerMeter() const;
|
106
|
+
|
107
|
+
QtScrollerProperties scrollerProperties() const;
|
108
|
+
|
109
|
+
void setSnapPositionsX( const QList<qreal> &positions );
|
110
|
+
void setSnapPositionsX( qreal first, qreal interval );
|
111
|
+
void setSnapPositionsY( const QList<qreal> &positions );
|
112
|
+
void setSnapPositionsY( qreal first, qreal interval );
|
113
|
+
|
114
|
+
public Q_SLOTS:
|
115
|
+
void setScrollerProperties(const QtScrollerProperties &prop);
|
116
|
+
void scrollTo(const QPointF &pos);
|
117
|
+
void scrollTo(const QPointF &pos, int scrollTime);
|
118
|
+
void ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin);
|
119
|
+
void ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin, int scrollTime);
|
120
|
+
void resendPrepareEvent();
|
121
|
+
|
122
|
+
Q_SIGNALS:
|
123
|
+
void stateChanged(QtScroller::State newstate);
|
124
|
+
void scrollerPropertiesChanged(const QtScrollerProperties &);
|
125
|
+
|
126
|
+
private:
|
127
|
+
QtScrollerPrivate* d_ptr;
|
128
|
+
|
129
|
+
QtScroller(QObject *target);
|
130
|
+
virtual ~QtScroller();
|
131
|
+
|
132
|
+
Q_DISABLE_COPY(QtScroller)
|
133
|
+
Q_DECLARE_PRIVATE(QtScroller)
|
134
|
+
|
135
|
+
friend class QtFlickGestureRecognizer;
|
136
|
+
};
|
137
|
+
|
138
|
+
#endif // QTSCROLLER_H
|
@@ -0,0 +1,205 @@
|
|
1
|
+
/****************************************************************************
|
2
|
+
**
|
3
|
+
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
4
|
+
** All rights reserved.
|
5
|
+
** Contact: Nokia Corporation (qt-info@nokia.com)
|
6
|
+
**
|
7
|
+
** This file is part of the QtGui module of the Qt Toolkit.
|
8
|
+
**
|
9
|
+
** $QT_BEGIN_LICENSE:LGPL$
|
10
|
+
** No Commercial Usage
|
11
|
+
** This file contains pre-release code and may not be distributed.
|
12
|
+
** You may use this file in accordance with the terms and conditions
|
13
|
+
** contained in the Technology Preview License Agreement accompanying
|
14
|
+
** this package.
|
15
|
+
**
|
16
|
+
** GNU Lesser General Public License Usage
|
17
|
+
** Alternatively, this file may be used under the terms of the GNU Lesser
|
18
|
+
** General Public License version 2.1 as published by the Free Software
|
19
|
+
** Foundation and appearing in the file LICENSE.LGPL included in the
|
20
|
+
** packaging of this file. Please review the following information to
|
21
|
+
** ensure the GNU Lesser General Public License version 2.1 requirements
|
22
|
+
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
23
|
+
**
|
24
|
+
** In addition, as a special exception, Nokia gives you certain additional
|
25
|
+
** rights. These rights are described in the Nokia Qt LGPL Exception
|
26
|
+
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
27
|
+
**
|
28
|
+
** If you have questions regarding the use of this file, please contact
|
29
|
+
** Nokia at qt-info@nokia.com.
|
30
|
+
**
|
31
|
+
**
|
32
|
+
**
|
33
|
+
**
|
34
|
+
**
|
35
|
+
**
|
36
|
+
**
|
37
|
+
**
|
38
|
+
** $QT_END_LICENSE$
|
39
|
+
**
|
40
|
+
****************************************************************************/
|
41
|
+
|
42
|
+
#ifndef QTSCROLLER_P_H
|
43
|
+
#define QTSCROLLER_P_H
|
44
|
+
|
45
|
+
//
|
46
|
+
// W A R N I N G
|
47
|
+
// -------------
|
48
|
+
//
|
49
|
+
// This file is not part of the Qt API. It exists purely as an
|
50
|
+
// implementation detail. This header file may change from version to
|
51
|
+
// version without notice, or even be removed.
|
52
|
+
//
|
53
|
+
// We mean it.
|
54
|
+
//
|
55
|
+
|
56
|
+
#include <QObject>
|
57
|
+
#include <QPointer>
|
58
|
+
#include <QQueue>
|
59
|
+
#include <QSet>
|
60
|
+
#include <QEasingCurve>
|
61
|
+
#if (QT_VERSION < QT_VERSION_CHECK(4, 7, 0))
|
62
|
+
# include <QTime>
|
63
|
+
typedef QTime QElapsedTimer;
|
64
|
+
#else
|
65
|
+
# include <QElapsedTimer>
|
66
|
+
#endif
|
67
|
+
#include <QSizeF>
|
68
|
+
#include <QPointF>
|
69
|
+
#include <QRectF>
|
70
|
+
#include "qtscroller.h"
|
71
|
+
#include "qtscrollerproperties.h"
|
72
|
+
#include "qtscrollerproperties_p.h"
|
73
|
+
#include <QAbstractAnimation>
|
74
|
+
|
75
|
+
class QtFlickGestureRecognizer;
|
76
|
+
|
77
|
+
class QScrollTimer;
|
78
|
+
|
79
|
+
class QtScrollerPrivate : public QObject
|
80
|
+
{
|
81
|
+
Q_OBJECT
|
82
|
+
Q_DECLARE_PUBLIC(QtScroller)
|
83
|
+
|
84
|
+
public:
|
85
|
+
QtScrollerPrivate(QtScroller *q, QObject *target);
|
86
|
+
void init();
|
87
|
+
|
88
|
+
void sendEvent(QObject *o, QEvent *e);
|
89
|
+
|
90
|
+
void setState(QtScroller::State s);
|
91
|
+
|
92
|
+
enum ScrollType {
|
93
|
+
ScrollTypeFlick = 0,
|
94
|
+
ScrollTypeScrollTo,
|
95
|
+
ScrollTypeOvershoot
|
96
|
+
};
|
97
|
+
|
98
|
+
struct ScrollSegment {
|
99
|
+
qint64 startTime;
|
100
|
+
qint64 deltaTime;
|
101
|
+
qreal startPos;
|
102
|
+
qreal deltaPos;
|
103
|
+
QEasingCurve curve;
|
104
|
+
qreal stopProgress; // whatever is..
|
105
|
+
qreal stopPos; // ..reached first
|
106
|
+
ScrollType type;
|
107
|
+
};
|
108
|
+
|
109
|
+
bool pressWhileInactive(const QPointF &position, qint64 timestamp);
|
110
|
+
bool moveWhilePressed(const QPointF &position, qint64 timestamp);
|
111
|
+
bool releaseWhilePressed(const QPointF &position, qint64 timestamp);
|
112
|
+
bool moveWhileDragging(const QPointF &position, qint64 timestamp);
|
113
|
+
bool releaseWhileDragging(const QPointF &position, qint64 timestamp);
|
114
|
+
bool pressWhileScrolling(const QPointF &position, qint64 timestamp);
|
115
|
+
|
116
|
+
void timerTick();
|
117
|
+
void timerEventWhileDragging();
|
118
|
+
void timerEventWhileScrolling();
|
119
|
+
|
120
|
+
bool prepareScrolling(const QPointF &position);
|
121
|
+
void handleDrag(const QPointF &position, qint64 timestamp);
|
122
|
+
|
123
|
+
QPointF realDpi(int screen);
|
124
|
+
QPointF dpi() const;
|
125
|
+
void setDpi(const QPointF &dpi);
|
126
|
+
void setDpiFromWidget(QWidget *widget);
|
127
|
+
|
128
|
+
void updateVelocity(const QPointF &deltaPixelRaw, qint64 deltaTime);
|
129
|
+
void pushSegment(ScrollType type, qreal deltaTime, qreal stopProgress, qreal startPos, qreal deltaPos, qreal stopPos, QEasingCurve::Type curve, Qt::Orientation orientation);
|
130
|
+
void recalcScrollingSegments(bool force = false);
|
131
|
+
qreal scrollingSegmentsEndPos(Qt::Orientation orientation) const;
|
132
|
+
bool scrollingSegmentsValid(Qt::Orientation orientation);
|
133
|
+
void createScrollToSegments(qreal v, qreal deltaTime, qreal endPos, Qt::Orientation orientation, ScrollType type);
|
134
|
+
void createScrollingSegments(qreal v, qreal startPos, qreal ppm, Qt::Orientation orientation);
|
135
|
+
|
136
|
+
void setContentPositionHelperDragging(const QPointF &deltaPos);
|
137
|
+
void setContentPositionHelperScrolling();
|
138
|
+
|
139
|
+
qreal nextSnapPos(qreal p, int dir, Qt::Orientation orientation);
|
140
|
+
static qreal nextSegmentPosition(QQueue<ScrollSegment> &segments, qint64 now, qreal oldPos);
|
141
|
+
|
142
|
+
inline int frameRateSkip() const { return properties.d.data()->frameRate; }
|
143
|
+
|
144
|
+
static const char *stateName(QtScroller::State state);
|
145
|
+
static const char *inputName(QtScroller::Input input);
|
146
|
+
|
147
|
+
public slots:
|
148
|
+
void targetDestroyed();
|
149
|
+
|
150
|
+
public:
|
151
|
+
// static
|
152
|
+
static QMap<QObject *, QtScroller *> allScrollers;
|
153
|
+
static QSet<QtScroller *> activeScrollers;
|
154
|
+
|
155
|
+
// non static
|
156
|
+
QObject *target;
|
157
|
+
QtScrollerProperties properties;
|
158
|
+
QtFlickGestureRecognizer *recognizer;
|
159
|
+
Qt::GestureType recognizerType;
|
160
|
+
|
161
|
+
// scroller state:
|
162
|
+
|
163
|
+
// QPointer<QObject> scrollTarget;
|
164
|
+
QSizeF viewportSize;
|
165
|
+
QRectF contentPosRange;
|
166
|
+
QPointF contentPosition;
|
167
|
+
QPointF overshootPosition; // the number of pixels we are overshooting (before overshootDragResistanceFactor)
|
168
|
+
|
169
|
+
// state
|
170
|
+
|
171
|
+
bool enabled;
|
172
|
+
QtScroller::State state;
|
173
|
+
bool firstScroll; // true if we haven't already send a scroll event
|
174
|
+
|
175
|
+
QPointF oldVelocity; // the release velocity of the last drag
|
176
|
+
|
177
|
+
QPointF pressPosition;
|
178
|
+
QPointF lastPosition;
|
179
|
+
qint64 pressTimestamp;
|
180
|
+
qint64 lastTimestamp;
|
181
|
+
|
182
|
+
QPointF dragDistance; // the distance we should move during the next drag timer event
|
183
|
+
|
184
|
+
QQueue<ScrollSegment> xSegments;
|
185
|
+
QQueue<ScrollSegment> ySegments;
|
186
|
+
|
187
|
+
// snap positions
|
188
|
+
QList<qreal> snapPositionsX;
|
189
|
+
qreal snapFirstX;
|
190
|
+
qreal snapIntervalX;
|
191
|
+
QList<qreal> snapPositionsY;
|
192
|
+
qreal snapFirstY;
|
193
|
+
qreal snapIntervalY;
|
194
|
+
|
195
|
+
QPointF pixelPerMeter;
|
196
|
+
|
197
|
+
QElapsedTimer monotonicTimer;
|
198
|
+
|
199
|
+
QPointF releaseVelocity; // the starting velocity of the scrolling state
|
200
|
+
QScrollTimer *scrollTimer;
|
201
|
+
|
202
|
+
QtScroller *q_ptr;
|
203
|
+
};
|
204
|
+
|
205
|
+
#endif // QTSCROLLER_P_H
|
@@ -0,0 +1,350 @@
|
|
1
|
+
#include <qtscrollerfilter_p.h>
|
2
|
+
#include <qtscrollevent.h>
|
3
|
+
#include <qtscroller.h>
|
4
|
+
#include <QAbstractItemView>
|
5
|
+
#include <QScrollBar>
|
6
|
+
#include <QGestureEvent>
|
7
|
+
#include <QGesture>
|
8
|
+
#include <QGraphicsView>
|
9
|
+
#include <QGraphicsItem>
|
10
|
+
#include <QCoreApplication>
|
11
|
+
|
12
|
+
#ifndef QTSCROLLER_NO_WEBKIT
|
13
|
+
# include <QWebFrame>
|
14
|
+
# include <QWebView>
|
15
|
+
#endif // QTSCROLLER_NO_WEBKIT
|
16
|
+
|
17
|
+
#ifdef Q_WS_WIN
|
18
|
+
# include <qlibrary.h>
|
19
|
+
# include <windows.h>
|
20
|
+
#endif
|
21
|
+
|
22
|
+
#ifdef Q_WS_MAEMO_5
|
23
|
+
# include <QAbstractKineticScroller>
|
24
|
+
#endif
|
25
|
+
|
26
|
+
#include <QtDebug>
|
27
|
+
|
28
|
+
bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event)
|
29
|
+
{
|
30
|
+
return QCoreApplication::sendSpontaneousEvent(receiver, event);
|
31
|
+
}
|
32
|
+
|
33
|
+
|
34
|
+
QtScrollerFilter *QtScrollerFilter::inst = 0;
|
35
|
+
|
36
|
+
QtScrollerFilter *QtScrollerFilter::instance()
|
37
|
+
{
|
38
|
+
if (!inst)
|
39
|
+
inst = new QtScrollerFilter();
|
40
|
+
return inst;
|
41
|
+
}
|
42
|
+
|
43
|
+
QtScrollerFilter::QtScrollerFilter()
|
44
|
+
: ignoreMove(false)
|
45
|
+
{ }
|
46
|
+
|
47
|
+
void QtScrollerFilter::add(QObject *target)
|
48
|
+
{
|
49
|
+
target->installEventFilter(this);
|
50
|
+
connect(QtScroller::scroller(target), SIGNAL(stateChanged(QtScroller::State)),
|
51
|
+
this, SLOT(stateChanged(QtScroller::State)));
|
52
|
+
#ifdef Q_WS_MAEMO_5
|
53
|
+
// disable the kinetic scroller on scrollArea
|
54
|
+
if (QAbstractScrollArea *area = qobject_cast<QAbstractScrollArea *>(target->parent()))
|
55
|
+
target = target->parent();
|
56
|
+
if (QAbstractKineticScroller *m5s = target->property("kineticScroller").value<QAbstractKineticScroller *>()) {
|
57
|
+
if (m5s)
|
58
|
+
m5s->setEnabled(false);
|
59
|
+
}
|
60
|
+
#endif
|
61
|
+
#ifndef QTSCROLLER_NO_WEBKIT
|
62
|
+
if (QWebView *web = qobject_cast<QWebView *>(target)) {
|
63
|
+
if (web->page() && web->page()->mainFrame()) {
|
64
|
+
web->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
|
65
|
+
web->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
|
66
|
+
}
|
67
|
+
}
|
68
|
+
#endif
|
69
|
+
}
|
70
|
+
|
71
|
+
void QtScrollerFilter::remove(QObject *target)
|
72
|
+
{
|
73
|
+
disconnect(QtScroller::scroller(target), SIGNAL(stateChanged(QtScroller::State)),
|
74
|
+
this, SLOT(stateChanged(QtScroller::State)));
|
75
|
+
target->removeEventFilter(this);
|
76
|
+
}
|
77
|
+
|
78
|
+
void QtScrollerFilter::stateChanged(QtScroller::State state)
|
79
|
+
{
|
80
|
+
if (QtScroller *scroller = qobject_cast<QtScroller *>(sender())) {
|
81
|
+
if (QObject *o = scroller->target()) {
|
82
|
+
if (o->isWidgetType()) {
|
83
|
+
QWidget *w = static_cast<QWidget *>(o);
|
84
|
+
|
85
|
+
if (w->parentWidget()) {
|
86
|
+
if (QAbstractScrollArea *area = qobject_cast<QAbstractScrollArea *>(w->parentWidget())) {
|
87
|
+
if (area->viewport() == w) {
|
88
|
+
if (QAbstractItemView *view = qobject_cast<QAbstractItemView *>(area))
|
89
|
+
stateChanged_QAbstractItemView(view, state);
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
bool QtScrollerFilter::eventFilter(QObject *o, QEvent *e)
|
99
|
+
{
|
100
|
+
bool result = false;
|
101
|
+
|
102
|
+
//qWarning() << o << e->type();
|
103
|
+
|
104
|
+
if (o->isWidgetType()) {
|
105
|
+
QWidget *w = static_cast<QWidget *>(o);
|
106
|
+
|
107
|
+
#ifndef QTSCROLLER_NO_WEBKIT
|
108
|
+
if (QWebView *web = qobject_cast<QWebView *>(w))
|
109
|
+
result |= eventFilter_QWebView(web, e);
|
110
|
+
#endif // QTSCROLLER_NO_WEBKIT
|
111
|
+
|
112
|
+
if (w->parentWidget()) {
|
113
|
+
if (QAbstractScrollArea *area = qobject_cast<QAbstractScrollArea *>(w->parentWidget())) {
|
114
|
+
if (area->viewport() == w) {
|
115
|
+
if (QAbstractItemView *view = qobject_cast<QAbstractItemView *>(area))
|
116
|
+
result |= eventFilter_QAbstractItemView(view, e);
|
117
|
+
|
118
|
+
result |= eventFilter_QAbstractScrollArea(area, e);
|
119
|
+
}
|
120
|
+
}
|
121
|
+
}
|
122
|
+
}
|
123
|
+
return result;
|
124
|
+
}
|
125
|
+
|
126
|
+
#ifndef QTSCROLLER_NO_WEBKIT
|
127
|
+
|
128
|
+
bool QtScrollerFilter::eventFilter_QWebView(QWebView *view, QEvent *event)
|
129
|
+
{
|
130
|
+
switch (event->type()) {
|
131
|
+
case QtScrollPrepareEvent::ScrollPrepare: {
|
132
|
+
QtScrollPrepareEvent *se = static_cast<QtScrollPrepareEvent *>(event);
|
133
|
+
scrollingFrames[view] = 0;
|
134
|
+
|
135
|
+
if (view->page()) {
|
136
|
+
if (QWebFrame *frame = scrollingFrameAt_QWebView(view, se->startPos().toPoint())) {
|
137
|
+
scrollingFrames[view] = frame;
|
138
|
+
|
139
|
+
// there's no way to do that from outside of QtWebKit
|
140
|
+
//// remember old selection so that we can restore it later
|
141
|
+
//oldWebSelection = d->frame->selection()->selection();
|
142
|
+
|
143
|
+
se->setViewportSize(frame->geometry().size());
|
144
|
+
QSize s = frame->contentsSize() - frame->geometry().size();
|
145
|
+
se->setContentPosRange(QRectF(0, 0, qMax(0, s.width()), qMax(0, s.height())));
|
146
|
+
se->setContentPos(QPointF(frame->scrollPosition()));
|
147
|
+
se->accept();
|
148
|
+
return true;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
return false;
|
152
|
+
}
|
153
|
+
case QtScrollEvent::Scroll: {
|
154
|
+
if (QWebFrame *frame = scrollingFrames.value(view)) {
|
155
|
+
QtScrollEvent *se = static_cast<QtScrollEvent *>(event);
|
156
|
+
// no way to do that from outside of QtWebKit
|
157
|
+
//// restore the old selection
|
158
|
+
//if (se->scrollState() == QScrollEvent::ScrollStarted)
|
159
|
+
// frame->d->frame->selection()->setSelection(d->oldWebSelection, CharacterGranularity);
|
160
|
+
|
161
|
+
frame->setScrollPosition(se->contentPos().toPoint());
|
162
|
+
|
163
|
+
} else {
|
164
|
+
return false;
|
165
|
+
}
|
166
|
+
}
|
167
|
+
default:
|
168
|
+
return false;
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
QWebFrame *QtScrollerFilter::scrollingFrameAt_QWebView(QWebView *view, const QPoint &pos) const
|
173
|
+
{
|
174
|
+
if (!view->page())
|
175
|
+
return 0;
|
176
|
+
|
177
|
+
QWebFrame *mainFrame = view->page()->mainFrame();
|
178
|
+
QWebHitTestResult hitTest = mainFrame->hitTestContent(pos);
|
179
|
+
QWebFrame *hitFrame = hitTest.frame();
|
180
|
+
|
181
|
+
if (!hitFrame)
|
182
|
+
return 0;
|
183
|
+
|
184
|
+
QRect vsbrect = hitFrame->scrollBarGeometry(Qt::Vertical);
|
185
|
+
QRect hsbrect = hitFrame->scrollBarGeometry(Qt::Horizontal);
|
186
|
+
|
187
|
+
if (!vsbrect.isEmpty() && vsbrect.contains(hitTest.pos() - hitFrame->scrollPosition()))
|
188
|
+
return 0;
|
189
|
+
if (!hsbrect.isEmpty() && hsbrect.contains(hitTest.pos() - hitFrame->scrollPosition()))
|
190
|
+
return 0;
|
191
|
+
|
192
|
+
QSize range = hitFrame->contentsSize() - hitFrame->geometry().size();
|
193
|
+
|
194
|
+
while (hitFrame && range.width() <= 1 && range.height() <= 1)
|
195
|
+
hitFrame = hitFrame->parentFrame();
|
196
|
+
return hitFrame;
|
197
|
+
}
|
198
|
+
|
199
|
+
#endif // QTSCROLLER_NO_WEBKIT
|
200
|
+
|
201
|
+
bool QtScrollerFilter::eventFilter_QAbstractScrollArea(QAbstractScrollArea *area, QEvent *event)
|
202
|
+
{
|
203
|
+
switch (event->type()) {
|
204
|
+
case QtScrollPrepareEvent::ScrollPrepare:
|
205
|
+
{
|
206
|
+
QtScrollPrepareEvent *se = static_cast<QtScrollPrepareEvent *>(event);
|
207
|
+
if (canStartScrollingAt_QAbstractScrollArea(area, se->startPos().toPoint())) {
|
208
|
+
QScrollBar *hBar = area->horizontalScrollBar();
|
209
|
+
QScrollBar *vBar = area->verticalScrollBar();
|
210
|
+
|
211
|
+
se->setViewportSize(QSizeF(area->viewport()->size()));
|
212
|
+
se->setContentPosRange(QRectF(0, 0, hBar->maximum(), vBar->maximum()));
|
213
|
+
se->setContentPos(QPointF(hBar->value(), vBar->value()));
|
214
|
+
se->accept();
|
215
|
+
return true;
|
216
|
+
}
|
217
|
+
return false;
|
218
|
+
}
|
219
|
+
case QtScrollEvent::Scroll:
|
220
|
+
{
|
221
|
+
QtScrollEvent *se = static_cast<QtScrollEvent *>(event);
|
222
|
+
|
223
|
+
QScrollBar *hBar = area->horizontalScrollBar();
|
224
|
+
QScrollBar *vBar = area->verticalScrollBar();
|
225
|
+
hBar->setValue(se->contentPos().x());
|
226
|
+
vBar->setValue(se->contentPos().y());
|
227
|
+
|
228
|
+
QPoint os = overshoot.value(area);
|
229
|
+
#ifdef Q_WS_WIN
|
230
|
+
typedef BOOL (*PtrBeginPanningFeedback)(HWND);
|
231
|
+
typedef BOOL (*PtrUpdatePanningFeedback)(HWND, LONG, LONG, BOOL);
|
232
|
+
typedef BOOL (*PtrEndPanningFeedback)(HWND, BOOL);
|
233
|
+
|
234
|
+
static PtrBeginPanningFeedback ptrBeginPanningFeedback = 0;
|
235
|
+
static PtrUpdatePanningFeedback ptrUpdatePanningFeedback = 0;
|
236
|
+
static PtrEndPanningFeedback ptrEndPanningFeedback = 0;
|
237
|
+
|
238
|
+
if (!ptrBeginPanningFeedback)
|
239
|
+
ptrBeginPanningFeedback = (PtrBeginPanningFeedback) QLibrary::resolve(QLatin1String("UxTheme"), "BeginPanningFeedback");
|
240
|
+
if (!ptrUpdatePanningFeedback)
|
241
|
+
ptrUpdatePanningFeedback = (PtrUpdatePanningFeedback) QLibrary::resolve(QLatin1String("UxTheme"), "UpdatePanningFeedback");
|
242
|
+
if (!ptrEndPanningFeedback)
|
243
|
+
ptrEndPanningFeedback = (PtrEndPanningFeedback) QLibrary::resolve(QLatin1String("UxTheme"), "EndPanningFeedback");
|
244
|
+
|
245
|
+
if (ptrBeginPanningFeedback && ptrUpdatePanningFeedback && ptrEndPanningFeedback) {
|
246
|
+
WId wid = area->window()->winId();
|
247
|
+
|
248
|
+
if (!se->overshootDistance().isNull() && os.isNull())
|
249
|
+
ptrBeginPanningFeedback(wid);
|
250
|
+
if (!se->overshootDistance().isNull())
|
251
|
+
ptrUpdatePanningFeedback(wid, -se->overshootDistance().x(), -se->overshootDistance().y(), false);
|
252
|
+
if (se->overshootDistance().isNull() && !os.isNull())
|
253
|
+
ptrEndPanningFeedback(wid, true);
|
254
|
+
} else
|
255
|
+
#endif
|
256
|
+
{
|
257
|
+
QPoint delta = os - se->overshootDistance().toPoint();
|
258
|
+
if (!delta.isNull()) {
|
259
|
+
ignoreMove = true;
|
260
|
+
area->viewport()->move(area->viewport()->pos() + delta);
|
261
|
+
ignoreMove = false;
|
262
|
+
}
|
263
|
+
}
|
264
|
+
overshoot[area] = se->overshootDistance().toPoint();
|
265
|
+
return true;
|
266
|
+
}
|
267
|
+
case QEvent::Move: {
|
268
|
+
if (!ignoreMove && !overshoot.value(area).isNull()) {
|
269
|
+
ignoreMove = true;
|
270
|
+
area->viewport()->move(area->viewport()->pos() - overshoot.value(area));
|
271
|
+
ignoreMove = false;
|
272
|
+
}
|
273
|
+
return false;
|
274
|
+
}
|
275
|
+
default:
|
276
|
+
return false;
|
277
|
+
}
|
278
|
+
}
|
279
|
+
|
280
|
+
struct HackedAbstractItemView : public QAbstractItemView
|
281
|
+
{
|
282
|
+
void hackedExecuteDelayedItemsLayout()
|
283
|
+
{
|
284
|
+
executeDelayedItemsLayout();
|
285
|
+
}
|
286
|
+
};
|
287
|
+
|
288
|
+
void QtScrollerFilter::stateChanged_QAbstractItemView(QAbstractItemView *view, QtScroller::State state)
|
289
|
+
{
|
290
|
+
switch (state) {
|
291
|
+
case QtScroller::Pressed:
|
292
|
+
if (view->selectionModel()) {
|
293
|
+
oldSelection = view->selectionModel()->selection();
|
294
|
+
oldCurrent = view->selectionModel()->currentIndex();
|
295
|
+
} else {
|
296
|
+
oldSelection = QItemSelection();
|
297
|
+
oldCurrent = QModelIndex();
|
298
|
+
}
|
299
|
+
break;
|
300
|
+
|
301
|
+
case QtScroller::Dragging:
|
302
|
+
// restore the old selection if we really start scrolling
|
303
|
+
if (view->selectionModel()) {
|
304
|
+
view->selectionModel()->select(oldSelection, QItemSelectionModel::ClearAndSelect);
|
305
|
+
view->selectionModel()->setCurrentIndex(oldCurrent, QItemSelectionModel::NoUpdate);
|
306
|
+
}
|
307
|
+
// fall through
|
308
|
+
|
309
|
+
default:
|
310
|
+
oldSelection = QItemSelection();
|
311
|
+
oldCurrent = QModelIndex();
|
312
|
+
break;
|
313
|
+
}
|
314
|
+
}
|
315
|
+
|
316
|
+
bool QtScrollerFilter::eventFilter_QAbstractItemView(QAbstractItemView *view, QEvent *event)
|
317
|
+
{
|
318
|
+
switch (event->type()) {
|
319
|
+
case QtScrollPrepareEvent::ScrollPrepare:
|
320
|
+
static_cast<HackedAbstractItemView *>(view)->hackedExecuteDelayedItemsLayout();
|
321
|
+
break;
|
322
|
+
|
323
|
+
default:
|
324
|
+
break;
|
325
|
+
}
|
326
|
+
|
327
|
+
return false;
|
328
|
+
}
|
329
|
+
|
330
|
+
bool QtScrollerFilter::canStartScrollingAt_QAbstractScrollArea(QAbstractScrollArea *area, const QPoint &startPos) const
|
331
|
+
{
|
332
|
+
// don't start scrolling when a drag mode has been set.
|
333
|
+
// don't start scrolling on a movable item.
|
334
|
+
if (QGraphicsView *view = qobject_cast<QGraphicsView *>(area)) {
|
335
|
+
if (view->dragMode() != QGraphicsView::NoDrag)
|
336
|
+
return false;
|
337
|
+
|
338
|
+
QGraphicsItem *childItem = view->itemAt(startPos);
|
339
|
+
|
340
|
+
if (childItem && (childItem->flags() & QGraphicsItem::ItemIsMovable))
|
341
|
+
return false;
|
342
|
+
}
|
343
|
+
|
344
|
+
// don't start scrolling on a QAbstractSlider
|
345
|
+
if (qobject_cast<QAbstractSlider *>(area->viewport()->childAt(startPos))) {
|
346
|
+
return false;
|
347
|
+
}
|
348
|
+
|
349
|
+
return true;
|
350
|
+
}
|