-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.qml
More file actions
152 lines (135 loc) · 3.83 KB
/
main.qml
File metadata and controls
152 lines (135 loc) · 3.83 KB
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
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Window 2.0
import QtGraphicalEffects 1.0
import QtWebKit 3.0
/*import QtQuick.VirtualKeyboard 2.1
import QtQuick.VirtualKeyboard.Styles 2.2
import QtQuick.VirtualKeyboard.Settings 2.2
*/
ApplicationWindow {
id: window
visible: true
visibility: "FullScreen"
width: Screen.width
height: Screen.height
title: qsTr("net")
property bool altPressed: false
TextField {
id: urlbar
text: webview.url
placeholderText: "Please enter an URL"
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.topMargin: -urlbar.height - 16
anchors.leftMargin: 16
anchors.rightMargin: 16
height: 32
/*leftPadding: 8
rightPadding: 8
topPadding: 8
bottomPadding: 8*/
horizontalAlignment: TextField.AlignHCenter
//color: "white"
font.bold: true;
/*background: Item {
Rectangle {
id: urlbarBackground
anchors.fill: parent
color: "black"
radius: 6
}
DropShadow {
anchors.fill: urlbarBackground
horizontalOffset: 0
verticalOffset: 0
radius: 12
samples: 17
color: "#D0000000"
source: urlbarBackground
z: 2
}
}*/
z: 1
PropertyAnimation {
id: urlbarSlideIn
target: urlbar
property: "anchors.topMargin"
to: 16
duration: 60
}
PropertyAnimation {
id: urlbarSlideOut
target: urlbar
property: "anchors.topMargin"
to: -urlbar.height - 16
duration: 60
}
onFocusChanged: {
if (!focus) {
urlbarSlideOut.start();
inputPanel.visible = false;
} else {
urlbarSlideIn.start();
inputPanel.visible = true;
}
}
onAccepted: {
webview.url = text;
webview.focus = true;
}
Keys.onPressed: {
if (event.key === Qt.Key_Escape) {
webview.focus = true;
}
}
}
WebView {
id: webview
url: Qt.application.arguments[1]
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
focus: true
Keys.onPressed: {
if (event.key === Qt.Key_Alt) {
altPressed = true;
}
if (altPressed && event.key === Qt.Key_Backspace) {
urlbar.focus = true;
}
}
Keys.onReleased: {
if (altPressed && event.key === Qt.Key_Alt) {
altPressed = false;
}
}
/*MouseArea {
anchors.fill: parent
propagateComposedEvents: true
onClicked: {
console.log("clicked");
mouse.accepted = false
}
}*/
onNavigationRequested: {
request.action = WebView.AcceptRequest;
// detect URL scheme prefix, most likely an external link
/*var schemaRE = /^\w+:/;
if (schemaRE.test(request.url)) {
request.action = WebView.AcceptRequest;
} else {
request.action = WebView.IgnoreRequest;
// delegate request.url here
}*/
}
}
/*InputPanel {
id: inputPanel
y: Qt.inputMethod.visible ? parent.height - inputPanel.height : parent.height
anchors.left: parent.left
anchors.right: parent.right
}*/
}