Added support for QGuiApplication

This commit is contained in:
Filippo Cucchetto 2016-02-20 11:07:43 +01:00
parent ba45affb99
commit 23826e2721
4 changed files with 29 additions and 28 deletions

View File

@ -18,16 +18,12 @@ include private/qvariant.nim
include private/qobject.nim
include private/qqmlapplicationengine.nim
include private/qapplication.nim
include private/qguiapplication.nim
include private/qurl.nim
include private/qquickview.nim
#include private.nimqmltypes
#var qobjectRegistry = initTable[ptr QObjectObj, bool]()
#include private/qvariant.nim
#include private/qqmlcontext.nim
#include private/qapplication.nim
#include private/qguiapplication.nim
#include private/qobject.nim
#include private/qquickview.nim
#include private/qmodelindex.nim
#include private/qhashintbytearray.nim
#include private/qabstractlistmodel.nim

View File

@ -54,6 +54,12 @@ proc dos_qapplication_exec() {.cdecl, importc.}
proc dos_qapplication_quit() {.cdecl, importc.}
proc dos_qapplication_delete() {.cdecl, importc.}
# QGuiApplication
proc dos_qguiapplication_create() {.cdecl, importc.}
proc dos_qguiapplication_exec() {.cdecl, importc.}
proc dos_qguiapplication_quit() {.cdecl, importc.}
proc dos_qguiapplication_delete() {.cdecl, importc.}
# QQmlContext
proc dos_qqmlcontext_setcontextproperty(context: DosQQmlContext, propertyName: cstring, propertyValue: DosQVariant) {.cdecl, importc.}

View File

@ -15,6 +15,10 @@ type
## A QApplication
deleted: bool
QGuiApplication = ref object of RootObj ## \
## A QGuiApplication
deleted: bool
QQuickView* = ref object of RootObj ## \
# A QQuickView
vptr: DosQQuickView

View File

@ -1,30 +1,25 @@
# QGuiApplication
proc dos_qguiapplication_create() {.cdecl, importc.}
proc dos_qguiapplication_exec() {.cdecl, importc.}
proc dos_qguiapplication_quit() {.cdecl, importc.}
proc dos_qguiapplication_delete() {.cdecl, importc.}
proc create*(application: QGuiApplication) =
## Create a new QApplication
proc setup*(self: QGuiApplication) =
## Setup a new QApplication
dos_qguiapplication_create()
application.deleted = false
self.deleted = false
proc exec*(application: QGuiApplication) =
## Start the Qt event loop
dos_qguiapplication_exec()
proc quit*(application: QGuiApplication) =
## Quit the Qt event loop
dos_qguiapplication_quit()
proc delete*(application: QGuiApplication) =
proc delete*(self: QGuiApplication) =
## Delete the given QApplication
if not application.deleted:
if self.deleted:
return
debugMsg("QApplication", "delete")
dos_qguiapplication_delete()
application.deleted = true
self.deleted = true
proc newQGuiApplication*(): QGuiApplication =
## Return a new QApplication
new(result, delete)
result.create()
result.setup()
proc exec*(self: QGuiApplication) =
## Start the Qt event loop
dos_qguiapplication_exec()
proc quit*(self: QGuiApplication) =
## Quit the Qt event loop
dos_qguiapplication_quit()