move block notification to node management tab

This commit is contained in:
Iuri Matias 2020-05-19 16:53:11 -04:00
parent 959f8277ce
commit 755fd6056b
6 changed files with 39 additions and 35 deletions

View File

@ -1,8 +1,9 @@
import NimQml import NimQml
import "../../status/core" as status import "../../status/core" as status
import ../signals/types
import nodeView import nodeView
type NodeController* = ref object type NodeController* = ref object of SignalSubscriber
view*: NodeView view*: NodeView
variant*: QVariant variant*: QVariant
@ -21,3 +22,8 @@ proc delete*(self: NodeController) =
proc init*(self: NodeController) = proc init*(self: NodeController) =
discard discard
method onSignal(self: NodeController, data: Signal) =
echo "new signal received"
var msg = cast[WalletSignal](data)
self.view.setLastMessage(msg.content)

View File

@ -4,6 +4,7 @@ QtObject:
type NodeView* = ref object of QObject type NodeView* = ref object of QObject
callResult: string callResult: string
sendRPCMessage: proc (msg: string): string sendRPCMessage: proc (msg: string): string
lastMessage*: string
proc setup(self: NodeView) = proc setup(self: NodeView) =
self.QObject.setup self.QObject.setup
@ -12,6 +13,7 @@ QtObject:
new(result) new(result)
result.sendRPCMessage = sendRPCMessage result.sendRPCMessage = sendRPCMessage
result.callResult = "Use this tool to call JSONRPC methods" result.callResult = "Use this tool to call JSONRPC methods"
result.lastMessage = ""
result.setup result.setup
proc delete*(self: NodeView) = proc delete*(self: NodeView) =
@ -41,3 +43,17 @@ QtObject:
proc onMessage*(self: NodeView, message: string) {.slot.} = proc onMessage*(self: NodeView, message: string) {.slot.} =
self.setCallResult(message) self.setCallResult(message)
echo "Received message: ", message echo "Received message: ", message
proc lastMessage*(self: NodeView): string {.slot.} =
result = self.lastMessage
proc receivedMessage*(self: NodeView, lastMessage: string) {.signal.}
proc setLastMessage*(self: NodeView, lastMessage: string) {.slot.} =
self.lastMessage = lastMessage
self.receivedMessage(lastMessage)
QtProperty[string] lastMessage:
read = lastMessage
write = setLastMessage
notify = receivedMessage

View File

@ -43,7 +43,3 @@ proc init*(self: WalletController) =
let symbol = "ETH" let symbol = "ETH"
self.view.addAssetToList("Ethereum", symbol, fmt"{eth_value:.6}", "$" & fmt"{usd_balance:.6}", fmt"../../img/token-icons/{toLowerAscii(symbol)}.svg") self.view.addAssetToList("Ethereum", symbol, fmt"{eth_value:.6}", "$" & fmt"{usd_balance:.6}", fmt"../../img/token-icons/{toLowerAscii(symbol)}.svg")
method onSignal(self: WalletController, data: Signal) =
var msg = cast[WalletSignal](data)
self.view.setLastMessage(msg.content)

View File

@ -17,7 +17,6 @@ QtObject:
type type
WalletView* = ref object of QAbstractListModel WalletView* = ref object of QAbstractListModel
assets*: seq[Asset] assets*: seq[Asset]
lastMessage*: string
defaultAccount: string defaultAccount: string
sendTransaction: proc(from_value: string, to: string, value: string, password: string): string sendTransaction: proc(from_value: string, to: string, value: string, password: string): string
@ -35,7 +34,6 @@ QtObject:
new(result, delete) new(result, delete)
result.sendTransaction = sendTransaction result.sendTransaction = sendTransaction
result.assets = @[] result.assets = @[]
result.lastMessage = ""
result.setup result.setup
proc addAssetToList*(self: WalletView, name: string, symbol: string, value: string, fiatValue: string, image: string) {.slot.} = proc addAssetToList*(self: WalletView, name: string, symbol: string, value: string, fiatValue: string, image: string) {.slot.} =
@ -80,20 +78,3 @@ QtObject:
AssetRoles.Value.int:"value", AssetRoles.Value.int:"value",
AssetRoles.FiatValue.int:"fiatValue", AssetRoles.FiatValue.int:"fiatValue",
AssetRoles.Image.int:"image" }.toTable AssetRoles.Image.int:"image" }.toTable
proc lastMessage*(self: WalletView): string {.slot.} =
result = self.lastMessage
proc receivedMessage*(self: WalletView, lastMessage: string) {.signal.}
proc setLastMessage*(self: WalletView, lastMessage: string) {.slot.} =
self.lastMessage = lastMessage
self.receivedMessage(lastMessage)
QtProperty[string] lastMessage:
read = lastMessage
write = setLastMessage
notify = receivedMessage

View File

@ -29,6 +29,21 @@ SplitView {
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: 0 anchors.topMargin: 0
RowLayout {
id: messageContainer
Layout.fillHeight: true
Text {
id: test
color: Theme.lightBlueText
text: nodeModel.lastMessage
Layout.fillWidth: true
anchors.left: walletAmountValue.right
anchors.leftMargin: 5
font.weight: Font.Medium
font.pixelSize: 30
}
}
RowLayout { RowLayout {
id: resultContainer id: resultContainer
Layout.fillHeight: true Layout.fillHeight: true

View File

@ -73,16 +73,6 @@ ColumnLayout {
} }
} }
Text {
id: test
color: Theme.lightBlueText
text: assetsModel.lastMessage
anchors.left: walletAmountValue.right
anchors.leftMargin: 5
font.weight: Font.Medium
font.pixelSize: 30
}
TabBar { TabBar {
readonly property int btnHeight: 56 readonly property int btnHeight: 56