mirror of https://github.com/status-im/nimqml.git
Added support for QQuickView
This commit is contained in:
parent
e31df59620
commit
ba45affb99
|
@ -19,6 +19,7 @@ include private/qobject.nim
|
|||
include private/qqmlapplicationengine.nim
|
||||
include private/qapplication.nim
|
||||
include private/qurl.nim
|
||||
include private/qquickview.nim
|
||||
#include private.nimqmltypes
|
||||
#var qobjectRegistry = initTable[ptr QObjectObj, bool]()
|
||||
#include private/qvariant.nim
|
||||
|
|
|
@ -9,6 +9,7 @@ type
|
|||
DosQMetaType = cint
|
||||
DosQMetaTypeArray* {.unchecked.} = array[0..0, DosQMetaType]
|
||||
DosQUrl* = distinct pointer
|
||||
DosQQuickView* = distinct pointer
|
||||
|
||||
DosSignalDefinition* = object
|
||||
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_delete(vptr: DosQUrl) {.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.}
|
||||
|
||||
|
||||
|
|
|
@ -15,6 +15,10 @@ type
|
|||
## A QApplication
|
||||
deleted: bool
|
||||
|
||||
QQuickView* = ref object of RootObj ## \
|
||||
# A QQuickView
|
||||
vptr: DosQQuickView
|
||||
|
||||
QtItemFlag* {.pure.} = enum ## \
|
||||
## Item flags
|
||||
##
|
||||
|
|
|
@ -1,36 +1,29 @@
|
|||
proc dos_qquickview_create(view: var RawQQuickView) {.cdecl, importc.}
|
||||
proc dos_qquickview_delete(view: RawQQuickView) {.cdecl, importc.}
|
||||
proc dos_qquickview_show(view: RawQQuickView) {.cdecl, importc.}
|
||||
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 setup*(self: var QQuickView) =
|
||||
## Setup a new QQuickView
|
||||
dos_qquickview_create(self.vptr)
|
||||
|
||||
proc create*(view: var 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) =
|
||||
proc delete*(self: QQuickView) =
|
||||
## Delete the given QQuickView
|
||||
if not view.deleted:
|
||||
debugMsg("QQuickView", "delete")
|
||||
dos_qquickview_delete(view.data)
|
||||
view.data = nil.RawQQuickView
|
||||
view.deleted = true
|
||||
if self.vptr.isNil:
|
||||
return
|
||||
debugMsg("QQuickView", "delete")
|
||||
dos_qquickview_delete(self.vptr)
|
||||
self.vptr.resetToNil
|
||||
|
||||
proc newQQuickView*(): QQuickView =
|
||||
## Return a new QQuickView
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue