From c428cf43976be8e647e8cf6412e783b06765b5ee Mon Sep 17 00:00:00 2001 From: Michal Iskierko Date: Tue, 27 Sep 2022 11:01:14 +0200 Subject: [PATCH] chore(@desktop): Expose QTimer functions --- src/nimqml.nim | 1 + src/nimqml/private/dotherside.nim | 21 ++++++++++++++++++++ src/nimqml/private/nimqmltypes.nim | 2 ++ src/nimqml/private/qtimer.nim | 31 ++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 src/nimqml/private/qtimer.nim diff --git a/src/nimqml.nim b/src/nimqml.nim index 562a02f..61ed338 100644 --- a/src/nimqml.nim +++ b/src/nimqml.nim @@ -30,6 +30,7 @@ include "nimqml/private/qabstracttablemodel.nim" include "nimqml/private/qresource.nim" include "nimqml/private/qdeclarative.nim" include "nimqml/private/qsettings.nim" +include "nimqml/private/qtimer.nim" include "nimqml/private/nimqmlmacros.nim" include "nimqml/private/singleinstance.nim" include "nimqml/private/status/statusevent.nim" diff --git a/src/nimqml/private/dotherside.nim b/src/nimqml/private/dotherside.nim index 25161b0..e3a6594 100644 --- a/src/nimqml/private/dotherside.nim +++ b/src/nimqml/private/dotherside.nim @@ -36,6 +36,7 @@ type DosStatusOSNotification = DosQObject DosQSettings = DosQObject DosStatusKeychainManager = DosQObject + DosQTimer = DosQObject DosParameterDefinition = object name: cstring @@ -371,6 +372,26 @@ proc dos_qsettings_remove(vptr: DosQSettings, key: cstring) proc dos_qsettings_delete(vptr: DosQSettings) {.cdecl, dynlib: dynLibName, importc.} +# QTimer +proc dos_qtimer_create(): DosQTimer + {.cdecl, dynlib: dynLibName, importc.} +proc dos_qtimer_delete(vptr: DosQTimer) + {.cdecl, dynlib: dynLibName, importc.} +proc dos_qtimer_set_interval(vptr: DosQTimer, interval: int) + {.cdecl, dynlib: dynLibName, importc.} +proc dos_qtimer_interval(vptr: DosQTimer): int + {.cdecl, dynlib: dynLibName, importc.} +proc dos_qtimer_start(vptr: DosQTimer) + {.cdecl, dynlib: dynLibName, importc.} +proc dos_qtimer_stop(vptr: DosQTimer) + {.cdecl, dynlib: dynLibName, importc.} +proc dos_qtimer_set_single_shot(vptr: DosQTimer, singleShot: bool) + {.cdecl, dynlib: dynLibName, importc.} +proc dos_qtimer_is_single_shot(vptr: DosQTimer): bool + {.cdecl, dynlib: dynLibName, importc.} +proc dos_qtimer_is_active(vptr: DosQTimer): bool + {.cdecl, dynlib: dynLibName, importc.} + # DosStatusKeychainManager proc dos_keychainmanager_create(service: cstring, authenticationReason: cstring): DosStatusKeychainManager diff --git a/src/nimqml/private/nimqmltypes.nim b/src/nimqml/private/nimqmltypes.nim index 55b75b4..b2d7047 100644 --- a/src/nimqml/private/nimqmltypes.nim +++ b/src/nimqml/private/nimqmltypes.nim @@ -112,6 +112,8 @@ type vptr: DosQUrl QNetworkConfigurationManager* = ref object of QObject + + QTimer* = ref object of QObject QNetworkAccessManagerFactory* = ref object of RootObj ## \ vptr: DosQQNetworkAccessManagerFactory diff --git a/src/nimqml/private/qtimer.nim b/src/nimqml/private/qtimer.nim new file mode 100644 index 0000000..292dd9f --- /dev/null +++ b/src/nimqml/private/qtimer.nim @@ -0,0 +1,31 @@ +proc delete*(self: QTimer) = + dos_qtimer_delete(self.vptr) + self.vptr.resetToNil + +proc setup*(self: QTimer) = + self.vptr = dos_qtimer_create() + +proc newQTimer*() : QTimer = + new(result, delete) + result.setup() + +proc setInterval*(self: QTimer, interval: int) = + dos_qtimer_set_interval(self.vptr, interval) + +proc interval*(self: QTimer): int = + return dos_qtimer_interval(self.vptr) + +proc start*(self:QTimer) = + dos_qtimer_start(self.vptr) + +proc stop*(self:QTimer) = + dos_qtimer_stop(self.vptr) + +proc setSingleShot*(self:QTimer, singleShot: bool) = + dos_qtimer_set_single_shot(self.vptr, singleShot) + +proc isSingleShot*(self:QTimer): bool = + return dos_qtimer_is_single_shot(self.vptr) + +proc isActive*(self:QTimer): bool = + return dos_qtimer_is_active(self.vptr)