/
WebPage.qml
131 lines (107 loc) · 3.63 KB
/
WebPage.qml
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
import QtQuick 2.6
import Sailfish.Silica 1.0
import Sailfish.WebView 1.0
import Sailfish.WebEngine 1.0
Page {
id: root
objectName: "WebPage"
property string url
allowedOrientations: Orientation.All
Loader {
id: loader
anchors.fill: parent
sourceComponent: parent.status === PageStatus.Active ? webComponent : undefined
}
Component {
id: webComponent
WebView {
anchors.fill: parent
id: webview
httpUserAgent: "Mozilla/5.0 (Mobile; rv:78.0) Gecko/78.0 Firefox/78.0"
/* This will probably be required from 4.4 on. */
Component.onCompleted: {
WebEngineSettings.setPreference("security.disable_cors_checks", true, WebEngineSettings.BoolPref)
WebEngineSettings.setPreference("security.fileuri.strict_origin_policy", false, WebEngineSettings.BoolPref)
if (configFontScaleWebEnabled.booleanValue)
{
experimental.preferences.minimumFontSize =
Theme.fontSizeExtraSmall * (configFontScale.value / 100.0);
}
}
onRecvAsyncMessage: {
console.debug(message)
switch (message) {
case "embed:contentOrientationChanged":
break
case "webview:action":
if ( data.key != val ) {
//if (debug) console.debug(data.src)
}
break
}
}
//property int _backCount: 0
//property int _previousContentY;
url: root.url
onLoadingChanged: {}
}
}
/*
Item {
id: toolbar
width: parent.width
height: Theme.itemSizeLarge
anchors {
bottom: parent.bottom
Behavior on bottomMargin {
NumberAnimation { duration: 300; easing.type: Easing.InOutQuad }
}
}
Rectangle {
anchors.fill: parent
color: Qt.darker(Theme.highlightColor)
}
IconButton {
id: backBtn
enabled: loader.item ? loader.item.canGoBack : false
anchors.left: parent.left
anchors.leftMargin: Theme.paddingSmall
anchors.verticalCenter: parent.verticalCenter
icon.source: "image://theme/icon-m-back"
onClicked: {
loader.item.goBack();
}
}
Label {
id: titleLabel
anchors.left: backBtn.right
anchors.leftMargin: Theme.paddingMedium
anchors.right: stopReloadBtn.left
anchors.rightMargin: Theme.paddingLarge
anchors.verticalCenter: parent.verticalCenter
elide: Text.ElideRight
text: loader.item ? loader.item.title : ""
}
IconButton {
id: stopReloadBtn
enabled: loader.item
anchors.right: parent.right
anchors.rightMargin: Theme.paddingSmall
anchors.verticalCenter: parent.verticalCenter
icon.source: !loader.item ? ""
: loader.item.loading ? "image://theme/icon-m-reset"
: "image://theme/icon-m-refresh"
onClicked: {
if (loader.item.loading)
{
loader.item.stop();
}
else
{
loader.item.reload();
}
}
}
}
*/
}