This commit is contained in:
obscuren 2015-02-17 16:13:06 +01:00
commit fe94622ea3
15 changed files with 256 additions and 188 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 657 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 756 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,35 @@
// Copyright (c) 2015, ETHDEV. All rights reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301 USA
// this function is included locally, but you can also include separately via a header definition
console.log("loaded?");
document.onkeydown = function(evt) {
evt = evt || window.event;
if (evt.ctrlKey && evt.keyCode == 67) {
window.document.execCommand("copy");
console.log("Ctrl-C");
} else if (evt.ctrlKey && evt.keyCode == 88) {
window.document.execCommand("cut");
console.log("Ctrl-X");
} if (evt.ctrlKey && evt.keyCode == 86) {
console.log("Ctrl-V");
} if (evt.ctrlKey && evt.keyCode == 90) {
console.log("Ctrl-Z");
}
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -40,10 +40,14 @@ ApplicationWindow {
// Takes care of loading all default plugins // Takes care of loading all default plugins
Component.onCompleted: { Component.onCompleted: {
catalog = addPlugin("./views/catalog.qml", {noAdd: true, close: false, section: "begin"}); catalog = addPlugin("./views/catalog.qml", {noAdd: true, close: false, section: "begin", active: true});
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}); var walletWeb = addPlugin("./views/browser.qml", {noAdd: true, close: false, section: "ethereum", active: false});
walletWeb.view.url = "http://ethereum-dapp-wallet.meteor.com/";
walletWeb.menuItem.title = "Wallet";
addPlugin("./views/wallet.qml", {noAdd: true, close: false, section: "legacy"});
addPlugin("./views/miner.qml", {noAdd: true, close: false, section: "ethereum", active: false});
addPlugin("./views/transaction.qml", {noAdd: true, close: false, section: "legacy"}); addPlugin("./views/transaction.qml", {noAdd: true, close: false, section: "legacy"});
addPlugin("./views/whisper.qml", {noAdd: true, close: false, section: "legacy"}); addPlugin("./views/whisper.qml", {noAdd: true, close: false, section: "legacy"});
addPlugin("./views/chain.qml", {noAdd: true, close: false, section: "legacy"}); addPlugin("./views/chain.qml", {noAdd: true, close: false, section: "legacy"});
@ -60,13 +64,14 @@ ApplicationWindow {
function activeView(view, menuItem) { function activeView(view, menuItem) {
mainSplit.setView(view, menuItem) mainSplit.setView(view, menuItem)
if (view.hideUrl) { /*if (view.hideUrl) {
//urlPane.visible = false; urlPane.visible = false;
//mainView.anchors.top = rootView.top mainView.anchors.top = rootView.top
} else { } else {
//urlPane.visible = true; urlPane.visible = true;
//mainView.anchors.top = divider.bottom mainView.anchors.top = divider.bottom
} }*/
} }
function addViews(view, path, options) { function addViews(view, path, options) {
@ -121,13 +126,10 @@ ApplicationWindow {
var domainAlreadyOpen = false; var domainAlreadyOpen = false;
console.log("requested: " + requestedDomain )
for(var i = 0; i < mainSplit.views.length; i++) { for(var i = 0; i < mainSplit.views.length; i++) {
if (mainSplit.views[i].view.url) { if (mainSplit.views[i].view.url) {
var matches = mainSplit.views[i].view.url.toString().match(/^[a-z]*\:\/\/(?:www\.)?([^\/?#]+)(?:[\/?#]|$)/i); var matches = mainSplit.views[i].view.url.toString().match(/^[a-z]*\:\/\/(?:www\.)?([^\/?#]+)(?:[\/?#]|$)/i);
var existingDomain = matches && matches[1]; var existingDomain = matches && matches[1];
console.log("exists: " + existingDomain);
if (requestedDomain == existingDomain) { if (requestedDomain == existingDomain) {
domainAlreadyOpen = true; domainAlreadyOpen = true;
mainSplit.views[i].view.url = url; mainSplit.views[i].view.url = url;
@ -247,79 +249,6 @@ ApplicationWindow {
} }
} }
statusBar: StatusBar {
//height: 32
visible: false
id: statusBar
Label {
//y: 6
id: walletValueLabel
font.pixelSize: 10
styleColor: "#797979"
}
/*
Label {
//y: 6
objectName: "miningLabel"
visible: true
font.pixelSize: 10
anchors.right: lastBlockLabel.left
anchors.rightMargin: 5
}
Label {
id: lastBlockLabel
objectName: "lastBlockLabel"
visible: true
text: "---"
font.pixelSize: 10
anchors.right: peerGroup.left
anchors.rightMargin: 5
}
*/
ProgressBar {
visible: false
id: downloadIndicator
value: 0
objectName: "downloadIndicator"
y: -4
x: statusBar.width / 2 - this.width / 2
width: 160
}
Label {
visible: false
objectName: "downloadLabel"
//y: 7
anchors.left: downloadIndicator.right
anchors.leftMargin: 5
font.pixelSize: 10
text: "0 / 0"
}
RowLayout {
id: peerGroup
//y: 7
anchors.right: parent.right
MouseArea {
onDoubleClicked: peerWindow.visible = true
anchors.fill: parent
}
Label {
id: peerCounterLabel
font.pixelSize: 10
text: "0 / 0"
}
}
}
property var blockModel: ListModel { property var blockModel: ListModel {
id: blockModel id: blockModel
} }
@ -445,10 +374,14 @@ ApplicationWindow {
property var view; property var view;
property var path; property var path;
property var closable; property var closable;
property var badgeContent;
property alias title: label.text property alias title: label.text
property alias icon: icon.source property alias icon: icon.source
property alias secondaryTitle: secondary.text property alias secondaryTitle: secondary.text
property alias badgeNumber: badgeNumberLabel.text
property alias badgeIcon: badgeIconLabel.text
function setSelection(on) { function setSelection(on) {
sel.visible = on sel.visible = on
@ -541,7 +474,6 @@ ApplicationWindow {
if (parent.closable == true) { if (parent.closable == true) {
closeIcon.visible = sel.visible closeIcon.visible = sel.visible
} }
} }
onExited: { onExited: {
closeIcon.visible = false closeIcon.visible = false
@ -550,8 +482,8 @@ ApplicationWindow {
Image { Image {
id: icon id: icon
height: 24 height: 28
width: 24 width: 28
anchors { anchors {
left: parent.left left: parent.left
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
@ -574,18 +506,24 @@ ApplicationWindow {
id: label id: label
font.family: sourceSansPro.name font.family: sourceSansPro.name
font.weight: Font.DemiBold font.weight: Font.DemiBold
anchors { elide: Text.ElideRight
left: icon.right
verticalCenter: parent.verticalCenter
leftMargin: 6
// verticalCenterOffset: -10
}
x:250 x:250
color: "#665F5F" color: "#665F5F"
font.pixelSize: 14 font.pixelSize: 14
anchors {
left: icon.right
right: parent.right
verticalCenter: parent.verticalCenter
leftMargin: 6
rightMargin: 8
verticalCenterOffset: (secondaryTitle == "") ? 0 : -10;
} }
}
Text { Text {
id: secondary id: secondary
font.family: sourceSansPro.name font.family: sourceSansPro.name
@ -604,7 +542,7 @@ ApplicationWindow {
visible: false visible: false
width: 10 width: 10
height: 10 height: 10
color: "#FFFFFF" color: "#FAFAFA"
anchors { anchors {
fill: icon fill: icon
} }
@ -623,11 +561,51 @@ ApplicationWindow {
centerIn: parent centerIn: parent
} }
color: "#665F5F" color: "#665F5F"
font.pixelSize: 18 font.pixelSize: 20
text: "\ue082" text: "\ue082"
} }
} }
Rectangle {
id: badge
visible: (badgeContent == "icon" || badgeContent == "number" )? true : false
width: 32
color: "#05000000"
anchors {
right: parent.right;
top: parent.top;
bottom: parent.bottom;
rightMargin: 4;
}
Text {
id: badgeIconLabel
visible: (badgeContent == "icon") ? true : false;
font.family: simpleLineIcons.name
anchors {
centerIn: parent
}
horizontalAlignment: Text.AlignCenter
color: "#AAA0A0"
font.pixelSize: 20
text: badgeIcon
}
Text {
id: badgeNumberLabel
visible: (badgeContent == "number") ? true : false;
anchors {
centerIn: parent
}
horizontalAlignment: Text.AlignCenter
font.family: sourceSansPro.name
font.weight: Font.Light
color: "#AAA0A0"
font.pixelSize: 18
text: badgeNumber
}
}
function closeApp() { function closeApp() {

View File

@ -3,7 +3,7 @@ import QtQuick.Controls 1.0;
import QtQuick.Controls.Styles 1.0 import QtQuick.Controls.Styles 1.0
import QtQuick.Layouts 1.0; import QtQuick.Layouts 1.0;
import QtWebEngine 1.0 import QtWebEngine 1.0
import QtWebEngine.experimental 1.0 //import QtWebEngine.experimental 1.0
import QtQuick.Window 2.0; import QtQuick.Window 2.0;
Rectangle { Rectangle {
@ -64,22 +64,14 @@ Rectangle {
} }
function showFullUrlBar(on){ function showFullUrlBar(on){
if (on) { if (uriNav.focus == false ) {
//appTitle.visible = false if (on == 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 clickAnywhereOnApp.visible = false
navBar.state = "titleVisible" navBar.state = "titleVisible"
} else {
clickAnywhereOnApp.visible = true
navBar.state = "fullUrlVisible"
}
} }
} }
@ -90,24 +82,40 @@ Rectangle {
Item { Item {
objectName: "root" objectName: "root"
id: root id: root
anchors.fill: parent anchors {
fill: parent
}
state: "inspectorShown" state: "inspectorShown"
MouseArea { MouseArea {
id: clickAnywhereOnApp id: clickAnywhereOnApp
z:15 z:15
//hoverEnabled: true // Using a secondary screen to catch on mouse exits for the area, because
anchors.fill: parent // there are many hover actions conflicting
/*hoverEnabled: true*/
onClicked: { anchors {
top: parent.top
topMargin: 50
right: parent.right
bottom: parent.bottom
left: parent.left
}
hoverEnabled: true
onEntered: {
showFullUrlBar(false); showFullUrlBar(false);
} }
/*Rectangle { onClicked: {
anchors.fill: parent uriNav.focus = false
color: "#88888888" showFullUrlBar(false);
}*/ }
// Rectangle {
// anchors.fill: parent
// color: "#88888888"
// }
} }
RowLayout { RowLayout {
@ -121,19 +129,21 @@ Rectangle {
Button { Button {
id: back id: back
z: 30
onClicked: { onClicked: {
webview.goBack() webview.goBack()
} }
anchors{ anchors {
left: parent.left left: parent.left
leftMargin: 6 leftMargin: 6
} }
style: ButtonStyle { style: ButtonStyle {
background: Image { background: Image {
source: "../../backButton.png" source: (webview.canGoBack) ?
(control.hovered ? "../../backButtonHover.png" : "../../backButton.png") :
"../../backButtonDisabled.png"
width: 20 width: 20
height: 30 height: 30
} }
@ -145,8 +155,7 @@ Rectangle {
height: 28 height: 28
color: "#FFFFFF" color: "#FFFFFF"
radius: 6 radius: 6
z:2
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
z: 10 z: 10
@ -155,6 +164,9 @@ Rectangle {
onEntered: { onEntered: {
showFullUrlBar(true); showFullUrlBar(true);
} }
/*onExited: {
showFullUrlBar(false);
}*/
} }
@ -172,13 +184,14 @@ Rectangle {
font.capitalization: Font.AllUppercase font.capitalization: Font.AllUppercase
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
anchors { anchors {
left: parent.left left: parent.left
right: parent.horizontalCenter right: parent.horizontalCenter
top: parent.top top: parent.top
bottom: parent.bottom bottom: parent.bottom
rightMargin: 10 leftMargin: 32
} }
color: "#928484" color: "#928484"
} }
@ -189,13 +202,15 @@ Rectangle {
font.bold: false font.bold: false
horizontalAlignment: Text.AlignLeft horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
elide: Text.ElideLeft
anchors { anchors {
left: parent.horizontalCenter left: parent.horizontalCenter
right: parent.right right: parent.right
top: parent.top top: parent.top
bottom: parent.bottom bottom: parent.bottom
leftMargin: 10 leftMargin: 32
} }
color: "#C0AFAF" color: "#C0AFAF"
} }
@ -225,16 +240,16 @@ Rectangle {
z: 20 z: 20
activeFocusOnPress: true activeFocusOnPress: true
Keys.onReturnPressed: { Keys.onReturnPressed: {
webview.url = this.text; // if there's no http, add it.
var url = this.text,
matches = url.match(/^([a-z]*\:\/\/)?([^\/.]+)(:?\/)(.*|$)/i),
requestedProtocol = (matches && matches[1] != "undefined")? "" : "http://";
webview.url = requestedProtocol + url;
} }
/* onFocusedChanged: {
if (focused) {
//uriNav.selectAll();
}
}*/
} }
z:2
} }
Rectangle { Rectangle {
@ -243,6 +258,7 @@ Rectangle {
height: 30 height: 30
color: "#BDB6B6" color: "#BDB6B6"
radius: 6 radius: 6
z:1
anchors { anchors {
left: back.right left: back.right
@ -252,18 +268,16 @@ Rectangle {
top: parent.top top: parent.top
topMargin: 23 topMargin: 23
} }
z:1
} }
Rectangle { Rectangle {
id: navBarBackground id: navBarBackground
anchors.fill: parent anchors.fill: parent
z:-1
gradient: Gradient { gradient: Gradient {
GradientStop { position: 0.0; color: "#F6F1F2" } GradientStop { position: 0.0; color: "#F6F1F2" }
GradientStop { position: 1.0; color: "#DED5D5" } GradientStop { position: 1.0; color: "#DED5D5" }
} }
z:-1
} }
states: [ states: [
@ -326,8 +340,8 @@ Rectangle {
WebEngineView { WebEngineView {
objectName: "webView" objectName: "webView"
id: webview id: webview
experimental.settings.javascriptCanAccessClipboard: true //experimental.settings.javascriptCanAccessClipboard: true
experimental.settings.localContentCanAccessRemoteUrls: true //experimental.settings.localContentCanAccessRemoteUrls: true
anchors { anchors {
left: parent.left left: parent.left
right: parent.right right: parent.right
@ -337,11 +351,47 @@ Rectangle {
z: 10 z: 10
Timer { Timer {
interval: 500; running: true; repeat: true interval: 2000; running: true; repeat: true
onTriggered: { onTriggered: {
webview.runJavaScript("try{document.querySelector('meta[name=badge]').getAttribute('content')}catch(e){}", function(badge) { webview.runJavaScript("try{document.querySelector('meta[name=ethereum-dapp-info]').getAttribute('content')}catch(e){}", function(extraInfo) {
if (extraInfo) {
menuItem.secondaryTitle = extraInfo;
}
});
webview.runJavaScript("try{document.querySelector('meta[name=ethereum-dapp-badge]').getAttribute('content')}catch(e){}", function(badge) {
if (badge) { if (badge) {
menuItem.secondaryTitle = badge; if (Number(badge)>0 && Number(badge)<999) {
menuItem.badgeNumber = Number(badge);
menuItem.badgeContent = "number"
} else if (badge == "warning") {
menuItem.badgeIcon = "\ue00e"
menuItem.badgeContent = "icon"
} else if (badge == "ghost") {
menuItem.badgeIcon = "\ue01a"
menuItem.badgeContent = "icon"
} else if (badge == "question") {
menuItem.badgeIcon = "\ue05d"
menuItem.badgeContent = "icon"
} else if (badge == "info") {
menuItem.badgeIcon = "\ue08b"
menuItem.badgeContent = "icon"
} else if (badge == "check") {
menuItem.badgeIcon = "\ue080"
menuItem.badgeContent = "icon"
} else if (badge == "gear") {
menuItem.badgeIcon = "\ue09a"
menuItem.badgeContent = "icon"
} else {
menuItem.badgeContent = ""
}
} else {
menuItem.badgeContent = ""
} }
}); });
} }
@ -353,6 +403,12 @@ Rectangle {
menuItem.title = pageTitle; menuItem.title = pageTitle;
}); });
webView.runJavaScript("try{document.querySelector(\"link[rel='icon']\").getAttribute(\"href\")}catch(e){}", function(sideIcon){
if(sideIcon){
menuItem.icon = webview.url + sideIcon;
};
});
webView.runJavaScript("try{document.querySelector(\"meta[name='ethereum-dapp-url-bar-style']\").getAttribute(\"content\")}catch(e){}", function(topBarStyle){ webView.runJavaScript("try{document.querySelector(\"meta[name='ethereum-dapp-url-bar-style']\").getAttribute(\"content\")}catch(e){}", function(topBarStyle){
if (!topBarStyle) { if (!topBarStyle) {
showFullUrlBar(true); showFullUrlBar(true);
@ -382,10 +438,15 @@ Rectangle {
}; };
}); });
webview.runJavaScript(eth.readFile("bignumber.min.js"));
webview.runJavaScript(eth.readFile("ethereum.js/dist/ethereum.js"));
var cleanTitle = webview.url.toString() var cleanTitle = webview.url.toString()
var matches = cleanTitle.match(/^[a-z]*\:\/\/([^\/?#]+)(?:[\/?#]|$)/i); var matches = cleanTitle.match(/^[a-z]*\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);
var domain = matches && matches[1]; var domain = matches && matches[1];
if (domain) if (domain)
appDomain.text = domain //webview.url.replace("a", "z") appDomain.text = domain //webview.url.replace("a", "z")
if (webview.title) if (webview.title)

View File

@ -85,35 +85,21 @@ Rectangle {
property var domain: "ethereum-dapp-catalog.meteor.com" property var domain: "ethereum-dapp-catalog.meteor.com"
url: protocol + domain url: protocol + domain
//navigationRequest: WebEngineView.IgnoreRequest //experimental.settings.javascriptCanAccessClipboard: true
// onLoadingChanged: {
// if (loadRequest.status == WebEngineView.LoadSucceededStatus) {
// webview.runJavaScript(eth.readFile("bignumber.min.js"));
// webview.runJavaScript(eth.readFile("ethereum.js/dist/ethereum.js"));
// }
// }
//onNavigationRequested: {
// 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
//}
//}
onJavaScriptConsoleMessage: { onJavaScriptConsoleMessage: {
console.log(sourceID + ":" + lineNumber + ":" + JSON.stringify(message)); console.log(sourceID + ":" + lineNumber + ":" + JSON.stringify(message));
} }
onNavigationRequested: { onNavigationRequested: {
// this checks if the domain of the requested link is the same as the catalog's
// If it is, it opens on the same window, if it's not it opens a new tab
var cleanTitle = request.url.toString() var cleanTitle = request.url.toString()
var matches = cleanTitle.match(/^[a-z]*\:\/\/([^\/?#]+)(?:[\/?#]|$)/i); var matches = cleanTitle.match(/^[a-z]*\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);
var requestedDomain = matches && matches[1]; var requestedDomain = matches && matches[1];
console.debug ("NavigationRequested: " + request.url + " navigationType=" + request.navigationType)
if(request.navigationType==0){ if(request.navigationType==0){
@ -126,10 +112,18 @@ Rectangle {
} }
} }
// onLoadingChanged: {
// if (loadRequest.status == WebEngineView.LoadSucceededStatus) {
// webview.runJavaScript(eth.readFile("mist.js"));
// }
// }
} }
WebEngineView { WebEngineView {
id: inspector id: inspector
visible: false visible: false
@ -137,6 +131,7 @@ Rectangle {
anchors { anchors {
left: root.left left: root.left
right: root.right right: root.right
top: root.top
bottom: root.bottom bottom: root.bottom
} }

View File

@ -9,7 +9,7 @@ import Ethereum 1.0
Rectangle { Rectangle {
id: root id: root
property var title: "Miner" property var title: "Miner"
property var iconSource: "../miner.png" property var iconSource: "../mining-icon.png"
property var menuItem property var menuItem
color: "#00000000" color: "#00000000"

View File

@ -9,7 +9,6 @@ import Ethereum 1.0
Rectangle { Rectangle {
id: root id: root
property var title: "Wallet" property var title: "Wallet"
property var iconSource: "../facet.png"
property var menuItem property var menuItem
objectName: "walletView" objectName: "walletView"