diff options
author | Miquel Lionel <lionel@les-miquelots.net> | 2022-02-06 20:42:01 +0100 |
---|---|---|
committer | Miquel Lionel <lionel@les-miquelots.net> | 2022-02-06 20:57:27 +0100 |
commit | d5ad7202ea77e8a512073f9ce09b6c07e37d6305 (patch) | |
tree | 167141728086401a50a125a20997b61df41a2d2e | |
parent | a01f8091c01889d7ca90938f56ae176a74da5590 (diff) | |
download | kdeltachat-d5ad7202ea77e8a512073f9ce09b6c07e37d6305.tar.gz kdeltachat-d5ad7202ea77e8a512073f9ce09b6c07e37d6305.zip |
Move notifications to own header file
- also make a skel for files in /usr/, useful
for sounds and notifyrc
- build.sh use plain simple cp -r to copy the skel.
also copies the knotifications5 in the current directory
for qml.qrc embedding in case the app is used on android.
-rw-r--r-- | CMakeLists.txt | 3 | ||||
-rwxr-xr-x | README.md | 4 | ||||
-rwxr-xr-x | build.sh | 6 | ||||
-rw-r--r-- | main.cpp | 9 | ||||
-rw-r--r-- | notifications.cpp | 21 | ||||
-rw-r--r-- | notifications.h | 13 | ||||
-rw-r--r-- | qml.qrc | 1 | ||||
-rw-r--r-- | qml/ChatPage.qml | 2 | ||||
-rwxr-xr-x | usr/share/applications/chat.delta.KDeltaChat.desktop | 9 | ||||
-rwxr-xr-x | usr/share/icons/hicolor/256x256/chat.delta.KDeltaChat.png | bin | 0 -> 18772 bytes | |||
-rwxr-xr-x | usr/share/knotifications5/kdeltachat.notifyrc | 18 | ||||
-rw-r--r-- | usr/share/sounds/kdeltachat/incomingmessage.ogg | bin | 0 -> 6938 bytes |
12 files changed, 83 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f10a4f8..4817196 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,7 @@ ecm_find_qmlmodule(org.kde.kirigami 2.12) # # See https://doc.qt.io/qt-5/qtquick-deployment.html#ahead-of-time-compilation find_package(Qt5QuickCompiler REQUIRED) +find_package(KF5Notifications REQUIRED) qtquick_compiler_add_resources(KDELTACHAT_QML_QRC qml.qrc) add_executable( @@ -48,6 +49,7 @@ add_executable( chatlist.cpp contact.cpp chat.cpp + notifications.cpp eventemitter.cpp lot.cpp dcevent.cpp @@ -55,7 +57,6 @@ add_executable( find_package(Threads REQUIRED) find_package(KF5Kirigami2 REQUIRED) -find_package(KF5Notifications REQUIRED) pkg_check_modules(DeltaChat IMPORTED_TARGET deltachat) target_compile_definitions( @@ -160,6 +160,10 @@ to help in this case. This results in usage of Adwaita icon theme. The pinned and muted chat icons are converted to PNG from the [Twemoji](https://twemoji.twitter.com/) font. Licensed under [CC-BY 4.0](https://creativecommons.org/licenses/by/4.0/) - Copyright 2020 Twitter, Inc and other contributors. +The incoming message notification sound, `incomingmessage.ogg`, is a .wav file made by [BeezleFM](https://freesound.org/people/BeezleFM/sounds/512136/) and then converted to .ogg through ffmpeg. Original title is 'Notification Sound'. +Licensed under [CC-BY 3.0](http://creativecommons.org/licenses/by/3.0/). +Copyright 2020 BeezleFM at freesound.org. + # License This program is free software: you can redistribute it and/or modify @@ -1,5 +1,9 @@ #!/bin/sh + +# for the qml.qrc +cp -r usr/share/knotifications5 . + cmake -B build . cmake --build build -sudo install -vDm644 usr/* -t / +cp -v -r usr/ / sudo install -vDm755 build/kdeltachat -t /usr/local/bin/ @@ -2,6 +2,7 @@ #include <QQmlApplicationEngine> #include <QMetaType> #include <QtWebEngine> +//#include <QScopedPointer> #include "accounts.h" #include "message.h" @@ -10,6 +11,7 @@ #include "context.h" #include "contact.h" #include "eventemitter.h" +#include "notifications.h" int main(int argc, char *argv[]) { @@ -52,15 +54,22 @@ int main(int argc, char *argv[]) { QCoreApplication::exit(-1); } + if (qmlRegisterType<DcNotifications>("DcNotifications", 1, 0, "DcNotifications") == -1) + { + QCoreApplication::exit(-1); + } if (qmlRegisterType<DcAccountsEventEmitter>("DeltaChat", 1, 0, "DcAccountsEventEmitter") == -1) { QCoreApplication::exit(-1); } + + DcNotifications* KNotif = new DcNotifications(); qRegisterMetaType<size_t>("size_t"); qRegisterMetaType<uint32_t>("uint32_t"); qRegisterMetaType<QVector<uint32_t>>("QVector<uint32_t>"); QQmlApplicationEngine engine; + engine.rootContext()->setContextProperty("KNotif", KNotif); const QUrl url(QStringLiteral("qrc:/qml/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { diff --git a/notifications.cpp b/notifications.cpp new file mode 100644 index 0000000..712e37e --- /dev/null +++ b/notifications.cpp @@ -0,0 +1,21 @@ +#include <KNotification> +#include "notifications.h" + +DcNotifications::DcNotifications(QObject *parent) + : QObject{parent} +{ +} + +void +DcNotifications::send(QString event, QString pfpPath, QString title, QString message) { + + KNotification *newMess = new KNotification(event); + newMess->setPixmap(QPixmap(pfpPath)); + newMess->setIconName("chat.delta.KDeltaChat"); + newMess->setComponentName("kdeltachat"); + newMess->setTitle(title); + newMess->setText(message); + newMess->sendEvent(); + +} +//newMess->setPixmap(QPixmap(":/res/chat.delta.KDeltaChat.png")); diff --git a/notifications.h b/notifications.h new file mode 100644 index 0000000..5d7852b --- /dev/null +++ b/notifications.h @@ -0,0 +1,13 @@ +#pragma once +#include <QObject> + +class DcNotifications: public QObject { + Q_OBJECT +public: + explicit DcNotifications(QObject *parent = nullptr); + //explicit DcEvent(dc_event_t *event); + + //~DcNotifications(); + + Q_INVOKABLE void send(QString event, QString pfpPath, QString title, QString message); +}; @@ -15,5 +15,6 @@ <file>knotifications5/kdeltachat.notifyrc</file> <file>res/pin_48x48.png</file> <file>res/muted_48x48.png</file> + <file>res/chat.delta.KDeltaChat.png</file> </qresource> </RCC> diff --git a/qml/ChatPage.qml b/qml/ChatPage.qml index 667e01d..a82e0f6 100644 --- a/qml/ChatPage.qml +++ b/qml/ChatPage.qml @@ -57,7 +57,7 @@ Kirigami.ScrollablePage { updateMessagelist(); console.log("Incoming message for chat " + chatId); if(!chat.muted || chatId != 0 || chatId != root.chatId) - chat.notifyNewMess(); + KNotif.send("onIncomingMessage",chat.getProfileImage() ,chat.name ,"has sent you a message.") } function onMessagesChanged(accountId, chatId, msgId) { diff --git a/usr/share/applications/chat.delta.KDeltaChat.desktop b/usr/share/applications/chat.delta.KDeltaChat.desktop new file mode 100755 index 0000000..35c2999 --- /dev/null +++ b/usr/share/applications/chat.delta.KDeltaChat.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Type=Application +Name=KDeltaChat +Comment=Delta Chat client built with Kirigami +Icon=chat.delta.KDeltaChat +TryExec=kdeltachat +Exec=kdeltachat +Categories=Network;Email;InstantMessaging;Chat;KDE;Qt; +StartupWMClass=KDeltaChat diff --git a/usr/share/icons/hicolor/256x256/chat.delta.KDeltaChat.png b/usr/share/icons/hicolor/256x256/chat.delta.KDeltaChat.png Binary files differnew file mode 100755 index 0000000..62f445e --- /dev/null +++ b/usr/share/icons/hicolor/256x256/chat.delta.KDeltaChat.png diff --git a/usr/share/knotifications5/kdeltachat.notifyrc b/usr/share/knotifications5/kdeltachat.notifyrc new file mode 100755 index 0000000..901db73 --- /dev/null +++ b/usr/share/knotifications5/kdeltachat.notifyrc @@ -0,0 +1,18 @@ +[Global] +IconName=chat.delta.KDeltaChat +Name=KDeltaChat +Comment=KDeltaChat +DesktopEntry=chat.delta.KDeltaChat + +[Event/onIncomingMessage] +Name=New Message +Comment=You have got a new message +Contexts=none +Sound=kdeltachat/incomingmessage.ogg +Action=Popup|Sound + +[Event/workMode] +Name=Working offline +Comment=Switch to offline mode +Contexts=none +Action=Popup diff --git a/usr/share/sounds/kdeltachat/incomingmessage.ogg b/usr/share/sounds/kdeltachat/incomingmessage.ogg Binary files differnew file mode 100644 index 0000000..e7eb72d --- /dev/null +++ b/usr/share/sounds/kdeltachat/incomingmessage.ogg |