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
|
import QtQuick 2.4
import QtQuick.Window 2.2
import Ubuntu.Web 0.2
import Ubuntu.Components 1.2
import com.canonical.Oxide 1.9 as Oxide
import "UCSComponents"
import Ubuntu.Content 1.1
import "."
import "../config.js" as Conf
Window {
id: window
visibility: Window.AutomaticVisibility
property string myUrl: Conf.webappUrl
property string myPattern: Conf.webappUrlPattern
property string myUA: "Mozilla/5.0 (Linux; Android 4.4; Nexus 5) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chromium/35.0.1870.2 Mobile Safari/537.36"
width: units.gu(150)
height: units.gu(100)
MainView {
objectName: "mainView"
applicationName: "google-plus.ogra"
anchorToKeyboard: true
automaticOrientation: true
anchors {
top: parent.top
bottom: parent.bottom
left: parent.left
right: parent.right
}
Page {
id: page
anchors {
fill: parent
bottom: parent.bottom
}
width: parent.width
height: parent.height
WebContext {
id: webcontext
userAgent: myUA
userScripts: [
Oxide.UserScript {
context: "oxide://"
url: Qt.resolvedUrl("../userscripts/ubuntutheme.js")
matchAllFrames: true
}
]
}
WebView {
id: webview
anchors {
fill: parent
bottom: parent.bottom
}
width: parent.width
height: parent.height
context: webcontext
url: myUrl
preferences.localStorageEnabled: true
preferences.allowFileAccessFromFileUrls: true
preferences.allowUniversalAccessFromFileUrls: true
preferences.appCacheEnabled: true
preferences.javascriptCanAccessClipboard: true
filePicker: filePickerLoader.item
onFullscreenRequested: webview.fullscreen = fullscreen
function navigationRequestedDelegate(request) {
var url = request.url.toString();
var pattern = myPattern.split(',');
var isvalid = false;
for (var i=0; i<pattern.length; i++) {
var tmpsearch = pattern[i].replace(/\*/g,'(.*)')
var search = tmpsearch.replace(/^https\?:\/\//g, '(http|https):\/\/');
if (url.match(search)) {
isvalid = true;
break
}
}
if(isvalid == false) {
console.warn("Opening remote: " + url);
Qt.openUrlExternally(url)
request.action = Oxide.NavigationRequest.ActionReject
}
}
Component.onCompleted: {
preferences.localStorageEnabled = true
if (Qt.application.arguments[1].toString().indexOf("https://plus.google.com") > -1) {
console.warn("got argument: " + Qt.application.arguments[1])
url = Qt.application.arguments[1]
}
console.warn("url is: " + url)
}
onGeolocationPermissionRequested: { request.accept() }
Loader {
id: filePickerLoader
source: "ContentPickerDialog.qml"
asynchronous: true
}
}
ThinProgressBar {
webview: webview
anchors {
left: parent.left
right: parent.right
top: parent.top
}
}
RadialBottomEdge {
id: nav
visible: true
actions: [
RadialAction {
id: reload
iconName: "reload"
onTriggered: {
webview.reload()
}
text: qsTr("Reload")
},
RadialAction {
id: forward
enabled: webview.canGoForward
iconName: "go-next"
onTriggered: {
webview.goForward()
}
text: qsTr("Forward")
},
RadialAction {
id: back
enabled: webview.canGoBack
iconName: "go-previous"
onTriggered: {
webview.goBack()
}
text: qsTr("Back")
}
]
}
}
Connections {
target: Qt.inputMethod
onVisibleChanged: {
nav.visible = !nav.visible
webview.focus = !nav.visible
}
}
Connections {
target: webview
onFullscreenChanged: {
nav.visible = !webview.fullscreen
if (webview.fullscreen == true) {
window.visibility = 5
} else {
window.visibility = 4
}
}
}
Connections {
target: UriHandler
onOpened: {
webview.url = uris[0]
console.warn("uri-handler request")
}
}
Connections {
target: ContentHub
onShareRequested: {
webview.url = "https://plus.google.com/share?url=" + String(transfer.items[0].url)
console.warn("content-hub request for: " + String(transfer.items[0].url))
}
}
}
}
|