diff options
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | README.md | 4 | ||||
-rwxr-xr-x | build.sh | 3 | ||||
-rw-r--r-- | chat.cpp | 12 | ||||
-rw-r--r-- | chat.h | 4 | ||||
-rw-r--r-- | context.cpp | 2 | ||||
-rw-r--r-- | context.h | 2 | ||||
-rw-r--r-- | qml.qrc | 5 | ||||
-rw-r--r-- | qml/ChatPage.qml | 2 | ||||
-rw-r--r-- | qml/ChatlistItem.qml | 55 | ||||
-rw-r--r-- | qml/ChatlistPage.qml | 3 | ||||
-rw-r--r-- | res/CMakeLists.txt | 8 | ||||
-rw-r--r-- | res/chat.delta.KDeltaChat.desktop | 9 |
13 files changed, 70 insertions, 43 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6584945..f10a4f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,7 @@ add_executable( find_package(Threads REQUIRED) find_package(KF5Kirigami2 REQUIRED) +find_package(KF5Notifications REQUIRED) pkg_check_modules(DeltaChat IMPORTED_TARGET deltachat) target_compile_definitions( @@ -66,8 +67,7 @@ target_link_libraries( Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::WebEngine PRIVATE Threads::Threads PRIVATE KF5::Kirigami2 + PRIVATE KF5::Notifications PRIVATE PkgConfig::DeltaChat m dl) install(TARGETS kdeltachat ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) - -add_subdirectory(res) diff --git a/README.md b/README.md index 1922507..506b251 100644..100755 --- a/README.md +++ b/README.md @@ -156,6 +156,10 @@ icon theme for Qt 5 there and set `QT_QPA_PLATFORMTHEME=qt5ct` or Setting `XDG_CURRENT_DESKTOP=GNOME` environment variable has also been reported to help in this case. This results in usage of Adwaita icon theme. +# Credits + +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. + # License This program is free software: you can redistribute it and/or modify @@ -1,4 +1,5 @@ #!/bin/sh cmake -B build . cmake --build build -sudo cp build/kdeltachat /usr/bin/kdeltachat +sudo install -vDm644 usr/* -t / +sudo install -vDm755 build/kdeltachat -t /usr/local/bin/ @@ -76,3 +76,15 @@ DcChat::getVisibility() { return dc_chat_get_visibility(m_chat); } + +void +DcChat::notifyNewMess() +{ + KNotification *newMess = new KNotification("onIncomingMessage"); + newMess->setPixmap(QPixmap(getProfileImage())); + newMess->setIconName("chat.delta.KDeltaChat"); + newMess->setComponentName("kdeltachat"); + newMess->setTitle(getName()); + newMess->setText("has sent you a message"); + newMess->sendEvent(); +} @@ -2,6 +2,9 @@ #include <QObject> #include <QColor> +#include <QPixmap> + +#include <KNotification> #include <deltachat.h> @@ -28,6 +31,7 @@ public: Q_INVOKABLE bool canSend(); Q_INVOKABLE bool isMuted(); Q_INVOKABLE int getVisibility(); + Q_INVOKABLE void notifyNewMess(); private: dc_chat_t *m_chat{nullptr}; diff --git a/context.cpp b/context.cpp index 11372d0..5729ca7 100644 --- a/context.cpp +++ b/context.cpp @@ -282,7 +282,7 @@ Context::getDraft(uint32_t chatId) } bool -Context::setChatMuteDuration(uint32_t chatId, int64_t duration) +Context::setChatMuteDuration(uint32_t chatId, int duration) { return dc_set_chat_mute_duration(m_context, chatId, duration); } @@ -51,7 +51,7 @@ public: QString getBlobdir(); Q_INVOKABLE bool setConfig(QString key, QString value); Q_INVOKABLE QString getConfig(QString key); - Q_INVOKABLE bool setChatMuteDuration(uint32_t chatId, int64_t duration); + Q_INVOKABLE bool setChatMuteDuration(uint32_t chatId, int duration); Q_INVOKABLE QString getMessageInfo(uint32_t msgId); Q_INVOKABLE QString getMessageHtml(uint32_t msgId); Q_INVOKABLE DcMessage *newMessage(int viewtype); @@ -1,5 +1,6 @@ <RCC> <qresource prefix="/"> + <file>qtquickcontrols2.conf</file> <file>qml/main.qml</file> <file>qml/AccountsPage.qml</file> <file>qml/ChatPage.qml</file> @@ -11,6 +12,8 @@ <file>qml/ComposePane.qml</file> <file>qml/HtmlViewSheet.qml</file> <file>qml/NewChatPage.qml</file> - <file>qtquickcontrols2.conf</file> + <file>knotifications5/kdeltachat.notifyrc</file> + <file>res/pin_48x48.png</file> + <file>res/muted_48x48.png</file> </qresource> </RCC> diff --git a/qml/ChatPage.qml b/qml/ChatPage.qml index b830bc0..667e01d 100644 --- a/qml/ChatPage.qml +++ b/qml/ChatPage.qml @@ -56,6 +56,8 @@ Kirigami.ScrollablePage { function onIncomingMessage(accountId, chatId, msgId) { updateMessagelist(); console.log("Incoming message for chat " + chatId); + if(!chat.muted || chatId != 0 || chatId != root.chatId) + chat.notifyNewMess(); } function onMessagesChanged(accountId, chatId, msgId) { diff --git a/qml/ChatlistItem.qml b/qml/ChatlistItem.qml index 6e37331..f0db86d 100644 --- a/qml/ChatlistItem.qml +++ b/qml/ChatlistItem.qml @@ -14,8 +14,10 @@ Kirigami.AbstractListItem { property string avatarSource property string username property int freshMsgCnt + property int visibility property bool isContactRequest property bool isPinned + property bool isMuted RowLayout { Kirigami.Avatar { @@ -34,6 +36,16 @@ Kirigami.AbstractListItem { Menu { id: contextMenu + + Action { + text: !root.isMuted ? "Mute chat" : "Unmute chat" + onTriggered: { + if (!root.isMuted) + root.context.setChatMuteDuration(root.chatId, -1) + else + root.context.setChatMuteDuration(root.chatId, 0) + } + } Action { text: "Block chat" @@ -46,23 +58,13 @@ Kirigami.AbstractListItem { Action { icon.name: "pin" - text: "Pin chat" - onTriggered: root.context.setChatVisibility(root.chatId, 2) - } - - Action { - text: "Unpin chat" - onTriggered: root.context.setChatVisibility(root.chatId, 0) + text: !root.isPinned ? "Pin chat" : "Unpin chat" + onTriggered: !root.isPinned ? root.context.setChatVisibility(root.chatId, 2) : root.context.setChatVisibility(root.chatId, 0) } Action { - text: "Archive chat" - onTriggered: root.context.setChatVisibility(root.chatId, 1) - } - - Action { - text: "Unarchive chat" - onTriggered: root.context.setChatVisibility(root.chatId, 0) + text: root.visibility != 1 ? "Archive chat" : "Unarchive chat" + onTriggered: root.visibility != 1 ? root.context.setChatVisibility(root.chatId, 1) : root.context.setChatVisibility(root.chatId, 0) } Action { @@ -111,13 +113,26 @@ Kirigami.AbstractListItem { } - // Pinned message badge - Label { + // Twemoji + // Copyright 2020 Twitter, Inc and other contributors. + // Muted chat badge + Image { + visible: root.isMuted + source: "qrc:/res/muted_48x48.png" + sourceSize.width: 24 + sourceSize.height: 24 + Layout.bottomMargin: 13 + } + + // Twemoji + // Copyright 2020 Twitter, Inc and other contributors. + // Pinned chat badge + Image { visible: root.isPinned - text: "📌" - font.pixelSize: 20 - rightPadding: 15 - bottomPadding: 15 + source: "qrc:/res/pin_48x48.png" + sourceSize.width: 24 + sourceSize.height: 24 + Layout.bottomMargin: 13 } } diff --git a/qml/ChatlistPage.qml b/qml/ChatlistPage.qml index d7e66ae..713113a 100644 --- a/qml/ChatlistPage.qml +++ b/qml/ChatlistPage.qml @@ -63,6 +63,7 @@ Kirigami.ScrollablePage { "avatarSource": profileImage ? "file:" + profileImage : "", "chatName": chat.name, "freshMsgCnt": chatlistPage.context.getFreshMsgCnt(chatId), + "isMuted" : chat.muted, "isContactRequest": chat.isContactRequest, "visibility": chat.visibility }; @@ -149,6 +150,8 @@ Kirigami.ScrollablePage { username: model.username freshMsgCnt: model.freshMsgCnt isContactRequest: model.isContactRequest + isMuted: model.isMuted + visibility: model.visibility isPinned: model.visibility == 2 width: chatlist.width onClicked: chatClicked(model.chatId) diff --git a/res/CMakeLists.txt b/res/CMakeLists.txt deleted file mode 100644 index e6512bb..0000000 --- a/res/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -install( - FILES chat.delta.KDeltaChat.png - DESTINATION share/icons/hicolor/256x256/apps/ - COMPONENT desktop) -install( - FILES chat.delta.KDeltaChat.desktop - DESTINATION share/applications/ - COMPONENT desktop) diff --git a/res/chat.delta.KDeltaChat.desktop b/res/chat.delta.KDeltaChat.desktop deleted file mode 100644 index 35c2999..0000000 --- a/res/chat.delta.KDeltaChat.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[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 |