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/qobject.nim
include private/qqmlapplicationengine.nim
include private/qapplication.nim
#include private.nimqmltypes
#var qobjectRegistry = initTable[ptr QObjectObj, bool]()
#include private/qvariant.nim

View File

@ -46,6 +46,12 @@ type
proc resetToNil*[T](x: var T) = x = nil.pointer.T
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
proc dos_qqmlcontext_setcontextproperty(context: DosQQmlContext, propertyName: cstring, propertyValue: DosQVariant) {.cdecl, importc.}

View File

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

View File

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