aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt3
-rwxr-xr-xREADME.md4
-rwxr-xr-xbuild.sh6
-rw-r--r--main.cpp9
-rw-r--r--notifications.cpp21
-rw-r--r--notifications.h13
-rw-r--r--qml.qrc1
-rw-r--r--qml/ChatPage.qml2
-rwxr-xr-xusr/share/applications/chat.delta.KDeltaChat.desktop9
-rwxr-xr-xusr/share/icons/hicolor/256x256/chat.delta.KDeltaChat.pngbin0 -> 18772 bytes
-rwxr-xr-xusr/share/knotifications5/kdeltachat.notifyrc18
-rw-r--r--usr/share/sounds/kdeltachat/incomingmessage.oggbin0 -> 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(
diff --git a/README.md b/README.md
index 506b251..a6c8a78 100755
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/build.sh b/build.sh
index 31845a2..ad735b2 100755
--- a/build.sh
+++ b/build.sh
@@ -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/
diff --git a/main.cpp b/main.cpp
index 57334a4..fb7cded 100644
--- a/main.cpp
+++ b/main.cpp
@@ -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);
+};
diff --git a/qml.qrc b/qml.qrc
index 506ed7b..cff9f53 100644
--- a/qml.qrc
+++ b/qml.qrc
@@ -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
new file mode 100755
index 0000000..62f445e
--- /dev/null
+++ b/usr/share/icons/hicolor/256x256/chat.delta.KDeltaChat.png
Binary files differ
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
new file mode 100644
index 0000000..e7eb72d
--- /dev/null
+++ b/usr/share/sounds/kdeltachat/incomingmessage.ogg
Binary files differ