2020-05-06 17:40:00 +00:00
|
|
|
import NimQml
|
|
|
|
import applicationLogic
|
2020-05-08 22:04:53 +00:00
|
|
|
import chats
|
2020-05-06 17:40:00 +00:00
|
|
|
|
|
|
|
proc mainProc() =
|
|
|
|
|
2020-05-10 23:24:06 +00:00
|
|
|
# From QT docs:
|
|
|
|
# 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
|
|
|
|
# not depend on the QtWidgets library. Use QCoreApplication for non GUI apps
|
|
|
|
var app = newQApplication()
|
|
|
|
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-10 23:24:06 +00:00
|
|
|
|
|
|
|
let logic = newApplicationLogic(app)
|
|
|
|
defer: logic.delete
|
|
|
|
|
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
|
|
|
|
chatsModel.addNameTolist("hello")
|
|
|
|
|
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-06 17:40:00 +00:00
|
|
|
engine.load("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()
|