Changeset View
Changeset View
Standalone View
Standalone View
applets/webbrowser/package/contents/ui/main.qml
- This file was moved from applets/webbrowser/contents/ui/main.qml.
1 | /*************************************************************************** | 1 | /*************************************************************************** | ||
---|---|---|---|---|---|
2 | * Copyright 2014, 2016 by Mikhail Ivchenko <ematirov@gmail.com> * | 2 | * Copyright 2014, 2016 by Mikhail Ivchenko <ematirov@gmail.com> * | ||
3 | * Copyright 2018 by Kai Uwe Broulik <kde@privat.broulik.de> * | ||||
3 | * * | 4 | * * | ||
4 | * This program is free software; you can redistribute it and/or modify * | 5 | * This program is free software; you can redistribute it and/or modify * | ||
5 | * it under the terms of the GNU General Public License as published by * | 6 | * it under the terms of the GNU General Public License as published by * | ||
6 | * the Free Software Foundation; either version 2 of the License, or * | 7 | * the Free Software Foundation; either version 2 of the License, or * | ||
7 | * (at your option) any later version. * | 8 | * (at your option) any later version. * | ||
8 | * * | 9 | * * | ||
9 | * This program is distributed in the hope that it will be useful, * | 10 | * This program is distributed in the hope that it will be useful, * | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
12 | * GNU General Public License for more details. * | 13 | * GNU General Public License for more details. * | ||
13 | * * | 14 | * * | ||
14 | * You should have received a copy of the GNU General Public License * | 15 | * You should have received a copy of the GNU General Public License * | ||
15 | * along with this program; if not, write to the * | 16 | * along with this program; if not, write to the * | ||
16 | * Free Software Foundation, Inc., * | 17 | * Free Software Foundation, Inc., * | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | ||
18 | ***************************************************************************/ | 19 | ***************************************************************************/ | ||
19 | 20 | | |||
20 | import QtQuick 2.0 | 21 | import QtQuick 2.0 | ||
21 | import QtWebKit 3.0 | 22 | import QtWebEngine 1.1 | ||
22 | import QtQuick.Layouts 1.1 | 23 | import QtQuick.Layouts 1.1 | ||
23 | import org.kde.plasma.components 2.0 as PlasmaComponents | 24 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
24 | import org.kde.plasma.extras 2.0 as PlasmaExtras | 25 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||
25 | 26 | | |||
26 | ColumnLayout { | 27 | ColumnLayout { | ||
27 | RowLayout{ | 28 | RowLayout{ | ||
28 | Layout.fillWidth: true | 29 | Layout.fillWidth: true | ||
29 | PlasmaComponents.Button{ | 30 | PlasmaComponents.Button{ | ||
Show All 10 Lines | 40 | PlasmaComponents.TextField{ | |||
40 | Layout.fillWidth: true | 41 | Layout.fillWidth: true | ||
41 | onAccepted: { | 42 | onAccepted: { | ||
42 | var url = text; | 43 | var url = text; | ||
43 | if (url.indexOf(":/") < 0) { | 44 | if (url.indexOf(":/") < 0) { | ||
44 | url = "http://" + url; | 45 | url = "http://" + url; | ||
45 | } | 46 | } | ||
46 | webview.url = url; | 47 | webview.url = url; | ||
47 | } | 48 | } | ||
49 | onActiveFocusChanged: { | ||||
50 | if (activeFocus) { | ||||
51 | selectAll(); | ||||
52 | } | ||||
53 | } | ||||
54 | | ||||
48 | text: webview.url | 55 | text: webview.url | ||
49 | } | 56 | } | ||
50 | PlasmaComponents.Button{ | 57 | PlasmaComponents.Button{ | ||
51 | iconSource: "view-refresh" | 58 | iconSource: webview.loading ? "process-stop" : "view-refresh" | ||
52 | onClicked: webview.reload() | 59 | onClicked: webview.loading ? webview.stop() : webview.reload() | ||
53 | } | 60 | } | ||
54 | } | 61 | } | ||
55 | PlasmaExtras.ScrollArea { | 62 | | ||
63 | Item { | ||||
56 | Layout.fillWidth: true | 64 | Layout.fillWidth: true | ||
57 | Layout.fillHeight: true | 65 | Layout.fillHeight: true | ||
58 | WebView { | 66 | | ||
67 | // TODO use contentsSize but that crashes, now mostly for some sane initial size | ||||
broulik: QTBUG-65942 | |||||
68 | Layout.preferredWidth: units.gridUnit * 25 | ||||
69 | Layout.preferredHeight: units.gridUnit * 12 | ||||
70 | | ||||
71 | // Binding it to e.g. width will be super slow on resizing | ||||
72 | Timer { | ||||
73 | id: updateZoomTimer | ||||
74 | interval: 100 | ||||
75 | onTriggered: { | ||||
76 | // Try to fit contents for a smaller screen | ||||
77 | webview.zoomFactor = Math.min(1, webview.width / 1000); | ||||
78 | } | ||||
79 | | ||||
80 | } | ||||
81 | | ||||
82 | WebEngineView { | ||||
59 | id: webview | 83 | id: webview | ||
60 | anchors.fill: parent | 84 | anchors.fill: parent | ||
61 | onUrlChanged: plasmoid.configuration.url = url; | 85 | onUrlChanged: plasmoid.configuration.url = url; | ||
62 | Component.onCompleted: url = plasmoid.configuration.url; | 86 | Component.onCompleted: url = plasmoid.configuration.url; | ||
87 | | ||||
88 | onLinkHovered: { | ||||
89 | if (hoveredUrl.toString() !== "") { | ||||
90 | mouseArea.cursorShape = Qt.PointingHandCursor; | ||||
91 | } else { | ||||
92 | mouseArea.cursorShape = Qt.ArrowCursor; | ||||
93 | } | ||||
94 | } | ||||
95 | | ||||
96 | onWidthChanged: updateZoomTimer.start() | ||||
97 | onLoadingChanged: { | ||||
98 | if (loadRequest.status === WebEngineLoadRequest.LoadSucceededStatus) { | ||||
99 | updateZoomTimer.start(); | ||||
100 | } | ||||
63 | } | 101 | } | ||
64 | } | 102 | } | ||
65 | //There will be RowLayout with buttons for bookmarks and zooming. | | |||
66 | 103 | | |||
104 | MouseArea { | ||||
105 | id: mouseArea | ||||
106 | anchors.fill: parent | ||||
107 | acceptedButtons: Qt.BackButton | Qt.ForwardButton | ||||
108 | onPressed: { | ||||
109 | if (mouse.button === Qt.BackButton) { | ||||
110 | webview.goBack(); | ||||
111 | } else if (mouse.button === Qt.ForwardButton) { | ||||
112 | webview.goForward(); | ||||
113 | } | ||||
114 | } | ||||
115 | } | ||||
116 | } | ||||
67 | } | 117 | } |
QTBUG-65942