2020-05-06 17:40:00 +00:00
|
|
|
import NimQml
|
2020-05-11 18:22:01 +00:00
|
|
|
import applicationView
|
2020-05-08 22:04:53 +00:00
|
|
|
import chats
|
2020-05-08 22:12:32 +00:00
|
|
|
import state
|
2020-05-11 17:31:07 +00:00
|
|
|
import status
|
|
|
|
|
2020-05-06 17:40:00 +00:00
|
|
|
proc mainProc() =
|
2020-05-10 23:24:06 +00:00
|
|
|
# From QT docs:
|
2020-05-11 21:24:08 +00:00
|
|
|
# For any GUI application using Qt, there is precisely one QApplication object,
|
|
|
|
# no matter whether the application has 0, 1, 2 or more windows at any given time.
|
|
|
|
# For non-QWidget based Qt applications, use QGuiApplication instead, as it does
|
2020-05-10 23:24:06 +00:00
|
|
|
# not depend on the QtWidgets library. Use QCoreApplication for non GUI apps
|
|
|
|
var app = newQApplication()
|
2020-05-11 21:24:08 +00:00
|
|
|
defer: app.delete() # Defer will run this just before mainProc() function ends
|
2020-05-06 17:40:00 +00:00
|
|
|
|
2020-05-08 22:04:53 +00:00
|
|
|
var chatsModel = newChatsModel();
|
|
|
|
defer: chatsModel.delete
|
|
|
|
|
2020-05-06 17:40:00 +00:00
|
|
|
var engine = newQQmlApplicationEngine()
|
|
|
|
defer: engine.delete()
|
|
|
|
|
2020-05-11 20:58:59 +00:00
|
|
|
status.setSignalHandler()
|
2020-05-11 17:31:07 +00:00
|
|
|
|
|
|
|
status.setupNewAccount()
|
|
|
|
discard status.addPeer("enode://2c8de3cbb27a3d30cbb5b3e003bc722b126f5aef82e2052aaef032ca94e0c7ad219e533ba88c70585ebd802de206693255335b100307645ab5170e88620d2a81@47.244.221.14:443")
|
|
|
|
echo status.callPrivateRPC("{\"jsonrpc\":\"2.0\", \"method\":\"wakuext_requestMessages\", \"params\":[{\"topics\": [\"0x7998f3c8\"]}], \"id\": 1}")
|
|
|
|
|
|
|
|
# result.accountResult = status.queryAccounts()
|
|
|
|
status.subscribeToTest()
|
|
|
|
|
2020-05-11 18:22:01 +00:00
|
|
|
let logic = newApplicationView(app, status.callPrivateRPC)
|
2020-05-10 23:24:06 +00:00
|
|
|
defer: logic.delete
|
2020-05-11 21:24:08 +00:00
|
|
|
|
2020-05-06 17:40:00 +00:00
|
|
|
let logicVariant = newQVariant(logic)
|
|
|
|
defer: logicVariant.delete
|
|
|
|
|
2020-05-08 22:04:53 +00:00
|
|
|
let chatsVariant = newQVariant(chatsModel)
|
|
|
|
defer: chatsVariant.delete
|
2020-05-08 22:12:32 +00:00
|
|
|
|
|
|
|
var appState = state.newAppState()
|
|
|
|
echo appState.title
|
|
|
|
|
|
|
|
appState.subscribe(proc () =
|
|
|
|
chatsModel.names = @[]
|
|
|
|
for channel in appState.channels:
|
|
|
|
echo channel.name
|
|
|
|
chatsModel.addNameTolist(channel.name)
|
|
|
|
)
|
|
|
|
|
|
|
|
appState.addChannel("test")
|
|
|
|
appState.addChannel("test2")
|
2020-05-08 22:04:53 +00:00
|
|
|
|
2020-05-06 17:40:00 +00:00
|
|
|
engine.setRootContextProperty("logic", logicVariant)
|
2020-05-08 22:04:53 +00:00
|
|
|
engine.setRootContextProperty("chatsModel", chatsVariant)
|
2020-05-11 21:24:08 +00:00
|
|
|
engine.load("../ui/main.qml")
|
|
|
|
|
2020-05-10 23:24:06 +00:00
|
|
|
# Qt main event loop is entered here
|
|
|
|
# The termination of the loop will be performed when exit() or quit() is called
|
2020-05-06 17:40:00 +00:00
|
|
|
app.exec()
|
|
|
|
|
|
|
|
when isMainModule:
|
|
|
|
mainProc()
|
|
|
|
GC_fullcollect()
|