abstract message sending from the view

This commit is contained in:
Iuri Matias 2020-05-11 14:01:03 -04:00
parent 03b6209f6b
commit b8563b25a3
2 changed files with 5 additions and 9 deletions

View File

@ -1,7 +1,4 @@
import NimQml
# import status
# import libstatus
import json
# Probably all QT classes will look like this:
QtObject:
@ -9,12 +6,14 @@ QtObject:
app: QApplication
callResult: string
accountResult: string
sendMessage: proc (msg: string): string
# chats: seq[ChatView]
# Constructor
proc newApplicationLogic*(app: QApplication): ApplicationLogic =
proc newApplicationLogic*(app: QApplication, sendMessage: proc): ApplicationLogic =
new(result)
result.app = app
result.sendMessage = sendMessage
result.callResult = "Use this tool to call JSONRPC methods"
result.setup()
@ -33,7 +32,6 @@ QtObject:
proc onExitTriggered(self: ApplicationLogic) {.slot.} =
self.app.quit
# Accesors
proc callResult*(self: ApplicationLogic): string {.slot.} =
result = self.callResult
@ -54,7 +52,7 @@ QtObject:
notify = callResultChanged
proc onSend*(self: ApplicationLogic, inputJSON: string) {.slot.} =
# self.setCallResult(status.callPrivateRPC(inputJSON))
self.setCallResult(self.sendMessage(inputJSON))
echo "Done!: ", self.callResult
# proc onMessage*(self: ApplicationLogic, message: string) {.slot.} =

View File

@ -41,9 +41,7 @@ proc mainProc() =
# result.accountResult = status.queryAccounts()
status.subscribeToTest()
let logic = newApplicationLogic(app)
let logic = newApplicationLogic(app, status.callPrivateRPC)
defer: logic.delete
let logicVariant = newQVariant(logic)