Added support for QApplication

This commit is contained in:
Filippo Cucchetto 2016-02-11 23:56:55 +01:00
parent 52205c42b5
commit ce498eaa70
4 changed files with 19 additions and 12 deletions

View File

@ -17,6 +17,7 @@ include private/qmetaobject.nim
include private/qvariant.nim include private/qvariant.nim
include private/qobject.nim include private/qobject.nim
include private/qqmlapplicationengine.nim include private/qqmlapplicationengine.nim
include private/qapplication.nim
#include private.nimqmltypes #include private.nimqmltypes
#var qobjectRegistry = initTable[ptr QObjectObj, bool]() #var qobjectRegistry = initTable[ptr QObjectObj, bool]()
#include private/qvariant.nim #include private/qvariant.nim

View File

@ -46,6 +46,12 @@ type
proc resetToNil*[T](x: var T) = x = nil.pointer.T proc resetToNil*[T](x: var T) = x = nil.pointer.T
proc isNil*[T](x: T): bool = x.pointer == nil proc isNil*[T](x: T): bool = x.pointer == nil
# QApplication
proc dos_qapplication_create() {.cdecl, importc.}
proc dos_qapplication_exec() {.cdecl, importc.}
proc dos_qapplication_quit() {.cdecl, importc.}
proc dos_qapplication_delete() {.cdecl, importc.}
# QQmlContext # QQmlContext
proc dos_qqmlcontext_setcontextproperty(context: DosQQmlContext, propertyName: cstring, propertyValue: DosQVariant) {.cdecl, importc.} proc dos_qqmlcontext_setcontextproperty(context: DosQQmlContext, propertyName: cstring, propertyValue: DosQVariant) {.cdecl, importc.}

View File

@ -11,6 +11,10 @@ type
## A QQmlApplicationEngine ## A QQmlApplicationEngine
vptr: DosQQmlApplicationEngine vptr: DosQQmlApplicationEngine
QApplication = ref object of RootObj ## \
## A QApplication
deleted: bool
QtItemFlag* {.pure.} = enum ## \ QtItemFlag* {.pure.} = enum ## \
## Item flags ## Item flags
## ##

View File

@ -1,10 +1,5 @@
proc dos_qapplication_create() {.cdecl, importc.} proc setup*(application: QApplication) =
proc dos_qapplication_exec() {.cdecl, importc.} ## Setup a new QApplication
proc dos_qapplication_quit() {.cdecl, importc.}
proc dos_qapplication_delete() {.cdecl, importc.}
proc create*(application: QApplication) =
## Create a new QApplication
dos_qapplication_create() dos_qapplication_create()
application.deleted = false application.deleted = false
@ -18,12 +13,13 @@ proc quit*(application: QApplication) =
proc delete*(application: QApplication) = proc delete*(application: QApplication) =
## Delete the given QApplication ## Delete the given QApplication
if not application.deleted: if application.deleted:
debugMsg("QApplication", "delete") return
dos_qapplication_delete() debugMsg("QApplication", "delete")
application.deleted = true dos_qapplication_delete()
application.deleted = true
proc newQApplication*(): QApplication = proc newQApplication*(): QApplication =
## Return a new QApplication ## Return a new QApplication
new(result, delete) new(result, delete)
result.create() result.setup()