mirror of https://github.com/status-im/nimqml.git
feat: QGuiApplication supporting icon() and installEventFilter() methods as well as passing argc, argv
This commit is contained in:
parent
65fa68c244
commit
6a5f0ef32e
|
@ -138,10 +138,12 @@ proc dos_qapplication_clipboard_setText(content: cstring) {.cdecl, dynlib: dynLi
|
|||
proc dos_qapplication_installEventFilter(engine: DosQQmlApplicationEngine) {.cdecl, dynlib: dynLibName, importc.}
|
||||
|
||||
# QGuiApplication
|
||||
proc dos_qguiapplication_create() {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_qguiapplication_create(argc: cint, argv: cstringArray) {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_qguiapplication_exec() {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_qguiapplication_quit() {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_qguiapplication_icon(filename: cstring) {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_qguiapplication_delete() {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_qguiapplication_installEventFilter(engine: DosQQmlApplicationEngine) {.cdecl, dynlib: dynLibName, importc.}
|
||||
|
||||
# QQmlContext
|
||||
proc dos_qqmlcontext_setcontextproperty(context: DosQQmlContext, propertyName: cstring, propertyValue: DosQVariant) {.cdecl, dynlib: dynLibName, importc.}
|
||||
|
|
|
@ -1,18 +1,32 @@
|
|||
import os
|
||||
|
||||
proc setup*(self: QGuiApplication) =
|
||||
## Setup a new QApplication
|
||||
dos_qguiapplication_create()
|
||||
## Setup a new QGuiApplication
|
||||
var argv = allocCStringArray([])
|
||||
argv[0] = getAppFilename().cstring
|
||||
for argi in 1..paramCount():
|
||||
argv[argi] = paramStr(argi).cstring
|
||||
|
||||
var argc = paramCount() + 1
|
||||
dos_qguiapplication_create(argc.cint, argv)
|
||||
self.deleted = false
|
||||
|
||||
proc delete*(self: QGuiApplication) =
|
||||
## Delete the given QApplication
|
||||
## Delete the given QGuiApplication
|
||||
if self.deleted:
|
||||
return
|
||||
debugMsg("QApplication", "delete")
|
||||
debugMsg("QGuiApplication", "delete")
|
||||
dos_qguiapplication_delete()
|
||||
self.deleted = true
|
||||
|
||||
proc icon*(application: QGuiApplication, filename: string) =
|
||||
dos_qguiapplication_icon(filename.cstring)
|
||||
|
||||
proc installEventFilter*(application: QGuiApplication, engine: QQmlApplicationEngine) =
|
||||
dos_qguiapplication_installEventFilter(engine.vptr)
|
||||
|
||||
proc newQGuiApplication*(): QGuiApplication =
|
||||
## Return a new QApplication
|
||||
## Return a new QGuiApplication
|
||||
new(result, delete)
|
||||
result.setup()
|
||||
|
||||
|
|
Loading…
Reference in New Issue