From b4a4642340bf6c26e1d1d51d15101cdb05bdbb25 Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Mon, 23 Aug 2021 09:55:12 +0200 Subject: [PATCH] fix(@desktop/general): clicking push notification does expand the app but does not open correct channel/chat An interface for using methods of the StatusOSNotification class added in the `dotherside` project. This is corresponding nimqml part of the issue 2996. Fixes: #2996 --- src/nimqml.nim | 1 + src/nimqml/private/dotherside.nim | 12 +++++++++++- src/nimqml/private/nimqmltypes.nim | 2 ++ src/nimqml/private/status/statusevent.nim | 6 ++---- src/nimqml/private/status/statusosnotification.nim | 14 ++++++++++++++ 5 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 src/nimqml/private/status/statusosnotification.nim diff --git a/src/nimqml.nim b/src/nimqml.nim index 5f4eb2f..5d30921 100644 --- a/src/nimqml.nim +++ b/src/nimqml.nim @@ -34,6 +34,7 @@ include "nimqml/private/qdeclarative.nim" include "nimqml/private/nimqmlmacros.nim" include "nimqml/private/singleinstance.nim" include "nimqml/private/status/statusevent.nim" +include "nimqml/private/status/statusosnotification.nim" proc signal_handler*(receiver: pointer, signal: cstring, slot: cstring) = diff --git a/src/nimqml/private/dotherside.nim b/src/nimqml/private/dotherside.nim index f457513..3281819 100644 --- a/src/nimqml/private/dotherside.nim +++ b/src/nimqml/private/dotherside.nim @@ -33,6 +33,7 @@ type DosQAbstractTableModel = distinct pointer DosQAbstractListModel = distinct pointer DosStatusEventObject = distinct pointer + DosStatusOSNotificationObject = DosQObject DosParameterDefinition = object name: cstring @@ -344,4 +345,13 @@ proc dos_singleinstance_delete(vptr: DosQObject) {.cdecl, dynlib: dynLibName, im # DosStatusEventObject proc dos_statusevent_create_showAppEvent(engine: DosQQmlApplicationEngine): DosStatusEventObject {.cdecl, dynlib: dynLibName, importc.} proc dos_statusevent_create_osThemeEvent(engine: DosQQmlApplicationEngine): DosStatusEventObject {.cdecl, dynlib: dynLibName, importc.} -proc dos_statusevent_delete(vptr: DosStatusEventObject) {.cdecl, dynlib: dynLibName, importc.} \ No newline at end of file +proc dos_statusevent_delete(vptr: DosStatusEventObject) {.cdecl, dynlib: dynLibName, importc.} + +# DosStatusOSNotificationObject +proc dos_statusosnotification_create(): DosStatusOSNotificationObject + {.cdecl, dynlib: dynLibName, importc.} +proc dos_statusosnotification_show_notification(vptr: DosStatusOSNotificationObject, + title: cstring, messsage: cstring, identifier: cstring) + {.cdecl, dynlib: dynLibName, importc.} +proc dos_statusosnotification_delete(vptr: DosStatusOSNotificationObject) + {.cdecl, dynlib: dynLibName, importc.} \ No newline at end of file diff --git a/src/nimqml/private/nimqmltypes.nim b/src/nimqml/private/nimqmltypes.nim index d97ea13..f8d74c0 100644 --- a/src/nimqml/private/nimqmltypes.nim +++ b/src/nimqml/private/nimqmltypes.nim @@ -135,6 +135,8 @@ type StatusEventObject* = ref object of RootObj ## \ ## A StatusEventObject vptr: DosStatusEventObject + + StatusOSNotificationObject* = ref object of QObject const UserRole* = 0x100 diff --git a/src/nimqml/private/status/statusevent.nim b/src/nimqml/private/status/statusevent.nim index 4dc9a8b..6c8d390 100644 --- a/src/nimqml/private/status/statusevent.nim +++ b/src/nimqml/private/status/statusevent.nim @@ -1,10 +1,8 @@ -#import ../[nimqmltypes, dotherside] - -proc setupDockShowAppEventObject*(self: StatusEventObject, engine: QQmlApplicationEngine) = +proc setupDockShowAppEventObject(self: StatusEventObject, engine: QQmlApplicationEngine) = self.vptr = dos_statusevent_create_showAppEvent(engine.vptr) -proc setupOSThemeEventObject*(self: StatusEventObject, engine: QQmlApplicationEngine) = +proc setupOSThemeEventObject(self: StatusEventObject, engine: QQmlApplicationEngine) = self.vptr = dos_statusevent_create_osThemeEvent(engine.vptr) proc delete*(self: StatusEventObject) = diff --git a/src/nimqml/private/status/statusosnotification.nim b/src/nimqml/private/status/statusosnotification.nim new file mode 100644 index 0000000..23f6923 --- /dev/null +++ b/src/nimqml/private/status/statusosnotification.nim @@ -0,0 +1,14 @@ +proc setup(self: StatusOSNotificationObject) = + self.vptr = dos_statusosnotification_create() + +proc delete*(self: StatusOSNotificationObject) = + dos_statusosnotification_delete(self.vptr) + self.vptr.resetToNil + +proc newStatusOSNotificationObject*(): StatusOSNotificationObject = + new(result, delete) + result.setup() + +proc showNotification*(self: StatusOSNotificationObject, title: string, + message: string, identifier: string) = + dos_statusosnotification_show_notification(self.vptr, title, message, identifier)