abstract message sending from the view
This commit is contained in:
parent
03b6209f6b
commit
b8563b25a3
|
@ -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.} =
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue