Skip to content

Commit ebc506d

Browse files
committed
Merge pull request bnb-chain#302 from alexvandesande/UI
Catalog Page Behaviour
2 parents d311b1b + 6221b28 commit ebc506d

3 files changed

Lines changed: 96 additions & 119 deletions

File tree

‎cmd/mist/assets/qml/main.qml‎

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ApplicationWindow {
3939
// Takes care of loading all default plugins
4040
Component.onCompleted: {
4141

42-
addPlugin("./views/catalog.qml", {noAdd: true, close: false, section: "begin"});
42+
var catalog = addPlugin("./views/catalog.qml", {noAdd: true, close: false, section: "begin"});
4343
var wallet = addPlugin("./views/wallet.qml", {noAdd: true, close: false, section: "ethereum", active: true});
4444

4545
addPlugin("./views/miner.qml", {noAdd: true, close: false, section: "ethereum", active: true});
@@ -49,9 +49,9 @@ ApplicationWindow {
4949
addPlugin("./views/pending_tx.qml", {noAdd: true, close: false, section: "legacy"});
5050
addPlugin("./views/info.qml", {noAdd: true, close: false, section: "legacy"});
5151

52-
mainSplit.setView(wallet.view, wallet.menuItem);
52+
mainSplit.setView(catalog.view, catalog.menuItem);
5353

54-
newBrowserTab("http://ethereum-dapp-whisper-client.meteor.com/chat/amsteam");
54+
//newBrowserTab("http://ethereum-dapp-catalog.meteor.com");
5555

5656
// Command setup
5757
gui.sendCommand(0)
@@ -114,10 +114,33 @@ ApplicationWindow {
114114
}
115115

116116
function newBrowserTab(url) {
117-
var window = addPlugin("./views/browser.qml", {noAdd: true, close: true, section: "apps", active: true});
118-
window.view.url = url;
119-
window.menuItem.title = "Mist";
120-
activeView(window.view, window.menuItem);
117+
118+
var urlMatches = url.toString().match(/^[a-z]*\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);
119+
var requestedDomain = urlMatches && urlMatches[1];
120+
121+
var domainAlreadyOpen = false;
122+
123+
console.log("requested: " + requestedDomain )
124+
125+
for(var i = 0; i < mainSplit.views.length; i++) {
126+
if (mainSplit.views[i].view.url) {
127+
var matches = mainSplit.views[i].view.url.toString().match(/^[a-z]*\:\/\/(?:www\.)?([^\/?#]+)(?:[\/?#]|$)/i);
128+
var existingDomain = matches && matches[1];
129+
console.log("exists: " + existingDomain);
130+
if (requestedDomain == existingDomain) {
131+
domainAlreadyOpen = true;
132+
mainSplit.views[i].view.url = url;
133+
activeView(mainSplit.views[i].view, mainSplit.views[i].menuItem);
134+
}
135+
}
136+
}
137+
138+
if (!domainAlreadyOpen) {
139+
var window = addPlugin("./views/browser.qml", {noAdd: true, close: true, section: "apps", active: true});
140+
window.view.url = url;
141+
window.menuItem.title = "Mist";
142+
activeView(window.view, window.menuItem);
143+
}
121144
}
122145

123146

@@ -332,8 +355,9 @@ ApplicationWindow {
332355

333356
id: mainSplit
334357
anchors.fill: parent
335-
resizing: false
358+
//resizing: false // this is NOT where we remove that damning resizing handle..
336359
handleDelegate: Item {
360+
//This handle is a way to remove the line between the split views
337361
Rectangle {
338362
anchors.fill: parent
339363
}
@@ -497,7 +521,7 @@ ApplicationWindow {
497521
anchors.fill: parent
498522
border.width: 0
499523
radius: 5
500-
color: "#FFFFFFFF"
524+
color: "#FAFAFA"
501525
}
502526
Rectangle {
503527
anchors {
@@ -506,7 +530,7 @@ ApplicationWindow {
506530
right: r.right
507531
}
508532
width: 10
509-
color: "#FFFFFFFF"
533+
color: "#FAFAFA"
510534
border.width:0
511535

512536
Rectangle {
@@ -517,7 +541,7 @@ ApplicationWindow {
517541
top: parent.top
518542
}
519543
height: 1
520-
color: "#FFFFFF"
544+
color: "#FAFAFA"
521545
}
522546

523547
Rectangle {
@@ -528,7 +552,7 @@ ApplicationWindow {
528552
bottom: parent.bottom
529553
}
530554
height: 1
531-
color: "#FFFFFF"
555+
color: "#FAFAFA"
532556
}
533557
}
534558
}
@@ -800,7 +824,7 @@ ApplicationWindow {
800824
anchors.top: parent.top
801825
color: "#00000000"
802826

803-
Rectangle {
827+
/*Rectangle {
804828
id: urlPane
805829
height: 40
806830
color: "#00000000"
@@ -847,15 +871,15 @@ ApplicationWindow {
847871
z: -1
848872
height: 1
849873
color: "#CCCCCC"
850-
}
874+
}*/
851875

852876
Rectangle {
853877
id: mainView
854878
color: "#00000000"
855879
anchors.right: parent.right
856880
anchors.left: parent.left
857881
anchors.bottom: parent.bottom
858-
anchors.top: divider.bottom
882+
anchors.top: parent.top
859883

860884
function createView(component) {
861885
var view = component.createObject(mainView)

‎cmd/mist/assets/qml/views/browser.qml‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,14 +345,21 @@ Rectangle {
345345
if (topBarStyle=="transparent") {
346346

347347
// Adjust for a transparent sidebar Dapp
348-
navBarBackground.visible = false;
349-
back.visible = false;
350-
appInfoPane.anchors.leftMargin = -16;
351-
appInfoPaneShadow.anchors.leftMargin = -16;
352-
webview.anchors.topMargin = -74;
348+
navBarBackground.visible = false;
349+
back.visible = false;
350+
appInfoPane.anchors.leftMargin = -16;
351+
appInfoPaneShadow.anchors.leftMargin = -16;
352+
webview.anchors.topMargin = -74;
353353
webview.runJavaScript("document.querySelector('body').classList.add('ethereum-dapp-url-bar-style-transparent')")
354354

355-
};
355+
} else {
356+
navBarBackground.visible = true;
357+
back.visible = true;
358+
appInfoPane.anchors.leftMargin = 0;
359+
appInfoPaneShadow.anchors.leftMargin = 0;
360+
webview.anchors.topMargin = 0;
361+
362+
};
356363
});
357364

358365

‎cmd/mist/assets/qml/views/catalog.qml‎

Lines changed: 44 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Rectangle {
1212
anchors.fill: parent
1313
color: "#00000000"
1414

15-
property var title: ""
15+
property var title: "Catalog"
1616
property var iconSource: ""
1717
property var menuItem
1818
property var hideUrl: true
@@ -75,111 +75,57 @@ Rectangle {
7575
anchors.fill: parent
7676
state: "inspectorShown"
7777

78-
RowLayout {
79-
id: navBar
80-
height: 184
81-
z: 20
82-
83-
anchors {
84-
left: parent.left
85-
right: parent.right
86-
}
87-
88-
Rectangle {
89-
id: appInfoPane
90-
height: 28
91-
color: "#efefef"
92-
radius: 6
93-
z:25
94-
95-
MouseArea {
96-
anchors.fill: parent
97-
z: 10
98-
hoverEnabled: true
99-
onEntered: {
100-
uriNav.visible = true
101-
appTitle.visible = false
102-
appDomain.visible = false
103-
}
104-
}
105-
106-
anchors {
107-
left: parent.left
108-
right: parent.right
109-
leftMargin: 10
110-
rightMargin: 10
111-
top: parent.verticalCenter
112-
topMargin: 23
113-
}
114-
115-
TextField {
116-
id: uriNav
117-
anchors {
118-
left: parent.left
119-
right: parent.right
120-
leftMargin: 16
121-
top: parent.verticalCenter
122-
topMargin: -10
123-
}
124-
125-
horizontalAlignment: Text.AlignHCenter
126-
127-
style: TextFieldStyle {
128-
textColor: "#928484"
129-
background: Rectangle {
130-
border.width: 0
131-
color: "transparent"
132-
}
133-
}
134-
text: "Type the address of a new Dapp";
135-
y: parent.height / 2 - this.height / 2
136-
z: 30
137-
activeFocusOnPress: true
138-
Keys.onReturnPressed: {
139-
newBrowserTab(this.text);
140-
this.text = "Type the address of a new Dapp";
141-
}
142-
143-
}
144-
}
145-
146-
Rectangle {
147-
id: appInfoPaneShadow
148-
width: 10
149-
height: 30
150-
color: "#BDB6B6"
151-
radius: 6
152-
z: 15
153-
154-
anchors {
155-
left: parent.left
156-
right: parent.right
157-
leftMargin:10
158-
rightMargin:10
159-
top: parent.verticalCenter
160-
topMargin: 23
161-
}
162-
163-
164-
}
165-
166-
}
167-
168-
16978
WebEngineView {
17079
objectName: "webView"
17180
id: webview
17281
anchors.fill: parent
17382

174-
onLoadingChanged: {
175-
if (loadRequest.status == WebEngineView.LoadSucceededStatus) {
176-
webview.runJavaScript(eth.readFile("bignumber.min.js"));
177-
webview.runJavaScript(eth.readFile("ethereum.js/dist/ethereum.js"));
178-
}
179-
}
83+
property var protocol: "http://"
84+
//property var domain: "localhost:3000"
85+
property var domain: "ethereum-dapp-catalog.meteor.com"
86+
url: protocol + domain
87+
88+
//navigationRequest: WebEngineView.IgnoreRequest
89+
// onLoadingChanged: {
90+
// if (loadRequest.status == WebEngineView.LoadSucceededStatus) {
91+
// webview.runJavaScript(eth.readFile("bignumber.min.js"));
92+
// webview.runJavaScript(eth.readFile("ethereum.js/dist/ethereum.js"));
93+
// }
94+
// }
95+
96+
//onNavigationRequested: {
97+
// detect URL scheme prefix, most likely an external link
98+
//var schemaRE = /^\w+:/;
99+
//if (schemaRE.test(request.url)) {
100+
// request.action = WebView.AcceptRequest;
101+
//} else {
102+
//request.action = WebView.IgnoreRequest;
103+
// delegate request.url here
104+
//}
105+
//}
106+
180107
onJavaScriptConsoleMessage: {
181108
console.log(sourceID + ":" + lineNumber + ":" + JSON.stringify(message));
182109
}
110+
111+
onNavigationRequested: {
112+
var cleanTitle = request.url.toString()
113+
var matches = cleanTitle.match(/^[a-z]*\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);
114+
var requestedDomain = matches && matches[1];
115+
116+
console.debug ("NavigationRequested: " + request.url + " navigationType=" + request.navigationType)
117+
118+
if(request.navigationType==0){
119+
120+
if (requestedDomain === this.domain){
121+
request.action = WebEngineView.AcceptRequest;
122+
} else {
123+
request.action = WebEngineView.IgnoreRequest;
124+
newBrowserTab(request.url);
125+
}
126+
127+
}
128+
}
183129
}
184130

185131

0 commit comments

Comments
 (0)