diff options
author | obscuren <geffobscura@gmail.com> | 2015-02-21 01:13:46 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-02-21 01:13:46 +0800 |
commit | bd7ebbcd5b77ce4fdd471b44f0acda80f2b3ceca (patch) | |
tree | 46ab5943fd5e26198067aeec4a44287452eb2a32 /cmd/mist/assets/qml/views | |
parent | 771bfe9e78f9952002a71cccc8d41c8c544fdfcb (diff) | |
parent | d586a633ff005ac01c9f1eb33552d147cf6c883e (diff) | |
download | go-tangerine-bd7ebbcd5b77ce4fdd471b44f0acda80f2b3ceca.tar.gz go-tangerine-bd7ebbcd5b77ce4fdd471b44f0acda80f2b3ceca.tar.zst go-tangerine-bd7ebbcd5b77ce4fdd471b44f0acda80f2b3ceca.zip |
Merge branch 'release/0.9.0'
Diffstat (limited to 'cmd/mist/assets/qml/views')
-rw-r--r-- | cmd/mist/assets/qml/views/browser.qml | 506 | ||||
-rw-r--r-- | cmd/mist/assets/qml/views/catalog.qml | 144 | ||||
-rw-r--r-- | cmd/mist/assets/qml/views/chain.qml | 2 | ||||
-rw-r--r-- | cmd/mist/assets/qml/views/info.qml | 14 | ||||
-rw-r--r-- | cmd/mist/assets/qml/views/miner.qml | 42 | ||||
-rw-r--r-- | cmd/mist/assets/qml/views/pending_tx.qml | 9 | ||||
-rw-r--r-- | cmd/mist/assets/qml/views/transaction.qml | 4 | ||||
-rw-r--r-- | cmd/mist/assets/qml/views/wallet.qml | 28 | ||||
-rw-r--r-- | cmd/mist/assets/qml/views/whisper.qml | 74 |
9 files changed, 793 insertions, 30 deletions
diff --git a/cmd/mist/assets/qml/views/browser.qml b/cmd/mist/assets/qml/views/browser.qml new file mode 100644 index 000000000..edecc8696 --- /dev/null +++ b/cmd/mist/assets/qml/views/browser.qml @@ -0,0 +1,506 @@ +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: "../browser.png" + 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; + } + } + + function showFullUrlBar(on){ + if (uriNav.focus == false ) { + if (on == false) { + clickAnywhereOnApp.visible = false + navBar.state = "titleVisible" + } else { + clickAnywhereOnApp.visible = true + navBar.state = "fullUrlVisible" + } + } + + } + + Component.onCompleted: { + } + + Item { + objectName: "root" + id: root + anchors { + fill: parent + } + + state: "inspectorShown" + + MouseArea { + id: clickAnywhereOnApp + z:15 + // Using a secondary screen to catch on mouse exits for the area, because + // there are many hover actions conflicting + + anchors { + top: parent.top + topMargin: 50 + right: parent.right + bottom: parent.bottom + left: parent.left + } + hoverEnabled: true + + onEntered: { + showFullUrlBar(false); + } + + onClicked: { + uriNav.focus = false + showFullUrlBar(false); + } + + // Rectangle { + // anchors.fill: parent + // color: "#88888888" + // } + } + + RowLayout { + id: navBar + height: 74 + z: 20 + anchors { + left: parent.left + right: parent.right + } + + Button { + id: back + z: 30 + onClicked: { + webview.goBack() + } + + anchors { + left: parent.left + leftMargin: 6 + } + + style: ButtonStyle { + background: Image { + source: (webview.canGoBack) ? + (control.hovered ? "../../backButtonHover.png" : "../../backButton.png") : + "../../backButtonDisabled.png" + width: 20 + height: 30 + } + } + } + + Rectangle { + id: appInfoPane + height: 28 + color: "#FFFFFF" + radius: 6 + z:2 + MouseArea { + anchors.fill: parent + z: 10 + hoverEnabled: true + + onEntered: { + showFullUrlBar(true); + } + /*onExited: { + showFullUrlBar(false); + }*/ + + } + + anchors { + left: back.right + right: parent.right + leftMargin: 10 + rightMargin: 10 + } + + Text { + id: appTitle + text: "LOADING" + font.bold: true + font.capitalization: Font.AllUppercase + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + + anchors { + left: parent.left + right: parent.horizontalCenter + top: parent.top + bottom: parent.bottom + leftMargin: 32 + } + color: "#928484" + } + + Text { + id: appDomain + text: "loading domain" + font.bold: false + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + elide: Text.ElideLeft + + anchors { + left: parent.horizontalCenter + right: parent.right + top: parent.top + bottom: parent.bottom + leftMargin: 32 + + } + 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: { + // 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; + } + } + + + } + + Rectangle { + id: appInfoPaneShadow + width: 10 + height: 30 + color: "#BDB6B6" + radius: 6 + z:1 + + anchors { + left: back.right + right: parent.right + leftMargin:10 + rightMargin:10 + top: parent.top + topMargin: 23 + } + } + + Rectangle { + id: navBarBackground + anchors.fill: parent + z:-1 + gradient: Gradient { + GradientStop { position: 0.0; color: "#F6F1F2" } + GradientStop { position: 1.0; color: "#DED5D5" } + } + } + + 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 { + objectName: "webView" + id: webview + experimental.settings.javascriptCanAccessClipboard: true + //experimental.settings.localContentCanAccessRemoteUrls: true + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + top: navBar.bottom + } + z: 10 + + Timer { + interval: 2000; running: true; repeat: true + onTriggered: { + 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 (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 = "" + } + }); + } + } + + onLoadingChanged: { + if (loadRequest.status == WebEngineView.LoadSucceededStatus) { + + webview.runJavaScript("document.title", function(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){ + if (!topBarStyle) { + showFullUrlBar(true); + navBarBackground.visible = true; + back.visible = true; + appInfoPane.anchors.leftMargin = 0; + appInfoPaneShadow.anchors.leftMargin = 0; + webview.anchors.topMargin = 0; + return; + } + + 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')") + + } else { + navBarBackground.visible = true; + back.visible = true; + appInfoPane.anchors.leftMargin = 0; + appInfoPaneShadow.anchors.leftMargin = 0; + webview.anchors.topMargin = 0; + }; + }); + + + webview.runJavaScript(eth.readFile("bignumber.min.js")); + webview.runJavaScript(eth.readFile("ethereum.js/dist/ethereum.js")); + webview.runJavaScript(eth.readFile("mist.js")); + + var cleanTitle = webview.url.toString() + var matches = cleanTitle.match(/^[a-z]*\:\/\/([^\/?#]+)(?:[\/?#]|$)/i); + var domain = matches && matches[1]; + + + if (domain) + appDomain.text = domain //webview.url.replace("a", "z") + if (webview.title) + appTitle.text = webview.title + + showFullUrlBar(false); + } + } + onJavaScriptConsoleMessage: { + console.log(sourceID + ":" + lineNumber + ":" + JSON.stringify(message)); + } + } + + Rectangle { + id: sizeGrip + color: "gray" + visible: false + height: 10 + anchors { + left: root.left + right: root.right + } + y: Math.round(root.height * 2 / 3) + + MouseArea { + anchors.fill: parent + drag.target: sizeGrip + drag.minimumY: 0 + drag.maximumY: root.height + drag.axis: Drag.YAxis + } + } + + WebEngineView { + id: inspector + visible: false + anchors { + left: root.left + right: root.right + top: sizeGrip.bottom + bottom: root.bottom + } + + } + + states: [ + State { + name: "inspectorShown" + PropertyChanges { + target: inspector + } + } + ] + } +} diff --git a/cmd/mist/assets/qml/views/catalog.qml b/cmd/mist/assets/qml/views/catalog.qml new file mode 100644 index 000000000..29e133074 --- /dev/null +++ b/cmd/mist/assets/qml/views/catalog.qml @@ -0,0 +1,144 @@ +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: "Catalog" + 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; + } + } + + Item { + objectName: "root" + id: root + anchors.fill: parent + state: "inspectorShown" + + WebEngineView { + objectName: "webView" + id: webview + anchors.fill: parent + + property var protocol: "http://" + //property var domain: "localhost:3000" + property var domain: "ethereum-dapp-catalog.meteor.com" + url: protocol + domain + + experimental.settings.javascriptCanAccessClipboard: true + + + onJavaScriptConsoleMessage: { + console.log(sourceID + ":" + lineNumber + ":" + JSON.stringify(message)); + } + + 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 matches = cleanTitle.match(/^[a-z]*\:\/\/([^\/?#]+)(?:[\/?#]|$)/i); + var requestedDomain = matches && matches[1]; + + + if(request.navigationType==0){ + + if (requestedDomain === this.domain){ + request.action = WebEngineView.AcceptRequest; + } else { + request.action = WebEngineView.IgnoreRequest; + newBrowserTab(request.url); + } + + } + } + onLoadingChanged: { + if (loadRequest.status == WebEngineView.LoadSucceededStatus) { + webview.runJavaScript(eth.readFile("mist.js")); + } + } + } + + + + + + + WebEngineView { + id: inspector + visible: false + z:10 + anchors { + left: root.left + right: root.right + top: root.top + bottom: root.bottom + } + + } + + states: [ + State { + name: "inspectorShown" + PropertyChanges { + target: inspector + } + } + ] + } +} diff --git a/cmd/mist/assets/qml/views/chain.qml b/cmd/mist/assets/qml/views/chain.qml index 6baf757a5..4d1bc0e03 100644 --- a/cmd/mist/assets/qml/views/chain.qml +++ b/cmd/mist/assets/qml/views/chain.qml @@ -111,7 +111,7 @@ Rectangle { if(initial){ blockModel.append({raw: block.raw, bloom: block.bloom, size: block.size, number: block.number, name: block.name, gasLimit: block.gasLimit, gasUsed: block.gasUsed, coinbase: block.coinbase, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)}) } else { - blockModel.insert(0, {bloom: block.bloom, size: block.size, number: block.number, name: block.name, gasLimit: block.gasLimit, gasUsed: block.gasUsed, coinbase: block.coinbase, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)}) + blockModel.insert(0, {raw: block.raw, bloom: block.bloom, size: block.size, number: block.number, name: block.name, gasLimit: block.gasLimit, gasUsed: block.gasUsed, coinbase: block.coinbase, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)}) } } diff --git a/cmd/mist/assets/qml/views/info.qml b/cmd/mist/assets/qml/views/info.qml index 3ff551b05..b2d2f521c 100644 --- a/cmd/mist/assets/qml/views/info.qml +++ b/cmd/mist/assets/qml/views/info.qml @@ -28,22 +28,10 @@ Rectangle { text: "Address" } TextField { - text: eth.key().address + text: eth.coinbase() width: 500 } - Label { - text: "Client ID" - } - TextField { - text: gui.getCustomIdentifier() - width: 500 - placeholderText: "Anonymous" - onTextChanged: { - gui.setCustomIdentifier(text) - } - } - TextArea { objectName: "statsPane" width: parent.width diff --git a/cmd/mist/assets/qml/views/miner.qml b/cmd/mist/assets/qml/views/miner.qml index e0182649f..e239c7d7b 100644 --- a/cmd/mist/assets/qml/views/miner.qml +++ b/cmd/mist/assets/qml/views/miner.qml @@ -9,11 +9,32 @@ import Ethereum 1.0 Rectangle { id: root property var title: "Miner" - property var iconSource: "../miner.png" + property var iconSource: "../mining-icon.png" property var menuItem color: "#00000000" + Label { + visible: false + id: lastBlockLabel + objectName: "lastBlockLabel" + text: "---" + onTextChanged: { + //menuItem.secondaryTitle = text + } + } + + Label { + objectName: "miningLabel" + visible: false + font.pixelSize: 10 + anchors.right: lastBlockLabel.left + anchors.rightMargin: 5 + onTextChanged: { + menuItem.secondaryTitle = text + } + } + ColumnLayout { spacing: 10 anchors.fill: parent @@ -46,6 +67,7 @@ Rectangle { text: "Start" onClicked: { eth.setGasPrice(minGasPrice.text || "10000000000000"); + eth.setExtra(blockExtra.text) if (eth.toggleMining()) { this.text = "Stop"; } else { @@ -55,6 +77,7 @@ Rectangle { } Rectangle { + id: minGasPriceRect anchors.top: parent.top anchors.topMargin: 2 width: 200 @@ -65,6 +88,23 @@ Rectangle { validator: RegExpValidator { regExp: /\d*/ } } } + + Rectangle { + width: 300 + anchors { + left: minGasPriceRect.right + leftMargin: 5 + top: parent.top + topMargin: 2 + } + + TextField { + id: blockExtra + placeholderText: "Extra" + width: parent.width + maximumLength: 1024 + } + } } } diff --git a/cmd/mist/assets/qml/views/pending_tx.qml b/cmd/mist/assets/qml/views/pending_tx.qml index 4442a69db..3dcedeff2 100644 --- a/cmd/mist/assets/qml/views/pending_tx.qml +++ b/cmd/mist/assets/qml/views/pending_tx.qml @@ -41,4 +41,13 @@ Rectangle { pendingTxModel.insert(0, {hash: tx.hash, to: tx.address, from: tx.sender, value: tx.value, contract: isContract}) } + + function removeTx(tx) { + for (var i = 0; i < pendingTxModel.count; i++) { + if (tx.hash === pendingTxModel.get(i).hash) { + pendingTxModel.remove(i); + break; + } + } + } } diff --git a/cmd/mist/assets/qml/views/transaction.qml b/cmd/mist/assets/qml/views/transaction.qml index 62c762956..df798a9c0 100644 --- a/cmd/mist/assets/qml/views/transaction.qml +++ b/cmd/mist/assets/qml/views/transaction.qml @@ -103,7 +103,7 @@ Rectangle { ComboBox { id: valueDenom - currentIndex: 6 + currentIndex: 5 model: denomModel } } @@ -177,7 +177,7 @@ Rectangle { mainContractColumn.state = "ERROR" } else { txResult.text = "Your transaction has been submitted:\n" - txOutput.text = res[0].address + txOutput.text = res.toString() mainContractColumn.state = "DONE" console.log(res) diff --git a/cmd/mist/assets/qml/views/wallet.qml b/cmd/mist/assets/qml/views/wallet.qml index 9727ef35c..2369390c3 100644 --- a/cmd/mist/assets/qml/views/wallet.qml +++ b/cmd/mist/assets/qml/views/wallet.qml @@ -9,20 +9,28 @@ import Ethereum 1.0 Rectangle { id: root property var title: "Wallet" - property var iconSource: "../facet.png" property var menuItem objectName: "walletView" anchors.fill: parent + Label { + objectName: "balanceLabel" + visible: false + onTextChanged: { + balance.text = text + menuItem.secondaryTitle = text + } + } + function onReady() { setBalance() } function setBalance() { - balance.text = "<b>Balance</b>: " + eth.numberToHuman(eth.balanceAt(eth.key().address)) + balance.text = "<b>Balance</b>: " + eth.numberToHuman(eth.balanceAt(eth.coinbase())) if(menuItem) - menuItem.secondaryTitle = eth.numberToHuman(eth.balanceAt(eth.key().address)) + menuItem.secondaryTitle = eth.numberToHuman(eth.balanceAt(eth.coinbase())) } ListModel { @@ -95,7 +103,7 @@ Rectangle { ComboBox { id: valueDenom - currentIndex: 6 + currentIndex: 5 model: denomModel } @@ -130,7 +138,7 @@ Rectangle { onClicked: { var value = txValue.text + denomModel.get(valueDenom.currentIndex).zeros; var gasPrice = "10000000000000" - var res = eth.transact({from: eth.key().privateKey, to: txTo.text, value: value, gas: "500", gasPrice: gasPrice}) + var res = eth.transact({from: eth.coinbase(), to: txTo.text, value: value, gas: "500", gasPrice: gasPrice}) } } } @@ -155,17 +163,10 @@ Rectangle { model: ListModel { id: txModel Component.onCompleted: { - var me = eth.key().address; - var filterTo = ethx.watch({latest: -1, to: me}); - var filterFrom = ethx.watch({latest: -1, from: me}); - filterTo.changed(addTxs) - filterFrom.changed(addTxs) - - addTxs(filterTo.messages()) - addTxs(filterFrom.messages()) } function addTxs(messages) { + /* setBalance() for(var i = 0; i < messages.length; i++) { @@ -179,6 +180,7 @@ Rectangle { } txModel.insert(0, {num: txModel.count, from: from, to: to, value: eth.numberToHuman(message.value)}) } + */ } } } diff --git a/cmd/mist/assets/qml/views/whisper.qml b/cmd/mist/assets/qml/views/whisper.qml new file mode 100644 index 000000000..dc097b806 --- /dev/null +++ b/cmd/mist/assets/qml/views/whisper.qml @@ -0,0 +1,74 @@ + +import QtQuick 2.0 +import QtQuick.Controls 1.0; +import QtQuick.Layouts 1.0; +import QtQuick.Dialogs 1.0; +import QtQuick.Window 2.1; +import QtQuick.Controls.Styles 1.1 +import Ethereum 1.0 + +Rectangle { + id: root + property var title: "Whisper Traffic" + property var menuItem + + objectName: "whisperView" + anchors.fill: parent + + property var identity: "" + Component.onCompleted: { + identity = shh.newIdentity() + + var t = shh.watch({}, root) + } + + function onShhMessage(message, i) { + whisperModel.insert(0, {from: message.from, payload: eth.toAscii(message.payload)}) + } + + RowLayout { + id: input + anchors { + left: parent.left + leftMargin: 20 + top: parent.top + topMargin: 20 + } + + TextField { + id: to + placeholderText: "To" + } + TextField { + id: data + placeholderText: "Data" + } + TextField { + id: topics + placeholderText: "topic1, topic2, topic3, ..." + } + Button { + text: "Send" + onClicked: { + shh.post([eth.toHex(data.text)], "", identity, topics.text.split(","), 500, 50) + } + } + } + + TableView { + id: txTableView + anchors { + top: input.bottom + topMargin: 10 + bottom: parent.bottom + left: parent.left + right: parent.right + } + TableViewColumn{ id: fromRole; role: "from" ; title: "From"; width: 300 } + TableViewColumn{ role: "payload" ; title: "Payload" ; width: parent.width - fromRole.width - 2 } + + model: ListModel { + id: whisperModel + } + } +} |