1 /****************************************************************************
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
6 ** This file is part of the QtBrowser project.
8 ** $QT_BEGIN_LICENSE:GPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 2 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.GPLv2 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU General Public License version 2 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 3.0 as published by the Free Software
28 ** Foundation and appearing in the file LICENSE.GPL included in the
29 ** packaging of this file. Please review the following information to
30 ** ensure the GNU General Public License version 3.0 requirements will be
31 ** met: http://www.gnu.org/copyleft/gpl.html.
36 ****************************************************************************/
39 import QtWebEngine 1.1
40 import QtWebEngine.experimental 1.0
42 import QtQuick.Controls 1.0
43 import QtQuick.Controls.Styles 1.0
44 import QtQuick.Layouts 1.0
45 import QtQuick.Window 2.1
46 import QtQuick.Controls.Private 1.0
47 import Qt.labs.settings 1.0
48 import QtQuick.Dialogs 1.2
55 property Item currentWebView: {
56 return tabView.get(tabView.currentIndex) ? tabView.get(tabView.currentIndex).item.webView : null
59 property int toolBarSize: 80
60 property string uiColor: "#46a2da"
61 property string uiSeparatorColor: "#7ebee5"
62 property string toolBarSeparatorColor: "#a3d1ed"
63 property string buttonPressedColor: "#3f91c4"
64 property string uiHighlightColor: "#fddd5c"
65 property string inactivePagerColor: "#bcbdbe"
66 property string textFieldStrokeColor: "#3882ae"
67 property string placeholderColor: "#a0a1a2"
68 property string iconOverlayColor: "#0e202c"
69 property string iconStrokeColor: "#d6d6d6"
70 property string defaultFontFamily: "Open Sans"
72 property int gridViewPageItemCount: 8
73 property int gridViewMaxBookmarks: 3 * gridViewPageItemCount
74 property int tabViewMaxTabs: 10
75 property int animationDuration: 200
76 property int velocityThreshold: 400
77 property int velocityY: 0
78 property real touchY: 0
79 property real touchReference: 0
80 property bool touchGesture: false
88 property alias autoLoadImages: loadImages.checked;
89 property alias javaScriptEnabled: javaScriptEnabled.checked;
90 property alias errorPageEnabled: errorPageEnabled.checked;
91 property alias pluginsEnabled: pluginsEnabled.checked;
97 downloadView.visible = !downloadView.visible
105 navigation.addressBar.forceActiveFocus();
106 navigation.addressBar.selectAll();
113 currentWebView.reload()
114 navigation.addressBar.forceActiveFocus()
121 tabView.get(tabView.currentIndex).item.webView.takeSnapshot()
122 var tab = tabView.createEmptyTab()
127 navigation.addressBar.forceActiveFocus();
128 navigation.addressBar.selectAll();
129 tabView.makeCurrent(tabView.count - 1)
130 navigation.addressBar.forceActiveFocus()
135 onTriggered: tabView.remove(tabView.currentIndex)
141 source: "qrc:///newtab"
142 indicator: tabView.count
150 visible: opacity != 0.0
151 opacity: tabView.viewState == "list" ? 1.0 : 0.0
152 onDoneClicked: tabView.viewState = "page"
153 onOptionClicked: newTabAction.trigger()
168 interactive: !sslDialog.visible && homeScreen.state == "disabled"
170 height: parent.height
173 top: navigation.bottom
178 Component.onCompleted: {
179 var tab = createEmptyTab()
184 navigation.webView = tab.webView
186 onCurrentIndexChanged: {
187 if (!tabView.get(tabView.currentIndex))
189 navigation.webView = tabView.get(tabView.currentIndex).item.webView
194 id: acceptedCertificates
196 property var acceptedUrls : []
198 function shouldAutoAccept(certificateError){
199 var domain = engine.domainFromString(certificateError.url)
200 return acceptedUrls.indexOf(domain) >= 0
207 property var certErrors: []
208 property var currentError: null
209 visible: certErrors.length > 0
210 icon: StandardIcon.Warning
211 standardButtons: StandardButton.No | StandardButton.Yes
212 title: "Server's certificate not trusted"
213 text: "Do you wish to continue?"
214 detailedText: "If you wish so, you may continue with an unverified certificate. " +
215 "Accepting an unverified certificate means " +
216 "you may not be connected with the host you tried to connect to.\n" +
217 "Do you wish to override the security check and continue?"
219 var cert = certErrors.shift()
220 var domain = engine.domainFromString(cert.url)
221 acceptedCertificates.acceptedUrls.push(domain)
222 cert.ignoreCertificateError()
229 certErrors.shift().rejectCertificate()
232 function enqueue(error){
234 certErrors.push(error)
237 function presentError(){
238 informativeText = "SSL error from URL\n\n" + currentError.url + "\n\n" + currentError.description + "\n"
244 height: parent.height - toolBarSize
246 top: navigation.bottom
250 height: parent.height - toolBarSize
252 top: navigation.bottom