diff --git a/src/app/node/core.nim b/src/app/node/core.nim index 01091ac29d..9d64aad82b 100644 --- a/src/app/node/core.nim +++ b/src/app/node/core.nim @@ -1,8 +1,9 @@ import NimQml import "../../status/core" as status +import ../signals/types import nodeView -type NodeController* = ref object +type NodeController* = ref object of SignalSubscriber view*: NodeView variant*: QVariant @@ -21,3 +22,8 @@ proc delete*(self: NodeController) = proc init*(self: NodeController) = discard + +method onSignal(self: NodeController, data: Signal) = + echo "new signal received" + var msg = cast[WalletSignal](data) + self.view.setLastMessage(msg.content) diff --git a/src/app/node/nodeView.nim b/src/app/node/nodeView.nim index 5773846695..c7e6a3e7e1 100644 --- a/src/app/node/nodeView.nim +++ b/src/app/node/nodeView.nim @@ -4,6 +4,7 @@ QtObject: type NodeView* = ref object of QObject callResult: string sendRPCMessage: proc (msg: string): string + lastMessage*: string proc setup(self: NodeView) = self.QObject.setup @@ -12,6 +13,7 @@ QtObject: new(result) result.sendRPCMessage = sendRPCMessage result.callResult = "Use this tool to call JSONRPC methods" + result.lastMessage = "" result.setup proc delete*(self: NodeView) = @@ -41,3 +43,17 @@ QtObject: proc onMessage*(self: NodeView, message: string) {.slot.} = self.setCallResult(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 diff --git a/src/app/wallet/core.nim b/src/app/wallet/core.nim index 1720d7ce02..b31dbfb705 100644 --- a/src/app/wallet/core.nim +++ b/src/app/wallet/core.nim @@ -43,7 +43,3 @@ proc init*(self: WalletController) = let symbol = "ETH" 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) \ No newline at end of file diff --git a/src/app/wallet/walletView.nim b/src/app/wallet/walletView.nim index a764f58124..53325f1f1e 100644 --- a/src/app/wallet/walletView.nim +++ b/src/app/wallet/walletView.nim @@ -17,7 +17,6 @@ QtObject: type WalletView* = ref object of QAbstractListModel assets*: seq[Asset] - lastMessage*: string defaultAccount: string sendTransaction: proc(from_value: string, to: string, value: string, password: string): string @@ -35,9 +34,8 @@ QtObject: new(result, delete) result.sendTransaction = sendTransaction result.assets = @[] - result.lastMessage = "" result.setup - + proc addAssetToList*(self: WalletView, name: string, symbol: string, value: string, fiatValue: string, image: string) {.slot.} = self.beginInsertRows(newQModelIndex(), self.assets.len, self.assets.len) self.assets.add(Asset(name : name, @@ -80,20 +78,3 @@ QtObject: AssetRoles.Value.int:"value", AssetRoles.FiatValue.int:"fiatValue", 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 diff --git a/ui/app/AppLayouts/NodeLayout.qml b/ui/app/AppLayouts/NodeLayout.qml index de06e61cc2..abdca0a360 100644 --- a/ui/app/AppLayouts/NodeLayout.qml +++ b/ui/app/AppLayouts/NodeLayout.qml @@ -29,6 +29,21 @@ SplitView { anchors.top: parent.top 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 { id: resultContainer Layout.fillHeight: true diff --git a/ui/app/AppLayouts/Wallet/LeftTab.qml b/ui/app/AppLayouts/Wallet/LeftTab.qml index f54341b814..f61ac069f0 100644 --- a/ui/app/AppLayouts/Wallet/LeftTab.qml +++ b/ui/app/AppLayouts/Wallet/LeftTab.qml @@ -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 { readonly property int btnHeight: 56