Recreated the changes on a new branch

parent ddccea75
...@@ -9,882 +9,1071 @@ import Ethereum 1.0 ...@@ -9,882 +9,1071 @@ import Ethereum 1.0
import "../ext/filter.js" as Eth import "../ext/filter.js" as Eth
import "../ext/http.js" as Http import "../ext/http.js" as Http
ApplicationWindow { ApplicationWindow {
id: root id: root
property var ethx : Eth.ethx //flags: Qt.FramelessWindowHint
// Use this to make the window frameless. But then you'll need to do move and resize by hand
width: 1200
height: 820 property var ethx : Eth.ethx
minimumWidth: 300
width: 1200
title: "Mist" height: 820
minimumHeight: 600
TextField { minimumWidth: 800
id: copyElementHax
visible: false title: "Mist"
}
TextField {
function copyToClipboard(text) { id: copyElementHax
copyElementHax.text = text visible: false
copyElementHax.selectAll() }
copyElementHax.copy()
} function copyToClipboard(text) {
copyElementHax.text = text
// Takes care of loading all default plugins copyElementHax.selectAll()
Component.onCompleted: { copyElementHax.copy()
var wallet = addPlugin("./views/wallet.qml", {noAdd: true, close: false, section: "ethereum", active: true}); }
addPlugin("./views/miner.qml", {noAdd: true, close: false, section: "ethereum", active: true});
// Takes care of loading all default plugins
addPlugin("./views/transaction.qml", {noAdd: true, close: false, section: "legacy"}); Component.onCompleted: {
addPlugin("./views/whisper.qml", {noAdd: true, close: false, section: "legacy"});
addPlugin("./views/chain.qml", {noAdd: true, close: false, section: "legacy"}); addPlugin("./views/catalog.qml", {noAdd: true, close: false, section: "begin"});
addPlugin("./views/pending_tx.qml", {noAdd: true, close: false, section: "legacy"}); var wallet = addPlugin("./views/wallet.qml", {noAdd: true, close: false, section: "ethereum", active: true});
addPlugin("./views/info.qml", {noAdd: true, close: false, section: "legacy"});
addPlugin("./views/miner.qml", {noAdd: true, close: false, section: "ethereum", active: true});
mainSplit.setView(wallet.view, wallet.menuItem); addPlugin("./views/transaction.qml", {noAdd: true, close: false, section: "legacy"});
addPlugin("./views/whisper.qml", {noAdd: true, close: false, section: "legacy"});
newBrowserTab(eth.assetPath("html/home.html")); addPlugin("./views/chain.qml", {noAdd: true, close: false, section: "legacy"});
addPlugin("./views/pending_tx.qml", {noAdd: true, close: false, section: "legacy"});
// Command setup addPlugin("./views/info.qml", {noAdd: true, close: false, section: "legacy"});
gui.sendCommand(0)
} mainSplit.setView(wallet.view, wallet.menuItem);
function activeView(view, menuItem) { newBrowserTab("http://ethereum-dapp-whisper-client.meteor.com/chat/amsteam");
mainSplit.setView(view, menuItem)
if (view.hideUrl) { // Command setup
urlPane.visible = false; gui.sendCommand(0)
mainView.anchors.top = rootView.top }
} else {
urlPane.visible = true; function activeView(view, menuItem) {
mainView.anchors.top = divider.bottom mainSplit.setView(view, menuItem)
} if (view.hideUrl) {
} urlPane.visible = false;
mainView.anchors.top = rootView.top
function addViews(view, path, options) { } else {
var views = mainSplit.addComponent(view, options) urlPane.visible = true;
views.menuItem.path = path mainView.anchors.top = divider.bottom
}
mainSplit.views.push(views); }
if(!options.noAdd) { function addViews(view, path, options) {
gui.addPlugin(path) var views = mainSplit.addComponent(view, options)
} views.menuItem.path = path
return views mainSplit.views.push(views);
}
if(!options.noAdd) {
function addPlugin(path, options) { gui.addPlugin(path)
try { }
if(typeof(path) === "string" && /^https?/.test(path)) {
console.log('load http') return views
Http.request(path, function(o) { }
if(o.status === 200) {
var view = Qt.createQmlObject(o.responseText, mainView, path) function addPlugin(path, options) {
addViews(view, path, options) try {
} if(typeof(path) === "string" && /^https?/.test(path)) {
}) console.log('load http')
Http.request(path, function(o) {
return if(o.status === 200) {
} var view = Qt.createQmlObject(o.responseText, mainView, path)
addViews(view, path, options)
var component = Qt.createComponent(path); }
if(component.status != Component.Ready) { })
if(component.status == Component.Error) {
ethx.note("error: ", component.errorString()); return
} }
return var component = Qt.createComponent(path);
} if(component.status != Component.Ready) {
if(component.status == Component.Error) {
var view = mainView.createView(component, options) ethx.note("error: ", component.errorString());
var views = addViews(view, path, options) }
return views return
} catch(e) { }
console.log(e)
} var view = mainView.createView(component, options)
} var views = addViews(view, path, options)
function newBrowserTab(url) { return views
var window = addPlugin("./views/browser.qml", {noAdd: true, close: true, section: "apps", active: true}); } catch(e) {
window.view.url = url; console.log(e)
window.menuItem.title = "Mist"; }
activeView(window.view, window.menuItem); }
}
function newBrowserTab(url) {
menuBar: MenuBar { var window = addPlugin("./views/browser.qml", {noAdd: true, close: true, section: "apps", active: true});
Menu { window.view.url = url;
title: "File" window.menuItem.title = "Mist";
MenuItem { activeView(window.view, window.menuItem);
text: "Import App" }
shortcut: "Ctrl+o"
onTriggered: {
generalFileDialog.show(true, importApp)
} menuBar: MenuBar {
} Menu {
title: "File"
MenuItem { MenuItem {
text: "Add plugin" text: "Import App"
onTriggered: { shortcut: "Ctrl+o"
generalFileDialog.show(true, function(path) { onTriggered: {
addPlugin(path, {close: true, section: "apps"}) generalFileDialog.show(true, importApp)
}) }
} }
}
MenuItem {
MenuItem { text: "Add plugin"
text: "New tab" onTriggered: {
shortcut: "Ctrl+t" generalFileDialog.show(true, function(path) {
onTriggered: { addPlugin(path, {close: true, section: "apps"})
newBrowserTab("about:blank"); })
} }
} }
MenuSeparator {} MenuItem {
text: "New tab"
MenuItem { shortcut: "Ctrl+t"
text: "Import key" onTriggered: {
shortcut: "Ctrl+i" newBrowserTab("http://etherian.io");
onTriggered: { }
generalFileDialog.show(true, function(path) { }
gui.importKey(path)
}) MenuSeparator {}
}
} MenuItem {
text: "Import key"
MenuItem { shortcut: "Ctrl+i"
text: "Export keys" onTriggered: {
shortcut: "Ctrl+e" generalFileDialog.show(true, function(path) {
onTriggered: { gui.importKey(path)
generalFileDialog.show(false, function(path) { })
}) }
} }
}
MenuItem {
} text: "Export keys"
shortcut: "Ctrl+e"
Menu { onTriggered: {
title: "Developer" generalFileDialog.show(false, function(path) {
MenuItem { })
iconSource: "../icecream.png" }
text: "Debugger" }
shortcut: "Ctrl+d"
onTriggered: eth.startDebugger() }
}
Menu {
MenuItem { title: "Developer"
text: "Import Tx" MenuItem {
onTriggered: { iconSource: "../icecream.png"
txImportDialog.visible = true text: "Debugger"
} shortcut: "Ctrl+d"
} onTriggered: eth.startDebugger()
}
MenuItem {
text: "Run JS file" MenuItem {
onTriggered: { text: "Import Tx"
generalFileDialog.show(true, function(path) { onTriggered: {
eth.evalJavascriptFile(path) txImportDialog.visible = true
}) }
} }
}
MenuItem {
MenuItem { text: "Run JS file"
text: "Dump state" onTriggered: {
onTriggered: { generalFileDialog.show(true, function(path) {
generalFileDialog.show(false, function(path) { eth.evalJavascriptFile(path)
// Empty hash for latest })
gui.dumpState("", path) }
}) }
}
} MenuItem {
text: "Dump state"
MenuSeparator {} onTriggered: {
} generalFileDialog.show(false, function(path) {
// Empty hash for latest
Menu { gui.dumpState("", path)
title: "Network" })
MenuItem { }
text: "Add Peer" }
shortcut: "Ctrl+p"
onTriggered: { MenuSeparator {}
addPeerWin.visible = true }
}
} Menu {
MenuItem { title: "Network"
text: "Show Peers" MenuItem {
shortcut: "Ctrl+e" text: "Add Peer"
onTriggered: { shortcut: "Ctrl+p"
peerWindow.visible = true onTriggered: {
} addPeerWin.visible = true
} }
} }
MenuItem {
Menu { text: "Show Peers"
title: "Help" shortcut: "Ctrl+e"
MenuItem { onTriggered: {
text: "About" peerWindow.visible = true
onTriggered: { }
aboutWin.visible = true }
} }
}
} Menu {
title: "Help"
Menu { MenuItem {
title: "GLOBAL SHORTCUTS" text: "About"
visible: false onTriggered: {
MenuItem { aboutWin.visible = true
visible: false }
shortcut: "Ctrl+l" }
onTriggered: { }
url.focus = true
} Menu {
} title: "GLOBAL SHORTCUTS"
} visible: false
} MenuItem {
visible: false
statusBar: StatusBar { shortcut: "Ctrl+l"
//height: 32 onTriggered: {
id: statusBar url.focus = true
Label { }
//y: 6 }
id: walletValueLabel }
}
font.pixelSize: 10
styleColor: "#797979" statusBar: StatusBar {
} //height: 32
visible: false
Label {
//y: 6 id: statusBar
objectName: "miningLabel" Label {
visible: true //y: 6
font.pixelSize: 10 id: walletValueLabel
anchors.right: lastBlockLabel.left
anchors.rightMargin: 5 font.pixelSize: 10
} styleColor: "#797979"
}
Label {
//y: 6 Label {
id: lastBlockLabel //y: 6
objectName: "lastBlockLabel" objectName: "miningLabel"
visible: true visible: true
text: "" font.pixelSize: 10
font.pixelSize: 10 anchors.right: lastBlockLabel.left
anchors.right: peerGroup.left anchors.rightMargin: 5
anchors.rightMargin: 5 }
}
Label {
ProgressBar { id: lastBlockLabel
visible: false objectName: "lastBlockLabel"
id: downloadIndicator visible: true
value: 0 text: "---"
objectName: "downloadIndicator" font.pixelSize: 10
y: -4 anchors.right: peerGroup.left
x: statusBar.width / 2 - this.width / 2 anchors.rightMargin: 5
width: 160 }
}
ProgressBar {
Label { visible: false
visible: false id: downloadIndicator
objectName: "downloadLabel" value: 0
//y: 7 objectName: "downloadIndicator"
anchors.left: downloadIndicator.right y: -4
anchors.leftMargin: 5 x: statusBar.width / 2 - this.width / 2
font.pixelSize: 10 width: 160
text: "0 / 0" }
}
Label {
visible: false
RowLayout { objectName: "downloadLabel"
id: peerGroup //y: 7
//y: 7 anchors.left: downloadIndicator.right
anchors.right: parent.right anchors.leftMargin: 5
MouseArea { font.pixelSize: 10
onDoubleClicked: peerWindow.visible = true text: "0 / 0"
anchors.fill: parent }
}
Label { RowLayout {
id: peerLabel id: peerGroup
font.pixelSize: 10 //y: 7
text: "0 / 0" anchors.right: parent.right
} MouseArea {
} onDoubleClicked: peerWindow.visible = true
} anchors.fill: parent
}
property var blockModel: ListModel { Label {
id: blockModel id: peerLabel
} font.pixelSize: 10
text: "0 / 0"
SplitView { }
property var views: []; }
}
id: mainSplit
anchors.fill: parent
resizing: false property var blockModel: ListModel {
id: blockModel
function setView(view, menu) { }
for(var i = 0; i < views.length; i++) {
views[i].view.visible = false SplitView {
views[i].menuItem.setSelection(false) property var views: [];
}
view.visible = true id: mainSplit
menu.setSelection(true) anchors.fill: parent
} resizing: false
handleDelegate: Item {
function addComponent(view, options) { Rectangle {
view.visible = false anchors.fill: parent
view.anchors.fill = mainView }
}
var menuItem = menu.createMenuItem(view, options);
if( view.hasOwnProperty("menuItem") ) { function setView(view, menu) {
view.menuItem = menuItem; for(var i = 0; i < views.length; i++) {
} views[i].view.visible = false
views[i].menuItem.setSelection(false)
if( view.hasOwnProperty("onReady") ) { }
view.onReady.call(view) view.visible = true
} menu.setSelection(true)
}
if( options.active ) {
setView(view, menuItem) function addComponent(view, options) {
} view.visible = false
view.anchors.fill = mainView
return {view: view, menuItem: menuItem} var menuItem = menu.createMenuItem(view, options);
} if( view.hasOwnProperty("menuItem") ) {
view.menuItem = menuItem;
/********************* }
* Main menu.
********************/ if( view.hasOwnProperty("onReady") ) {
Rectangle { view.onReady.call(view)
id: menu }
Layout.minimumWidth: 210
Layout.maximumWidth: 210 if( options.active ) {
anchors.top: parent.top setView(view, menuItem)
color: "#ececec" }
Component {
id: menuItemTemplate return {view: view, menuItem: menuItem}
Rectangle { }
id: menuItem
property var view; /*********************
property var path; * Main menu.
property var closable; ********************/
Rectangle {
property alias title: label.text id: menu
property alias icon: icon.source Layout.minimumWidth: 192
property alias secondaryTitle: secondary.text Layout.maximumWidth: 192
function setSelection(on) {
sel.visible = on FontLoader {
} id: sourceSansPro
source: "fonts/SourceSansPro-Regular.ttf"
width: 206 }
height: 28 FontLoader {
color: "#00000000" source: "fonts/SourceSansPro-Semibold.ttf"
}
anchors { FontLoader {
left: parent.left source: "fonts/SourceSansPro-Bold.ttf"
leftMargin: 4 }
} FontLoader {
source: "fonts/SourceSansPro-Black.ttf"
Rectangle { }
id: sel FontLoader {
visible: false source: "fonts/SourceSansPro-Light.ttf"
anchors.fill: parent }
color: "#00000000" FontLoader {
Rectangle { source: "fonts/SourceSansPro-ExtraLight.ttf"
id: r }
anchors.fill: parent FontLoader {
border.color: "#CCCCCC" id: simpleLineIcons
border.width: 1 source: "fonts/Simple-Line-Icons.ttf"
radius: 5 }
color: "#FFFFFFFF"
} Rectangle {
Rectangle { color: "steelblue"
anchors { anchors.fill: parent
top: r.top
bottom: r.bottom MouseArea {
right: r.right anchors.fill: parent
} property real lastMouseX: 0
width: 10 property real lastMouseY: 0
color: "#FFFFFFFF" onPressed: {
lastMouseX = mouseX
Rectangle { lastMouseY = mouseY
anchors { }
left: parent.left onPositionChanged: {
right: parent.right root.x += (mouseX - lastMouseX)
top: parent.top root.y += (mouseY - lastMouseY)
} }
height: 1 /*onDoubleClicked: {
color: "#CCCCCC" //!maximized ? view.set_max() : view.set_normal()}
} visibility = "Minimized"
}*/
Rectangle { }
anchors { }
left: parent.left
right: parent.right
bottom: parent.bottom
} anchors.top: parent.top
height: 1 Rectangle {
color: "#CCCCCC" width: parent.height
} height: parent.width
} anchors.centerIn: parent
} rotation: 90
MouseArea { gradient: Gradient {
anchors.fill: parent GradientStop { position: 0.0; color: "#E2DEDE" }
onClicked: { GradientStop { position: 0.1; color: "#EBE8E8" }
activeView(view, menuItem); GradientStop { position: 1.0; color: "#EBE8E8" }
} }
} }
Image { Component {
id: icon id: menuItemTemplate
height: 20 Rectangle {
width: 20 id: menuItem
anchors { property var view;
left: parent.left property var path;
verticalCenter: parent.verticalCenter property var closable;
leftMargin: 3
} property alias title: label.text
MouseArea { property alias icon: icon.source
anchors.fill: parent property alias secondaryTitle: secondary.text
onClicked: { function setSelection(on) {
menuItem.closeApp() sel.visible = on
}
} if (this.closable == true) {
} closeIcon.visible = on
}
Text { }
id: label
anchors { function setAsBigButton(on) {
left: icon.right newAppButton.visible = on
verticalCenter: parent.verticalCenter label.visible = !on
leftMargin: 3 buttonLabel.visible = on
} }
color: "#0D0A01" width: 192
font.pixelSize: 12 height: 55
} color: "#00000000"
Text { anchors {
id: secondary left: parent.left
anchors { leftMargin: 4
right: parent.right }
rightMargin: 8
verticalCenter: parent.verticalCenter Rectangle {
} // New App Button
color: "#AEADBE" id: newAppButton
font.pixelSize: 12 visible: false
} anchors.fill: parent
anchors.rightMargin: 8
border.width: 0
function closeApp() { radius: 5
if(!this.closable) { return; } height: 55
width: 180
if(this.view.hasOwnProperty("onDestroy")) { color: "#F3F1F3"
this.view.onDestroy.call(this.view) }
}
Rectangle {
this.view.destroy() id: sel
this.destroy() visible: false
for (var i = 0; i < mainSplit.views.length; i++) { anchors.fill: parent
var view = mainSplit.views[i]; color: "#00000000"
if (view.menuItem === this) { Rectangle {
mainSplit.views.splice(i, 1); id: r
break; anchors.fill: parent
} border.width: 0
} radius: 5
gui.removePlugin(this.path) color: "#FFFFFFFF"
activeView(mainSplit.views[0].view, mainSplit.views[0].menuItem); }
} Rectangle {
} anchors {
} top: r.top
bottom: r.bottom
function createMenuItem(view, options) { right: r.right
if(options === undefined) { }
options = {}; width: 10
} color: "#FFFFFFFF"
border.width:0
var section;
switch(options.section) { Rectangle {
case "ethereum": // Small line on top of selection. What's this for?
section = menuDefault; anchors {
break; left: parent.left
case "legacy": right: parent.right
section = menuLegacy; top: parent.top
break; }
default: height: 1
section = menuApps; color: "#FFFFFF"
break; }
}
Rectangle {
var comp = menuItemTemplate.createObject(section) // Small line on bottom of selection. What's this for again?
comp.view = view anchors {
comp.title = view.title left: parent.left
right: parent.right
if(view.hasOwnProperty("iconSource")) { bottom: parent.bottom
comp.icon = view.iconSource; }
} height: 1
comp.closable = options.close; color: "#FFFFFF"
}
return comp }
} }
ColumnLayout { MouseArea {
id: menuColumn anchors.fill: parent
y: 10 hoverEnabled: true
width: parent.width onClicked: {
anchors.left: parent.left activeView(view, menuItem);
anchors.right: parent.right }
spacing: 3 onEntered: {
if (parent.closable == true) {
Text { closeIcon.visible = sel.visible
text: "ETHEREUM" }
font.bold: true
anchors { }
left: parent.left onExited: {
leftMargin: 5 closeIcon.visible = false
} }
color: "#888888" }
}
Image {
ColumnLayout { id: icon
id: menuDefault height: 24
spacing: 3 width: 24
anchors { anchors {
left: parent.left left: parent.left
right: parent.right verticalCenter: parent.verticalCenter
} leftMargin: 6
} }
}
Text { Text {
text: "NET" id: buttonLabel
font.bold: true visible: false
anchors { text: "GO TO NEW APP"
left: parent.left font.family: sourceSansPro.name
leftMargin: 5 font.weight: Font.DemiBold
} anchors.horizontalCenter: parent.horizontalCenter
color: "#888888" anchors.verticalCenter: parent.verticalCenter
} color: "#AAA0A0"
}
ColumnLayout {
id: menuApps Text {
spacing: 3 id: label
anchors { font.family: sourceSansPro.name
left: parent.left font.weight: Font.DemiBold
right: parent.right anchors {
} left: icon.right
} verticalCenter: parent.verticalCenter
leftMargin: 6
Text { // verticalCenterOffset: -10
text: "DEBUG" }
font.bold: true x:250
anchors { color: "#665F5F"
left: parent.left font.pixelSize: 14
leftMargin: 5 }
}
color: "#888888"
} Text {
id: secondary
ColumnLayout { font.family: sourceSansPro.name
id: menuLegacy font.weight: Font.Light
spacing: 3 anchors {
anchors { left: icon.right
left: parent.left leftMargin: 6
right: parent.right top: label.bottom
} }
} color: "#6691C2"
} font.pixelSize: 12
} }
/********************* Rectangle {
* Main view id: closeIcon
********************/ visible: false
Rectangle { width: 10
id: rootView height: 10
anchors.right: parent.right color: "#FFFFFF"
anchors.left: menu.right anchors {
anchors.bottom: parent.bottom fill: icon
anchors.top: parent.top }
color: "#00000000"
MouseArea {
Rectangle { anchors.fill: parent
id: urlPane onClicked: {
height: 40 menuItem.closeApp()
color: "#00000000" }
anchors { }
left: parent.left
right: parent.right Text {
leftMargin: 5
rightMargin: 5 font.family: simpleLineIcons.name
top: parent.top anchors {
topMargin: 5 centerIn: parent
} }
TextField { color: "#665F5F"
id: url font.pixelSize: 18
objectName: "url" text: "\ue082"
placeholderText: "DApp URL" }
anchors { }
left: parent.left
right: parent.right
top: parent.top
topMargin: 5 function closeApp() {
rightMargin: 5 if(!this.closable) { return; }
leftMargin: 5
} if(this.view.hasOwnProperty("onDestroy")) {
this.view.onDestroy.call(this.view)
Keys.onReturnPressed: { }
if(/^https?/.test(this.text)) {
newBrowserTab(this.text); this.view.destroy()
} else { this.destroy()
addPlugin(this.text, {close: true, section: "apps"}) for (var i = 0; i < mainSplit.views.length; i++) {
} var view = mainSplit.views[i];
} if (view.menuItem === this) {
} mainSplit.views.splice(i, 1);
break;
} }
}
// Border gui.removePlugin(this.path)
Rectangle { activeView(mainSplit.views[0].view, mainSplit.views[0].menuItem);
id: divider }
anchors { }
left: parent.left }
right: parent.right
top: urlPane.bottom function createMenuItem(view, options) {
} if(options === undefined) {
z: -1 options = {};
height: 1 }
color: "#CCCCCC"
} var section;
switch(options.section) {
Rectangle { case "begin":
id: mainView section = menuBegin
color: "#00000000" break;
anchors.right: parent.right case "ethereum":
anchors.left: parent.left section = menuDefault;
anchors.bottom: parent.bottom break;
anchors.top: divider.bottom case "legacy":
section = menuLegacy;
function createView(component) { break;
var view = component.createObject(mainView) default:
section = menuApps;
return view; break;
} }
}
} var comp = menuItemTemplate.createObject(section)
} comp.view = view
comp.title = view.title
/****************** if(view.hasOwnProperty("iconSource")) {
* Dialogs comp.icon = view.iconSource;
*****************/ }
FileDialog { comp.closable = options.close;
id: generalFileDialog
property var callback; if (options.section === "begin") {
onAccepted: { comp.setAsBigButton(true)
var path = this.fileUrl.toString(); }
callback.call(this, path);
} return comp
}
function show(selectExisting, callback) {
generalFileDialog.callback = callback; ColumnLayout {
generalFileDialog.selectExisting = selectExisting; id: menuColumn
y: 10
this.open(); width: parent.width
} anchors.left: parent.left
} anchors.right: parent.right
spacing: 3
/******************
* Wallet functions
*****************/ ColumnLayout {
function importApp(path) { id: menuBegin
var ext = path.split('.').pop() spacing: 3
if(ext == "html" || ext == "htm") { anchors {
eth.openHtml(path) left: parent.left
}else if(ext == "qml"){ right: parent.right
addPlugin(path, {close: true, section: "apps"}) }
} }
}
Rectangle {
height: 55
function setWalletValue(value) { color: "transparent"
walletValueLabel.text = value Text {
} text: "ETHEREUM"
font.family: sourceSansPro.name
function loadPlugin(name) { font.weight: Font.DemiBold
console.log("Loading plugin" + name) anchors {
var view = mainView.addPlugin(name) left: parent.left
} top: parent.verticalCenter
leftMargin: 16
function setPeers(text) { }
peerLabel.text = text color: "#AAA0A0"
} }
}
function addPeer(peer) {
// We could just append the whole peer object but it cries if you try to alter them
peerModel.append({ip: peer.ip, port: peer.port, lastResponse:timeAgo(peer.lastSend), latency: peer.latency, version: peer.version, caps: peer.caps}) ColumnLayout {
} id: menuDefault
spacing: 3
function resetPeers(){ anchors {
peerModel.clear() left: parent.left
} right: parent.right
}
function timeAgo(unixTs){ }
var lapsed = (Date.now() - new Date(unixTs*1000)) / 1000
return (lapsed + " seconds ago") Rectangle {
} height: 55
color: "transparent"
function convertToPretty(unixTs){ Text {
var a = new Date(unixTs*1000); text: "APPS"
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; font.family: sourceSansPro.name
var year = a.getFullYear(); font.weight: Font.DemiBold
var month = months[a.getMonth()]; anchors {
var date = a.getDate(); left: parent.left
var hour = a.getHours(); top: parent.verticalCenter
var min = a.getMinutes(); leftMargin: 16
var sec = a.getSeconds(); }
var time = date+' '+month+' '+year+' '+hour+':'+min+':'+sec ; color: "#AAA0A0"
return time; }
} }
/********************** ColumnLayout {
* Windows id: menuApps
*********************/ spacing: 3
Window { anchors {
id: peerWindow left: parent.left
//flags: Qt.CustomizeWindowHint | Qt.Tool | Qt.WindowCloseButtonHint right: parent.right
height: 200 }
width: 700 }
Rectangle {
anchors.fill: parent Rectangle {
property var peerModel: ListModel { height: 55
id: peerModel color: "transparent"
} Text {
TableView { text: "DEBUG"
anchors.fill: parent font.family: sourceSansPro.name
id: peerTable font.weight: Font.DemiBold
model: peerModel anchors {
TableViewColumn{width: 200; role: "ip" ; title: "IP" } left: parent.left
TableViewColumn{width: 260; role: "version" ; title: "Version" } top: parent.verticalCenter
TableViewColumn{width: 180; role: "caps" ; title: "Capabilities" } leftMargin: 16
} }
} color: "#AAA0A0"
} }
}
Window {
id: aboutWin
visible: false ColumnLayout {
title: "About" id: menuLegacy
minimumWidth: 350 spacing: 3
maximumWidth: 350 anchors {
maximumHeight: 280 left: parent.left
minimumHeight: 280 right: parent.right
}
Image { }
id: aboutIcon }
height: 150 }
width: 150
fillMode: Image.PreserveAspectFit /*********************
smooth: true * Main view
source: "../facet.png" ********************/
x: 10 Rectangle {
y: 30 id: rootView
} anchors.right: parent.right
anchors.left: menu.right
Text { anchors.bottom: parent.bottom
anchors.left: aboutIcon.right anchors.top: parent.top
anchors.leftMargin: 10 color: "#00000000"
anchors.top: parent.top
anchors.topMargin: 30 Rectangle {
font.pointSize: 12 id: urlPane
text: "<h2>Mist (0.7.10)</h2><br><h3>Development</h3>Jeffrey Wilcke<br>Viktor Trón<br>Felix Lange<br>Taylor Gerring<br>Daniel Nagy<br><h3>UX</h3>Alex van de Sande<br>" height: 40
} color: "#00000000"
} anchors {
left: parent.left
Window { right: parent.right
id: txImportDialog leftMargin: 5
minimumWidth: 270 rightMargin: 5
maximumWidth: 270 top: parent.top
maximumHeight: 50 topMargin: 5
minimumHeight: 50 }
TextField { TextField {
id: txImportField id: url
width: 170 objectName: "url"
anchors.verticalCenter: parent.verticalCenter placeholderText: "DApp URL"
anchors.left: parent.left anchors {
anchors.leftMargin: 10 left: parent.left
onAccepted: { right: parent.right
} top: parent.top
} topMargin: 5
Button { rightMargin: 5
anchors.left: txImportField.right leftMargin: 5
anchors.verticalCenter: parent.verticalCenter }
anchors.leftMargin: 5
text: "Import" Keys.onReturnPressed: {
onClicked: { if(/^https?/.test(this.text)) {
eth.importTx(txImportField.text) newBrowserTab(this.text);
txImportField.visible = false } else {
} addPlugin(this.text, {close: true, section: "apps"})
} }
Component.onCompleted: { }
addrField.focus = true }
}
} }
Window { // Border
id: addPeerWin Rectangle {
visible: false id: divider
minimumWidth: 300 anchors {
maximumWidth: 300 left: parent.left
maximumHeight: 50 right: parent.right
minimumHeight: 50 top: urlPane.bottom
title: "Connect to peer" }
z: -1
ComboBox { height: 1
id: addrField color: "#CCCCCC"
anchors.verticalCenter: parent.verticalCenter }
anchors.left: parent.left
anchors.right: addPeerButton.left Rectangle {
anchors.leftMargin: 10 id: mainView
anchors.rightMargin: 10 color: "#00000000"
onAccepted: { anchors.right: parent.right
eth.connectToPeer(addrField.currentText) anchors.left: parent.left
addPeerWin.visible = false anchors.bottom: parent.bottom
} anchors.top: divider.bottom
editable: true function createView(component) {
model: ListModel { id: pastPeers } var view = component.createObject(mainView)
Component.onCompleted: { return view;
pastPeers.insert(0, {text: "poc-8.ethdev.com:30303"}) }
/* }
var ips = eth.pastPeers() }
for(var i = 0; i < ips.length; i++) { }
pastPeers.append({text: ips.get(i)})
}
/******************
pastPeers.insert(0, {text: "poc-7.ethdev.com:30303"}) * Dialogs
*/ *****************/
} FileDialog {
} id: generalFileDialog
property var callback;
Button { onAccepted: {
id: addPeerButton var path = this.fileUrl.toString();
anchors.right: parent.right callback.call(this, path);
anchors.verticalCenter: parent.verticalCenter }
anchors.rightMargin: 10
text: "Add" function show(selectExisting, callback) {
onClicked: { generalFileDialog.callback = callback;
eth.connectToPeer(addrField.currentText) generalFileDialog.selectExisting = selectExisting;
addPeerWin.visible = false
} this.open();
} }
Component.onCompleted: { }
addrField.focus = true
}
} /******************
} * Wallet functions
*****************/
function importApp(path) {
var ext = path.split('.').pop()
if(ext == "html" || ext == "htm") {
eth.openHtml(path)
}else if(ext == "qml"){
addPlugin(path, {close: true, section: "apps"})
}
}
function setWalletValue(value) {
walletValueLabel.text = value
}
function loadPlugin(name) {
console.log("Loading plugin" + name)
var view = mainView.addPlugin(name)
}
function setPeers(text) {
peerLabel.text = text
}
function addPeer(peer) {
// We could just append the whole peer object but it cries if you try to alter them
peerModel.append({ip: peer.ip, port: peer.port, lastResponse:timeAgo(peer.lastSend), latency: peer.latency, version: peer.version, caps: peer.caps})
}
function resetPeers(){
peerModel.clear()
}
function timeAgo(unixTs){
var lapsed = (Date.now() - new Date(unixTs*1000)) / 1000
return (lapsed + " seconds ago")
}
function convertToPretty(unixTs){
var a = new Date(unixTs*1000);
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var year = a.getFullYear();
var month = months[a.getMonth()];
var date = a.getDate();
var hour = a.getHours();
var min = a.getMinutes();
var sec = a.getSeconds();
var time = date+' '+month+' '+year+' '+hour+':'+min+':'+sec ;
return time;
}
/**********************
* Windows
*********************/
Window {
id: peerWindow
//flags: Qt.CustomizeWindowHint | Qt.Tool | Qt.WindowCloseButtonHint
height: 200
width: 700
Rectangle {
anchors.fill: parent
property var peerModel: ListModel {
id: peerModel
}
TableView {
anchors.fill: parent
id: peerTable
model: peerModel
TableViewColumn{width: 200; role: "ip" ; title: "IP" }
TableViewColumn{width: 260; role: "version" ; title: "Version" }
TableViewColumn{width: 180; role: "caps" ; title: "Capabilities" }
}
}
}
Window {
id: aboutWin
visible: false
title: "About"
minimumWidth: 350
maximumWidth: 350
maximumHeight: 280
minimumHeight: 280
Image {
id: aboutIcon
height: 150
width: 150
fillMode: Image.PreserveAspectFit
smooth: true
source: "../facet.png"
x: 10
y: 30
}
Text {
anchors.left: aboutIcon.right
anchors.leftMargin: 10
anchors.top: parent.top
anchors.topMargin: 30
font.pointSize: 12
text: "<h2>Mist (0.7.10)</h2><br><h3>Development</h3>Jeffrey Wilcke<br>Viktor Trón<br>Felix Lange<br>Taylor Gerring<br>Daniel Nagy<br><h3>UX</h3>Alex van de Sande<br>"
}
}
Window {
id: txImportDialog
minimumWidth: 270
maximumWidth: 270
maximumHeight: 50
minimumHeight: 50
TextField {
id: txImportField
width: 170
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 10
onAccepted: {
}
}
Button {
anchors.left: txImportField.right
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: 5
text: "Import"
onClicked: {
eth.importTx(txImportField.text)
txImportField.visible = false
}
}
Component.onCompleted: {
addrField.focus = true
}
}
Window {
id: addPeerWin
visible: false
minimumWidth: 300
maximumWidth: 300
maximumHeight: 50
minimumHeight: 50
title: "Connect to peer"
ComboBox {
id: addrField
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.right: addPeerButton.left
anchors.leftMargin: 10
anchors.rightMargin: 10
onAccepted: {
eth.connectToPeer(addrField.currentText)
addPeerWin.visible = false
}
editable: true
model: ListModel { id: pastPeers }
Component.onCompleted: {
pastPeers.insert(0, {text: "poc-8.ethdev.com:30303"})
/*
var ips = eth.pastPeers()
for(var i = 0; i < ips.length; i++) {
pastPeers.append({text: ips.get(i)})
}
pastPeers.insert(0, {text: "poc-7.ethdev.com:30303"})
*/
}
}
Button {
id: addPeerButton
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: 10
text: "Add"
onClicked: {
eth.connectToPeer(addrField.currentText)
addPeerWin.visible = false
}
}
Component.onCompleted: {
addrField.focus = true
}
}
}
\ No newline at end of file
...@@ -56,12 +56,34 @@ Rectangle { ...@@ -56,12 +56,34 @@ Rectangle {
//uriNav.text = uri.text.replace(/(^https?\:\/\/(?:www\.)?)([a-zA-Z0-9_\-]*\.\w{2,3})(.*)/, "$1$2<span style='color:#CCC'>$3</span>"); //uriNav.text = uri.text.replace(/(^https?\:\/\/(?:www\.)?)([a-zA-Z0-9_\-]*\.\w{2,3})(.*)/, "$1$2<span style='color:#CCC'>$3</span>");
uriNav.text = uri; uriNav.text = uri;
} else { } else {
// Prevent inf loop. // Prevent inf loop.
window.cleanPath = false; window.cleanPath = false;
} }
} }
function showFullUrlBar(on){
if (on) {
//appTitle.visible = false
//appDomain.visible = false
//uriNav.visible = true
clickAnywhereOnApp.visible = true
navBar.state = "fullUrlVisible"
} else {
//appTitle.visible = true
//appDomain.visible = true
//uriNav.visible = false
clickAnywhereOnApp.visible = false
navBar.state = "titleVisible"
}
}
Component.onCompleted: { Component.onCompleted: {
} }
...@@ -71,75 +93,234 @@ Rectangle { ...@@ -71,75 +93,234 @@ Rectangle {
anchors.fill: parent anchors.fill: parent
state: "inspectorShown" state: "inspectorShown"
MouseArea {
id: clickAnywhereOnApp
z:15
//hoverEnabled: true
anchors.fill: parent
/*hoverEnabled: true*/
onClicked: {
showFullUrlBar(false);
}
/*Rectangle {
anchors.fill: parent
color: "#88888888"
}*/
}
RowLayout { RowLayout {
id: navBar id: navBar
height: 40 height: 74
z: 20
anchors { anchors {
left: parent.left left: parent.left
right: parent.right right: parent.right
leftMargin: 7
} }
Button { Button {
id: back id: back
onClicked: { onClicked: {
webview.goBack() webview.goBack()
} }
anchors{
left: parent.left
leftMargin: 6
}
style: ButtonStyle { style: ButtonStyle {
background: Image { background: Image {
source: "../../back.png" source: "../../backButton.png"
width: 30 width: 20
height: 30 height: 30
} }
} }
} }
TextField { Rectangle {
anchors { id: appInfoPane
height: 28
color: "#FFFFFF"
radius: 6
MouseArea {
anchors.fill: parent
z: 10
hoverEnabled: true
onEntered: {
showFullUrlBar(true);
}
}
anchors {
left: back.right left: back.right
right: toggleInspector.left right: parent.right
leftMargin: 10 leftMargin: 10
rightMargin: 10 rightMargin: 10
} }
text: webview.url;
id: uriNav
y: parent.height / 2 - this.height / 2
Keys.onReturnPressed: { Text {
webview.url = this.text; id: appTitle
} text: "LOADING"
font.bold: true
font.capitalization: Font.AllUppercase
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
anchors {
left: parent.left
right: parent.horizontalCenter
top: parent.top
bottom: parent.bottom
rightMargin: 10
}
color: "#928484"
}
Text {
id: appDomain
text: "loading domain"
font.bold: false
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
anchors {
left: parent.horizontalCenter
right: parent.right
top: parent.top
bottom: parent.bottom
leftMargin: 10
}
color: "#C0AFAF"
}
TextField {
id: uriNav
opacity: 0.0
anchors {
left: parent.left
right: parent.right
leftMargin: 16
}
horizontalAlignment: Text.AlignHCenter
style: TextFieldStyle {
textColor: "#928484"
background: Rectangle {
border.width: 0
color: "transparent"
}
}
text: webview.url;
y: parent.height / 2 - this.height / 2
z: 20
activeFocusOnPress: true
Keys.onReturnPressed: {
webview.url = this.text;
}
/* onFocusedChanged: {
if (focused) {
//uriNav.selectAll();
}
}*/
}
z:2
} }
Rectangle {
id: appInfoPaneShadow
width: 10
height: 30
color: "#BDB6B6"
radius: 6
Button { anchors {
id: toggleInspector left: back.right
anchors {
right: parent.right right: parent.right
leftMargin:10
rightMargin:10
top: parent.top
topMargin: 23
} }
iconSource: "../../bug.png"
onClicked: {
// XXX soon
return
if(inspector.visible == true){
inspector.visible = false
}else{
inspector.visible = true
inspector.url = webview.experimental.remoteInspectorUrl
}
}
}
}
// Border z:1
Rectangle {
id: divider
anchors {
left: parent.left
right: parent.right
top: navBar.bottom
} }
z: -1
height: 1 Rectangle {
color: "#CCCCCC" id: navBarBackground
anchors.fill: parent
gradient: Gradient {
GradientStop { position: 0.0; color: "#F6F1F2" }
GradientStop { position: 1.0; color: "#DED5D5" }
}
z:-1
}
states: [
State {
name: "fullUrlVisible"
PropertyChanges {
target: appTitle
anchors.rightMargin: -50
opacity: 0.0
}
PropertyChanges {
target: appDomain
anchors.leftMargin: -50
opacity: 0.0
}
PropertyChanges {
target: uriNav
anchors.leftMargin: 0
opacity: 1.0
}
},
State {
name: "titleVisible"
PropertyChanges {
target: appTitle
anchors.rightMargin: 10
opacity: 1.0
}
PropertyChanges {
target: appDomain
anchors.leftMargin: 10
opacity: 1.0
}
PropertyChanges {
target: uriNav
anchors.leftMargin: -50
opacity: 0.0
}
}
]
transitions: [
// This adds a transition that defaults to applying to all state changes
Transition {
// This applies a default NumberAnimation to any changes a state change makes to x or y properties
NumberAnimation {
properties: "anchors.leftMargin, anchors.rightMargin, opacity"
easing.type: Easing.InOutQuad //Easing.InOutBack
duration: 300
}
}
]
} }
WebEngineView { WebEngineView {
...@@ -149,16 +330,44 @@ Rectangle { ...@@ -149,16 +330,44 @@ Rectangle {
left: parent.left left: parent.left
right: parent.right right: parent.right
bottom: parent.bottom bottom: parent.bottom
top: divider.bottom top: navBar.bottom
} }
z: 10
onLoadingChanged: { onLoadingChanged: {
if (loadRequest.status == WebEngineView.LoadSucceededStatus) { if (loadRequest.status == WebEngineView.LoadSucceededStatus) {
webview.runJavaScript("document.title", function(pageTitle) { webview.runJavaScript("document.title", function(pageTitle) {
menuItem.title = pageTitle; menuItem.title = pageTitle;
}); });
//var topBarStyle
webView.runJavaScript("document.querySelector(\"meta[name='ethereum-dapp-url-bar-style']\").getAttribute(\"content\")", function(topBarStyle){
if (topBarStyle=="transparent") {
// Adjust for a transparent sidebar Dapp
navBarBackground.visible = false;
back.visible = false;
appInfoPane.anchors.leftMargin = -16;
appInfoPaneShadow.anchors.leftMargin = -16;
webview.anchors.topMargin = -74;
webview.runJavaScript("document.querySelector('body').classList.add('ethereum-dapp-url-bar-style-transparent')")
};
});
webview.runJavaScript(eth.readFile("bignumber.min.js")); webview.runJavaScript(eth.readFile("bignumber.min.js"));
webview.runJavaScript(eth.readFile("ethereum.js/dist/ethereum.js")); webview.runJavaScript(eth.readFile("ethereum.js/dist/ethereum.js"));
var cleanTitle = webview.url.toString()
var matches = cleanTitle.match(/^[a-z]*\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);
var domain = matches && matches[1];
appDomain.text = domain //webview.url.replace("a", "z")
appTitle.text = webview.title
showFullUrlBar(false);
} }
} }
onJavaScriptConsoleMessage: { onJavaScriptConsoleMessage: {
...@@ -208,4 +417,3 @@ Rectangle { ...@@ -208,4 +417,3 @@ Rectangle {
] ]
} }
} }
import QtQuick 2.0
import QtQuick.Controls 1.0;
import QtQuick.Controls.Styles 1.0
import QtQuick.Layouts 1.0;
import QtWebEngine 1.0
//import QtWebEngine.experimental 1.0
import QtQuick.Window 2.0;
Rectangle {
id: window
anchors.fill: parent
color: "#00000000"
property var title: ""
property var iconSource: ""
property var menuItem
property var hideUrl: true
property alias url: webview.url
property alias windowTitle: webview.title
property alias webView: webview
property var cleanPath: false
property var open: function(url) {
if(!window.cleanPath) {
var uri = url;
if(!/.*\:\/\/.*/.test(uri)) {
uri = "http://" + uri;
}
var reg = /(^https?\:\/\/(?:www\.)?)([a-zA-Z0-9_\-]*\.eth)(.*)/
if(reg.test(uri)) {
uri.replace(reg, function(match, pre, domain, path) {
uri = pre;
var lookup = eth.lookupDomain(domain.substring(0, domain.length - 4));
var ip = [];
for(var i = 0, l = lookup.length; i < l; i++) {
ip.push(lookup.charCodeAt(i))
}
if(ip.length != 0) {
uri += lookup;
} else {
uri += domain;
}
uri += path;
});
}
window.cleanPath = true;
webview.url = uri;
//uriNav.text = uri.text.replace(/(^https?\:\/\/(?:www\.)?)([a-zA-Z0-9_\-]*\.\w{2,3})(.*)/, "$1$2<span style='color:#CCC'>$3</span>");
uriNav.text = uri;
} else {
// Prevent inf loop.
window.cleanPath = false;
}
}
Component.onCompleted: {
}
Item {
objectName: "root"
id: root
anchors.fill: parent
state: "inspectorShown"
RowLayout {
id: navBar
height: 184
z: 20
anchors {
left: parent.left
right: parent.right
}
Rectangle {
id: appInfoPane
height: 28
color: "#efefef"
radius: 6
z:25
MouseArea {
anchors.fill: parent
z: 10
hoverEnabled: true
onEntered: {
uriNav.visible = true
appTitle.visible = false
appDomain.visible = false
}
}
anchors {
left: parent.left
right: parent.right
leftMargin: 10
rightMargin: 10
top: parent.verticalCenter
topMargin: 23
}
TextField {
id: uriNav
anchors {
left: parent.left
right: parent.right
leftMargin: 16
top: parent.verticalCenter
topMargin: -10
}
horizontalAlignment: Text.AlignHCenter
style: TextFieldStyle {
textColor: "#928484"
background: Rectangle {
border.width: 0
color: "transparent"
}
}
text: "Type the address of a new Dapp";
y: parent.height / 2 - this.height / 2
z: 30
activeFocusOnPress: true
Keys.onReturnPressed: {
newBrowserTab(this.text);
this.text = "Type the address of a new Dapp";
}
}
}
Rectangle {
id: appInfoPaneShadow
width: 10
height: 30
color: "#BDB6B6"
radius: 6
z: 15
anchors {
left: parent.left
right: parent.right
leftMargin:10
rightMargin:10
top: parent.verticalCenter
topMargin: 23
}
}
}
WebEngineView {
objectName: "webView"
id: webview
anchors.fill: parent
onLoadingChanged: {
if (loadRequest.status == WebEngineView.LoadSucceededStatus) {
webview.runJavaScript(eth.readFile("bignumber.min.js"));
webview.runJavaScript(eth.readFile("ethereum.js/dist/ethereum.js"));
}
}
onJavaScriptConsoleMessage: {
console.log(sourceID + ":" + lineNumber + ":" + JSON.stringify(message));
}
}
WebEngineView {
id: inspector
visible: false
z:10
anchors {
left: root.left
right: root.right
top: sizeGrip.bottom
bottom: root.bottom
}
}
states: [
State {
name: "inspectorShown"
PropertyChanges {
target: inspector
}
}
]
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment