From b298f01d92eac2f7af6fce28cbe5256411e6c386 Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Wed, 22 Apr 2020 19:52:30 -0400 Subject: Add signal/slot for decryption changes in last patch --- src/timeline/TimelineViewManager.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/timeline/TimelineViewManager.cpp') 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 @@ -16,6 +16,19 @@ Q_DECLARE_METATYPE(mtx::events::collections::TimelineEvents) +void +TimelineViewManager::updateEncryptedDescriptions() +{ + QHash>::iterator i; + for (i = models.begin(); i != models.end(); ++i) { + auto ptr = i.value(); + + if (!ptr.isNull()) { + ptr->updateLastMessage(); + } + } +} + void TimelineViewManager::updateColorPalette() { @@ -83,6 +96,10 @@ TimelineViewManager::TimelineViewManager(QSharedPointer userSettin &ChatPage::themeChanged, this, &TimelineViewManager::updateColorPalette); + connect(dynamic_cast(parent), + &ChatPage::decryptSidebarChanged, + this, + &TimelineViewManager::updateEncryptedDescriptions); } void -- cgit 1.4.1 From 994edb836c0e812933cabf5e0b57f2f8aaaba9a7 Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Thu, 23 Apr 2020 19:05:44 -0400 Subject: Change how decrypt value is retrieved from settings --- .gitignore | 4 +++- src/timeline/TimelineModel.cpp | 6 ++++++ src/timeline/TimelineModel.h | 3 ++- src/timeline/TimelineViewManager.cpp | 3 ++- 4 files changed, 13 insertions(+), 3 deletions(-) (limited to 'src/timeline/TimelineViewManager.cpp') diff --git a/.gitignore b/.gitignore index 6d178679..5f6725db 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ cscope* /.ccls-cache /.exrc .gdb_history +.hunter # GTAGS GTAGS @@ -70,7 +71,8 @@ install_manifest.txt .LSOverride # Icon must end with two \r -Icon +Icon + # Thumbnails ._* diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index ff1f324e..75819532 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -514,6 +514,12 @@ TimelineModel::updateLastMessage() { // Get the user setting to show decrypted messages in side bar bool decrypt = QSettings().value("user/decrypt_sidebar", true).toBool(); + updateLastMessage(decrypt); +} + +void +TimelineModel::updateLastMessage(bool decrypt) +{ for (auto it = eventOrder.begin(); it != eventOrder.end(); ++it) { auto event = events.value(*it); if (auto e = std::get_if>( diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h index 98b183f6..135b31ff 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h @@ -189,7 +189,7 @@ public: Q_INVOKABLE void cacheMedia(QString eventId); Q_INVOKABLE bool saveMedia(QString eventId) const; - void updateLastMessage(); + void updateLastMessage(bool); void addEvents(const mtx::responses::Timeline &events); template void sendMessage(const T &msg); @@ -259,6 +259,7 @@ private: const mtx::responses::ClaimKeys &res, mtx::http::RequestErr err); void readEvent(const std::string &id); + void updateLastMessage(); QHash events; QSet read; diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index 4562dd67..3c870e36 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -19,12 +19,13 @@ Q_DECLARE_METATYPE(mtx::events::collections::TimelineEvents) void TimelineViewManager::updateEncryptedDescriptions() { + auto decrypt = settings->isDecryptSidebarEnabled(); QHash>::iterator i; for (i = models.begin(); i != models.end(); ++i) { auto ptr = i.value(); if (!ptr.isNull()) { - ptr->updateLastMessage(); + ptr->updateLastMessage(decrypt); } } } -- cgit 1.4.1 From 58933654391c699951b322a153bcc3a85bf40552 Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Thu, 23 Apr 2020 19:21:20 -0400 Subject: Change decrypt setting again --- src/timeline/TimelineModel.cpp | 10 +--------- src/timeline/TimelineModel.h | 5 +++-- src/timeline/TimelineViewManager.cpp | 5 ++++- 3 files changed, 8 insertions(+), 12 deletions(-) (limited to 'src/timeline/TimelineViewManager.cpp') diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 75819532..e3a1a781 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -511,20 +511,12 @@ isMessage(const mtx::events::EncryptedEvent &) void TimelineModel::updateLastMessage() -{ - // Get the user setting to show decrypted messages in side bar - bool decrypt = QSettings().value("user/decrypt_sidebar", true).toBool(); - updateLastMessage(decrypt); -} - -void -TimelineModel::updateLastMessage(bool decrypt) { for (auto it = eventOrder.begin(); it != eventOrder.end(); ++it) { auto event = events.value(*it); if (auto e = std::get_if>( &event)) { - if (decrypt) { + if (decryptDescription) { event = decryptEvent(*e).event; } } diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h index 135b31ff..ae468c09 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h @@ -189,7 +189,7 @@ public: Q_INVOKABLE void cacheMedia(QString eventId); Q_INVOKABLE bool saveMedia(QString eventId) const; - void updateLastMessage(bool); + void updateLastMessage(); void addEvents(const mtx::responses::Timeline &events); template void sendMessage(const T &msg); @@ -224,6 +224,7 @@ public slots: emit replyChanged(reply_); } } + void setDecryptDescription(bool decrypt) { decryptDescription = decrypt; } private slots: // Add old events at the top of the timeline. @@ -259,7 +260,6 @@ private: const mtx::responses::ClaimKeys &res, mtx::http::RequestErr err); void readEvent(const std::string &id); - void updateLastMessage(); QHash events; QSet read; @@ -271,6 +271,7 @@ private: bool isInitialSync = true; bool paginationInProgress = false; + bool decryptDescription = true; QString currentId; QString reply_; diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index 3c870e36..b9565be8 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -25,7 +25,8 @@ TimelineViewManager::updateEncryptedDescriptions() auto ptr = i.value(); if (!ptr.isNull()) { - ptr->updateLastMessage(decrypt); + ptr->setDecryptDescription(decrypt); + ptr->updateLastMessage(); } } } @@ -132,6 +133,8 @@ TimelineViewManager::addRoom(const QString &room_id) { if (!models.contains(room_id)) { QSharedPointer newRoom(new TimelineModel(this, room_id)); + newRoom->setDecryptDescription(settings->isDecryptSidebarEnabled()); + connect(newRoom.data(), &TimelineModel::newEncryptedImage, imgProvider, -- cgit 1.4.1