abstract message sending from the view
This commit is contained in:
parent
03b6209f6b
commit
b8563b25a3
|
@ -1,7 +1,4 @@
|
||||||
import NimQml
|
import NimQml
|
||||||
# import status
|
|
||||||
# import libstatus
|
|
||||||
import json
|
|
||||||
|
|
||||||
# Probably all QT classes will look like this:
|
# Probably all QT classes will look like this:
|
||||||
QtObject:
|
QtObject:
|
||||||
|
@ -9,12 +6,14 @@ QtObject:
|
||||||
app: QApplication
|
app: QApplication
|
||||||
callResult: string
|
callResult: string
|
||||||
accountResult: string
|
accountResult: string
|
||||||
|
sendMessage: proc (msg: string): string
|
||||||
# chats: seq[ChatView]
|
# chats: seq[ChatView]
|
||||||
|
|
||||||
# Constructor
|
# Constructor
|
||||||
proc newApplicationLogic*(app: QApplication): ApplicationLogic =
|
proc newApplicationLogic*(app: QApplication, sendMessage: proc): ApplicationLogic =
|
||||||
new(result)
|
new(result)
|
||||||
result.app = app
|
result.app = app
|
||||||
|
result.sendMessage = sendMessage
|
||||||
result.callResult = "Use this tool to call JSONRPC methods"
|
result.callResult = "Use this tool to call JSONRPC methods"
|
||||||
result.setup()
|
result.setup()
|
||||||
|
|
||||||
|
@ -33,7 +32,6 @@ QtObject:
|
||||||
proc onExitTriggered(self: ApplicationLogic) {.slot.} =
|
proc onExitTriggered(self: ApplicationLogic) {.slot.} =
|
||||||
self.app.quit
|
self.app.quit
|
||||||
|
|
||||||
|
|
||||||
# Accesors
|
# Accesors
|
||||||
proc callResult*(self: ApplicationLogic): string {.slot.} =
|
proc callResult*(self: ApplicationLogic): string {.slot.} =
|
||||||
result = self.callResult
|
result = self.callResult
|
||||||
|
@ -54,7 +52,7 @@ QtObject:
|
||||||
notify = callResultChanged
|
notify = callResultChanged
|
||||||
|
|
||||||
proc onSend*(self: ApplicationLogic, inputJSON: string) {.slot.} =
|
proc onSend*(self: ApplicationLogic, inputJSON: string) {.slot.} =
|
||||||
# self.setCallResult(status.callPrivateRPC(inputJSON))
|
self.setCallResult(self.sendMessage(inputJSON))
|
||||||
echo "Done!: ", self.callResult
|
echo "Done!: ", self.callResult
|
||||||
|
|
||||||
# proc onMessage*(self: ApplicationLogic, message: string) {.slot.} =
|
# proc onMessage*(self: ApplicationLogic, message: string) {.slot.} =
|
||||||
|
|
|
@ -41,9 +41,7 @@ proc mainProc() =
|
||||||
# result.accountResult = status.queryAccounts()
|
# result.accountResult = status.queryAccounts()
|
||||||
status.subscribeToTest()
|
status.subscribeToTest()
|
||||||
|
|
||||||
|
let logic = newApplicationLogic(app, status.callPrivateRPC)
|
||||||
|
|
||||||
let logic = newApplicationLogic(app)
|
|
||||||
defer: logic.delete
|
defer: logic.delete
|
||||||
|
|
||||||
let logicVariant = newQVariant(logic)
|
let logicVariant = newQVariant(logic)
|
||||||
|
|
Loading…
Reference in New Issue