blob: e545c755bd0f297b4c96ce7c3c5882b922719526 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
/****************************************************************************
* Copyright (C) 2012 Instituto Nokia de Tecnologia (INdT) *
* *
* This file may be used under the terms of the GNU Lesser *
* General Public License version 2.1 as published by the Free Software *
* Foundation and appearing in the file LICENSE.LGPL included in the *
* packaging of this file. Please review the following information to *
* ensure the GNU Lesser General Public License version 2.1 requirements *
* will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
****************************************************************************/
import QtQuick 2.0
import QtWebKit 3.0
// What to do on Qt5 !?
import "UiConstants.js" as UiConstants
Item {
id: navigationPanel
property alias url: navigationBar.url
property QtObject visibleTab: TabsModel.currentWebView
property QtObject lastVisibleTab
signal newTabRequested()
signal urlInputRequested()
signal webViewMaximized()
signal webViewMinimized()
Connections {
target: visibleTab
onLoadingChanged: {
if (navigationPanel.state === "withNavigationBarAndOverlay")
return;
navigationBarHidingTimer.updateStateForCurrentTab();
}
}
Binding {
target: visibleTab
property: "interactive"
value: navigationPanel.state !== "withNavigationBarAndOverlay"
}
Image {
id: barsBackground
height: tabBar.height
source: "qrc:///mobile/app/bg_image"
anchors.bottom: parent.bottom
fillMode: Image.Pad
verticalAlignment: Image.AlignBottom
}
SwipeArea {
id: overlay
visible: false
anchors {
top: parent.top
bottom: tabBar.top
left: parent.left
right: parent.right
}
function dismiss() { navigationPanel.state = ""; }
function goToNextTab() {
if (TabsModel.currentWebViewIndex + 1 < TabsModel.count)
TabsModel.currentWebViewIndex++;
}
function goToPreviousTab() {
if (TabsModel.currentWebViewIndex > 0)
TabsModel.currentWebViewIndex--;
}
onSwipeLeft: overlay.goToNextTab()
onSwipeRight: overlay.goToPreviousTab()
onClicked: overlay.dismiss()
}
Item {
id: tabBar
width: UiConstants.PortraitWidth
height: UiConstants.TabBarHeight
anchors.top: barsBackground.top
anchors.left: parent.left
anchors.right: parent.right
IndicatorRow {
id: tabBarRow
anchors {
top: parent.top
bottom: parent.bottom
horizontalCenter: parent.horizontalCenter
topMargin: 25
bottomMargin: 27
}
itemCount: TabsModel.count
maxItems: UiConstants.TabsMaxPages * UiConstants.PagedGridItemsPerPage
currentItem: Math.max(0, TabsModel.currentWebViewIndex)
loadProgress: visibleTab != null ? visibleTab.loadProgress : 0
blinkOnZeroProgress: true
}
SwipeArea {
anchors.fill: parent
onSwipeLeft: overlay.goToNextTab()
onSwipeRight: overlay.goToPreviousTab()
onClicked: navigationPanel.state = "withNavigationBarAndOverlay";
}
}
NavigationBar {
id: navigationBar
currentWebView: navigationPanel.visibleTab
anchors.top: parent.bottom
anchors.bottomMargin: 31
onUrlInputRequested: navigationPanel.urlInputRequested()
onStopRequested: navigationPanel.state = "withNavigationBarAndOverlay"
onReloadRequested: navigationPanel.state = "withNavigationBarAndOverlay"
onBackRequested: navigationPanel.state = "withNavigationBarAndOverlay"
onForwardRequested: navigationPanel.state = "withNavigationBarAndOverlay"
Timer {
id: navigationBarHidingTimer
interval: 2000
onTriggered: {
navigationPanel.state = "";
}
function updateStateForCurrentTab() {
if (navigationPanel.visibleTab.loading) {
navigationPanel.state = "withNavigationBarAndOverlay";
stop();
} else
restart();
}
}
onUrlChanged: overlayBar.pin = BookmarkModel.contains(url);
}
OverlayBar {
id: overlayBar
visible: overlay.visible
anchors {
top: parent.bottom
left: parent.left
right: parent.right
bottomMargin: 31
}
onShowThumbnails: {
navigationPanel.state = "";
TabsModel.currentWebViewIndex = -1;
}
onOpenNewTab: navigationPanel.newTabRequested()
onPinToggled: BookmarkModel.togglePin(visibleTab.url);
Connections {
target: BookmarkModel
onCountChanged: {
if (visibleTab)
overlayBar.pin = BookmarkModel.contains(visibleTab.url);
}
}
}
states: [
State {
name: "withNavigationBarAndOverlay"
PropertyChanges { target: overlay; visible: true }
AnchorChanges { target: navigationBar; anchors.top: undefined; anchors.bottom: overlayBar.top }
AnchorChanges { target: overlayBar; anchors.top: undefined; anchors.bottom: parent.bottom }
StateChangeScript { script: navigationBarHidingTimer.stop() }
PropertyChanges {
target: barsBackground
height: tabBar.height + tabBar.anchors.topMargin + tabBar.anchors.bottomMargin
+ navigationBar.height + navigationBar.anchors.topMargin + navigationBar.anchors.bottomMargin
+ overlayBar.height + overlayBar.anchors.topMargin + overlayBar.anchors.bottomMargin
}
PropertyChanges {
target: visibleTab
height: UiConstants.PortraitHeight - UiConstants.TabBarHeight
restoreEntryValues: false
}
}
]
transitions: Transition {
AnchorAnimation { duration: 100 }
PropertyAnimation { target: visibleTab; properties: "height"; duration: 100 }
PropertyAnimation { target: barsBackground; properties: "height"; duration: 100 }
}
Component {
id: snowShoeWebView
SnowshoeWebView {}
}
function openUrl(url)
{
TabsModel.currentWebView.load(url)
webViewMaximized()
}
function openUrlInNewTab(url)
{
var webView = snowShoeWebView.createObject(this, { "width" : UiConstants.PortraitWidth,
"height" : UiConstants.PortraitHeight - UiConstants.TabBarHeight,
"z" : -1});
webView.load(url);
TabsModel.append(webView);
}
onVisibleTabChanged: {
if (lastVisibleTab)
lastVisibleTab.visible = false;
lastVisibleTab = visibleTab;
if (visibleTab) {
visibleTab.visible = true;
webViewMaximized();
tabBar.visible = true;
} else {
webViewMinimized();
tabBar.visible = false;
}
}
}
|