From d39b1c4a10f66b79539b39da0a2e395b9523bf47 Mon Sep 17 00:00:00 2001 From: "Sebastian J. Wolf" Date: Tue, 15 Sep 2020 21:17:44 +0200 Subject: [PATCH] Open chat directly from notification --- qml/pages/OverviewPage.qml | 15 ++++++++++++++- src/tdlibwrapper.cpp | 6 ++++++ src/tdlibwrapper.h | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/qml/pages/OverviewPage.qml b/qml/pages/OverviewPage.qml index f647713..dbae907 100644 --- a/qml/pages/OverviewPage.qml +++ b/qml/pages/OverviewPage.qml @@ -43,6 +43,19 @@ Page { } } + Connections { + target: dBusAdaptor + onPleaseOpenMessage: { + console.log("[OverviewPage] Opening chat from external call...") + if (chatListCreated) { + if (status !== PageStatus.Active) { + pageStack.pop(pageStack.find( function(page){ return(page._depth === 0)} ), PageStackAction.Immediate); + } + pageStack.push(Qt.resolvedUrl("../pages/ChatPage.qml"), { "chatInformation" : tdLibWrapper.getChat(chatId) }); + } + } + } + Timer { id: chatListCreatedTimer interval: 500 @@ -201,7 +214,7 @@ Page { model: chatListModel delegate: ListItem { - id: chatListItem + id: chatListViewItem contentHeight: chatListRow.height + chatListSeparator.height + 2 * Theme.paddingMedium contentWidth: parent.width diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 6ea44bf..5150636 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -271,6 +271,12 @@ QVariantMap TDLibWrapper::getSuperGroup(const QString &groupId) return this->superGroups.value(groupId).toMap(); } +QVariantMap TDLibWrapper::getChat(const QString &chatId) +{ + qDebug() << "[TDLibWrapper] Returning chat information for ID " << chatId; + return this->chats.value(chatId).toMap(); +} + void TDLibWrapper::copyFileToDownloads(const QString &filePath) { qDebug() << "[TDLibWrapper] Copy file to downloads " << filePath; diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index 19ae049..d652cb0 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -69,6 +69,7 @@ public: Q_INVOKABLE QVariantMap getUnreadChatInformation(); Q_INVOKABLE QVariantMap getBasicGroup(const QString &groupId); Q_INVOKABLE QVariantMap getSuperGroup(const QString &groupId); + Q_INVOKABLE QVariantMap getChat(const QString &chatId); Q_INVOKABLE void copyFileToDownloads(const QString &filePath); Q_INVOKABLE void openFileOnDevice(const QString &filePath); Q_INVOKABLE void controlScreenSaver(const bool &enabled);