Added support for QQuickView

This commit is contained in:
Filippo Cucchetto 2016-02-20 11:03:35 +01:00
parent e31df59620
commit ba45affb99
4 changed files with 38 additions and 30 deletions

View File

@ -19,6 +19,7 @@ include private/qobject.nim
include private/qqmlapplicationengine.nim include private/qqmlapplicationengine.nim
include private/qapplication.nim include private/qapplication.nim
include private/qurl.nim include private/qurl.nim
include private/qquickview.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

@ -9,6 +9,7 @@ type
DosQMetaType = cint DosQMetaType = cint
DosQMetaTypeArray* {.unchecked.} = array[0..0, DosQMetaType] DosQMetaTypeArray* {.unchecked.} = array[0..0, DosQMetaType]
DosQUrl* = distinct pointer DosQUrl* = distinct pointer
DosQQuickView* = distinct pointer
DosSignalDefinition* = object DosSignalDefinition* = object
name*: cstring name*: cstring
@ -113,3 +114,12 @@ proc dos_qmetaobject_delete*(vptr: DosQmetaObject) {.cdecl, importc.}
proc dos_qurl_create(vptr: var DosQUrl, url: cstring, parsingMode: cint) {.cdecl, importc.} proc dos_qurl_create(vptr: var DosQUrl, url: cstring, parsingMode: cint) {.cdecl, importc.}
proc dos_qurl_delete(vptr: DosQUrl) {.cdecl, importc.} proc dos_qurl_delete(vptr: DosQUrl) {.cdecl, importc.}
proc dos_qurl_to_string(vptr: DosQUrl, str: var cstring) {.cdecl, importc.} proc dos_qurl_to_string(vptr: DosQUrl, str: var cstring) {.cdecl, importc.}
# QQuickView
proc dos_qquickview_create(view: var DosQQuickView) {.cdecl, importc.}
proc dos_qquickview_delete(view: DosQQuickView) {.cdecl, importc.}
proc dos_qquickview_show(view: DosQQuickView) {.cdecl, importc.}
proc dos_qquickview_source(view: DosQQuickView, filename: var cstring, length: var int) {.cdecl, importc.}
proc dos_qquickview_set_source(view: DosQQuickView, filename: cstring) {.cdecl, importc.}

View File

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

View File

@ -1,36 +1,29 @@
proc dos_qquickview_create(view: var RawQQuickView) {.cdecl, importc.} proc setup*(self: var QQuickView) =
proc dos_qquickview_delete(view: RawQQuickView) {.cdecl, importc.} ## Setup a new QQuickView
proc dos_qquickview_show(view: RawQQuickView) {.cdecl, importc.} dos_qquickview_create(self.vptr)
proc dos_qquickview_source(view: RawQQuickView, filename: var cstring, length: var int) {.cdecl, importc.}
proc dos_qquickview_set_source(view: RawQQuickView, filename: cstring) {.cdecl, importc.}
proc create*(view: var QQuickView) = proc delete*(self: QQuickView) =
## Create a new QQuickView
dos_qquickview_create(view.data)
view.deleted = false
proc source*(view: QQuickView): cstring =
## Return the source Qml file loaded by the view
var length: int
dos_qquickview_source(view.data, result, length)
proc `source=`*(view: QQuickView, filename: cstring) =
## Sets the source Qml file laoded by the view
dos_qquickview_set_source(view.data, filename)
proc show*(view: QQuickView) =
## Sets the view visible
dos_qquickview_show(view.data)
proc delete*(view: QQuickView) =
## Delete the given QQuickView ## Delete the given QQuickView
if not view.deleted: if self.vptr.isNil:
debugMsg("QQuickView", "delete") return
dos_qquickview_delete(view.data) debugMsg("QQuickView", "delete")
view.data = nil.RawQQuickView dos_qquickview_delete(self.vptr)
view.deleted = true self.vptr.resetToNil
proc newQQuickView*(): QQuickView = proc newQQuickView*(): QQuickView =
## Return a new QQuickView ## Return a new QQuickView
new(result, delete) new(result, delete)
result.create() result.setup()
proc source*(self: QQuickView): cstring =
## Return the source Qml file loaded by the view
var length: int
dos_qquickview_source(self.vptr, result, length)
proc `source=`*(self: QQuickView, filename: cstring) =
## Sets the source Qml file laoded by the view
dos_qquickview_set_source(self.vptr, filename)
proc show*(self: QQuickView) =
## Sets the view visible
dos_qquickview_show(self.vptr)