diff options
author | Joseph Donofry <joedonofry@gmail.com> | 2020-04-22 19:52:30 -0400 |
---|---|---|
committer | Joseph Donofry <joedonofry@gmail.com> | 2020-04-22 19:52:30 -0400 |
commit | b298f01d92eac2f7af6fce28cbe5256411e6c386 (patch) | |
tree | f935539dea236e5dfc733906bfab513e4be4cc0b | |
parent | a4c280a4f927df7de5445d19419fa77f2b603f27 (diff) |
Add signal/slot for decryption changes in last patch
-rw-r--r-- | src/ChatPage.h | 1 | ||||
-rw-r--r-- | src/MainWindow.cpp | 4 | ||||
-rw-r--r-- | src/Olm.cpp | 2 | ||||
-rw-r--r-- | src/UserSettingsPage.cpp | 1 | ||||
-rw-r--r-- | src/UserSettingsPage.h | 1 | ||||
-rw-r--r-- | src/timeline/TimelineModel.cpp | 7 | ||||
-rw-r--r-- | src/timeline/TimelineModel.h | 2 | ||||
-rw-r--r-- | src/timeline/TimelineViewManager.cpp | 17 | ||||
-rw-r--r-- | src/timeline/TimelineViewManager.h | 1 |
9 files changed, 34 insertions, 2 deletions
diff --git a/src/ChatPage.h b/src/ChatPage.h index 5182ab99..46630692 100644 --- a/src/ChatPage.h +++ b/src/ChatPage.h @@ -153,6 +153,7 @@ signals: void updateGroupsInfo(const mtx::responses::JoinedGroups &groups); void themeChanged(); + void decryptSidebarChanged(); private slots: void showUnreadMessageNotification(int count); diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index fb64f0fe..c6abdca2 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -117,6 +117,10 @@ MainWindow::MainWindow(QWidget *parent) userSettingsPage_, SIGNAL(trayOptionChanged(bool)), trayIcon_, SLOT(setVisible(bool))); connect( userSettingsPage_, &UserSettingsPage::themeChanged, chat_page_, &ChatPage::themeChanged); + connect(userSettingsPage_, + &UserSettingsPage::decryptSidebarChanged, + chat_page_, + &ChatPage::decryptSidebarChanged); connect(trayIcon_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, diff --git a/src/Olm.cpp b/src/Olm.cpp index 78b16be7..c8e4c13c 100644 --- a/src/Olm.cpp +++ b/src/Olm.cpp @@ -184,7 +184,7 @@ encrypt_group_message(const std::string &room_id, const std::string &device_id, data.relates_to = relation; auto message_index = olm_outbound_group_session_message_index(res.session); - nhlog::crypto()->info("next message_index {}", message_index); + nhlog::crypto()->debug("next message_index {}", message_index); // We need to re-pickle the session after we send a message to save the new message_index. cache::updateOutboundMegolmSession(room_id, message_index); diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp index 537054c7..4db883f5 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp @@ -432,6 +432,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge connect(decryptSidebar_, &Toggle::toggled, this, [this](bool isDisabled) { settings_->setDecryptSidebar(!isDisabled); + emit decryptSidebarChanged(); }); connect(avatarCircles_, &Toggle::toggled, this, [this](bool isDisabled) { diff --git a/src/UserSettingsPage.h b/src/UserSettingsPage.h index aff2525a..6b9834ea 100644 --- a/src/UserSettingsPage.h +++ b/src/UserSettingsPage.h @@ -183,6 +183,7 @@ signals: void moveBack(); void trayOptionChanged(bool value); void themeChanged(); + void decryptSidebarChanged(); private slots: void importSessionKeys(); diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 439a7786..3e2c32fa 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -502,6 +502,13 @@ isMessage(const mtx::events::Event<T> &) return false; } +template<typename T> +auto +isMessage(const mtx::events::EncryptedEvent<T> &) +{ + return true; +} + void TimelineModel::updateLastMessage() { diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h index 84e9ec26..98b183f6 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h @@ -189,6 +189,7 @@ public: Q_INVOKABLE void cacheMedia(QString eventId); Q_INVOKABLE bool saveMedia(QString eventId) const; + void updateLastMessage(); void addEvents(const mtx::responses::Timeline &events); template<class T> void sendMessage(const T &msg); @@ -257,7 +258,6 @@ private: const std::string &user_id, const mtx::responses::ClaimKeys &res, mtx::http::RequestErr err); - void updateLastMessage(); void readEvent(const std::string &id); QHash<QString, mtx::events::collections::TimelineEvents> events; diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index 0a339825..4562dd67 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -17,6 +17,19 @@ Q_DECLARE_METATYPE(mtx::events::collections::TimelineEvents) void +TimelineViewManager::updateEncryptedDescriptions() +{ + QHash<QString, QSharedPointer<TimelineModel>>::iterator i; + for (i = models.begin(); i != models.end(); ++i) { + auto ptr = i.value(); + + if (!ptr.isNull()) { + ptr->updateLastMessage(); + } + } +} + +void TimelineViewManager::updateColorPalette() { userColors.clear(); @@ -83,6 +96,10 @@ TimelineViewManager::TimelineViewManager(QSharedPointer<UserSettings> userSettin &ChatPage::themeChanged, this, &TimelineViewManager::updateColorPalette); + connect(dynamic_cast<ChatPage *>(parent), + &ChatPage::decryptSidebarChanged, + this, + &TimelineViewManager::updateEncryptedDescriptions); } void diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h index 122e4aec..45a603af 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h @@ -84,6 +84,7 @@ public slots: const QString &url, const QString &mime, uint64_t dsize); + void updateEncryptedDescriptions(); private: #ifdef USE_QUICK_VIEW |