Merge pull request #35 from status-im/fix/qguiapplication

QGuiApplication to not mess with QCoreApplication and QApplication
This commit is contained in:
Iuri Matias 2021-09-20 11:35:25 -04:00 committed by GitHub
commit d3fdb6eed2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 31 deletions

View File

@ -19,9 +19,7 @@ include "nimqml/private/qnetworkconfigurationmanager.nim"
include "nimqml/private/qvariant.nim"
include "nimqml/private/qobject.nim"
include "nimqml/private/qqmlapplicationengine.nim"
include "nimqml/private/qcoreapplication.nim"
include "nimqml/private/qguiapplication.nim"
include "nimqml/private/qapplication.nim"
include "nimqml/private/qurl.nim"
include "nimqml/private/qquickview.nim"
include "nimqml/private/qhashintbytearray.nim"

View File

@ -127,29 +127,20 @@ proc isNil(x: DosQModelIndex): bool = x.pointer.isNil
# CharArray
proc dos_chararray_delete(str: cstring) {.cdecl, dynlib: dynLibName, importc.}
# QCoreApplication
proc dos_qcoreapplication_application_dir_path(): cstring {.cdecl, dynlib: dynLibName, importc.}
proc dos_qapplication_enable_hdpi(uiScaleFilePath: cstring) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qapplication_initialize_opengl() {.cdecl, dynlib: dynLibName, importc.}
# QApplication
proc dos_qapplication_create() {.cdecl, dynlib: dynLibName, importc.}
proc dos_qapplication_exec() {.cdecl, dynlib: dynLibName, importc.}
proc dos_qapplication_quit() {.cdecl, dynlib: dynLibName, importc.}
proc dos_qapplication_icon(filename: cstring) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qapplication_delete() {.cdecl, dynlib: dynLibName, importc.}
proc dos_qapplication_clipboard_setText(content: cstring) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qapplication_installEventFilter(engine: DosStatusEvent) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qapplication_clipboard_setImage(content: cstring) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qapplication_download_image(imageSource: cstring, filePath: cstring) {.cdecl, dynlib: dynLibName, importc.}
# QGuiApplication
proc dos_qguiapplication_application_dir_path(): cstring {.cdecl, dynlib: dynLibName, importc.}
proc dos_qguiapplication_enable_hdpi(uiScaleFilePath: cstring) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qguiapplication_initialize_opengl() {.cdecl, dynlib: dynLibName, importc.}
proc dos_qguiapplication_create() {.cdecl, dynlib: dynLibName, importc.}
proc dos_qguiapplication_exec() {.cdecl, dynlib: dynLibName, importc.}
proc dos_qguiapplication_quit() {.cdecl, dynlib: dynLibName, importc.}
proc dos_qguiapplication_icon(filename: cstring) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qguiapplication_delete() {.cdecl, dynlib: dynLibName, importc.}
proc dos_qguiapplication_clipboard_setText(content: cstring) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qguiapplication_installEventFilter(engine: DosStatusEvent) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qguiapplication_clipboard_setImage(content: cstring) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qguiapplication_download_image(imageSource: cstring, filePath: cstring) {.cdecl, dynlib: dynLibName, importc.}
# QQmlContext
proc dos_qqmlcontext_setcontextproperty(context: DosQQmlContext, propertyName: cstring, propertyValue: DosQVariant) {.cdecl, dynlib: dynLibName, importc.}
@ -164,7 +155,7 @@ proc dos_qqmlapplicationengine_load_data(engine: DosQQmlApplicationEngine, data:
proc dos_qqmlapplicationengine_add_import_path(engine: DosQQmlApplicationEngine, path: cstring) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qqmlapplicationengine_context(engine: DosQQmlApplicationEngine): DosQQmlContext {.cdecl, dynlib: dynLibName, importc.}
proc dos_qqmlapplicationengine_delete(engine: DosQQmlApplicationEngine) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qapplication_load_translation(engine: DosQQmlApplicationEngine, content: cstring, shouldRetranslate: bool) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qguiapplication_load_translation(engine: DosQQmlApplicationEngine, content: cstring, shouldRetranslate: bool) {.cdecl, dynlib: dynLibName, importc.}
# QVariant
proc dos_qvariant_create(): DosQVariant {.cdecl, dynlib: dynLibName, importc.}

View File

@ -1,10 +0,0 @@
proc enableHDPI*(uiScaleFilePath: string) =
dos_qapplication_enable_hdpi(uiScaleFilePath)
proc initializeOpenGL*() =
dos_qapplication_initialize_opengl()
proc applicationDirPath*(app: QCoreApplication): string =
let str = dos_qcoreapplication_application_dir_path()
result = $str
dos_chararray_delete(str)

View File

@ -31,3 +31,23 @@ proc exec*(self: QGuiApplication) =
proc quit*(self: QGuiApplication) =
## Quit the Qt event loop
dos_qguiapplication_quit()
proc setClipboardText*(text: string = "") =
dos_qguiapplication_clipboard_setText(text.cstring)
proc setClipboardImage*(text: string = "") =
dos_qguiapplication_clipboard_setImage(text.cstring)
proc downloadImage*(imageSource: string = "", filePath = "") =
dos_qguiapplication_download_image(imageSource.cstring, filePath.cstring)
proc enableHDPI*(uiScaleFilePath: string) =
dos_qguiapplication_enable_hdpi(uiScaleFilePath)
proc initializeOpenGL*() =
dos_qguiapplication_initialize_opengl()
proc applicationDirPath*(app: QGuiApplication): string =
let str = dos_qguiapplication_application_dir_path()
result = $str
dos_chararray_delete(str)

View File

@ -30,7 +30,7 @@ proc setRootContextProperty*(self: QQmlApplicationEngine, name: string, value: Q
dos_qqmlcontext_setcontextproperty(context, name.cstring, value.vptr)
proc setTranslationPackage*(self: QQmlApplicationEngine, packagePath: string, shouldRetranslate: bool = true) =
dos_qapplication_load_translation(self.vptr, packagePath.cstring, shouldRetranslate)
dos_qguiapplication_load_translation(self.vptr, packagePath.cstring, shouldRetranslate)
proc delete*(self: QQmlApplicationEngine) =
## Delete the given QQmlApplicationEngine