summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/UserSettingsPage.cpp10
-rw-r--r--src/UserSettingsPage.h9
-rw-r--r--src/Utils.h1
-rw-r--r--src/timeline/TimelineModel.cpp7
4 files changed, 24 insertions, 3 deletions
diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp
index b4f4cb45..537054c7 100644
--- a/src/UserSettingsPage.cpp
+++ b/src/UserSettingsPage.cpp
@@ -63,6 +63,7 @@ UserSettings::load()
         theme_                        = settings.value("user/theme", defaultTheme_).toString();
         font_                         = settings.value("user/font_family", "default").toString();
         avatarCircles_                = settings.value("user/avatar_circles", true).toBool();
+        decryptSidebar_               = settings.value("user/decrypt_sidebar", true).toBool();
         emojiFont_    = settings.value("user/emoji_font_family", "default").toString();
         baseFontSize_ = settings.value("user/font_size", QFont().pointSizeF()).toDouble();
 
@@ -167,7 +168,7 @@ UserSettings::save()
         settings.endGroup();
 
         settings.setValue("avatar_circles", avatarCircles_);
-
+        settings.setValue("decrypt_sidebar", decryptSidebar_);
         settings.setValue("font_size", baseFontSize_);
         settings.setValue("typing_notifications", isTypingNotificationsEnabled_);
         settings.setValue("minor_events", sortByImportance_);
@@ -230,6 +231,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
         trayToggle_              = new Toggle{this};
         startInTrayToggle_       = new Toggle{this};
         avatarCircles_           = new Toggle{this};
+        decryptSidebar_          = new Toggle(this);
         groupViewToggle_         = new Toggle{this};
         timelineButtonsToggle_   = new Toggle{this};
         typingNotifications_     = new Toggle{this};
@@ -335,6 +337,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
         formLayout_->addRow(new HorizontalLine{this});
         boxWrap(tr("Circular Avatars"), avatarCircles_);
         boxWrap(tr("Group's sidebar"), groupViewToggle_);
+        boxWrap(tr("Decrypt messages in sidebar"), decryptSidebar_);
         boxWrap(tr("Show buttons in timeline"), timelineButtonsToggle_);
         boxWrap(tr("Typing notifications"), typingNotifications_);
         boxWrap(tr("Sort rooms by unreads"), sortByImportance_);
@@ -427,6 +430,10 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
                 settings_->setGroupView(!isDisabled);
         });
 
+        connect(decryptSidebar_, &Toggle::toggled, this, [this](bool isDisabled) {
+                settings_->setDecryptSidebar(!isDisabled);
+        });
+
         connect(avatarCircles_, &Toggle::toggled, this, [this](bool isDisabled) {
                 settings_->setAvatarCircles(!isDisabled);
         });
@@ -479,6 +486,7 @@ UserSettingsPage::showEvent(QShowEvent *)
         trayToggle_->setState(!settings_->isTrayEnabled());
         startInTrayToggle_->setState(!settings_->isStartInTrayEnabled());
         groupViewToggle_->setState(!settings_->isGroupViewEnabled());
+        decryptSidebar_->setState(!settings_->isDecryptSidebarEnabled());
         avatarCircles_->setState(!settings_->isAvatarCirclesEnabled());
         typingNotifications_->setState(!settings_->isTypingNotificationsEnabled());
         sortByImportance_->setState(!settings_->isSortByImportanceEnabled());
diff --git a/src/UserSettingsPage.h b/src/UserSettingsPage.h
index 1c20214e..aff2525a 100644
--- a/src/UserSettingsPage.h
+++ b/src/UserSettingsPage.h
@@ -111,11 +111,18 @@ public:
                 save();
         }
 
+        void setDecryptSidebar(bool state)
+        {
+                decryptSidebar_ = state;
+                save();
+        }
+
         QString theme() const { return !theme_.isEmpty() ? theme_ : defaultTheme_; }
         bool isTrayEnabled() const { return isTrayEnabled_; }
         bool isStartInTrayEnabled() const { return isStartInTrayEnabled_; }
         bool isGroupViewEnabled() const { return isGroupViewEnabled_; }
         bool isAvatarCirclesEnabled() const { return avatarCircles_; }
+        bool isDecryptSidebarEnabled() const { return decryptSidebar_; }
         bool isMarkdownEnabled() const { return isMarkdownEnabled_; }
         bool isTypingNotificationsEnabled() const { return isTypingNotificationsEnabled_; }
         bool isSortByImportanceEnabled() const { return sortByImportance_; }
@@ -147,6 +154,7 @@ private:
         bool isReadReceiptsEnabled_;
         bool hasDesktopNotifications_;
         bool avatarCircles_;
+        bool decryptSidebar_;
         double baseFontSize_;
         QString font_;
         QString emojiFont_;
@@ -199,6 +207,7 @@ private:
         Toggle *markdownEnabled_;
         Toggle *desktopNotifications_;
         Toggle *avatarCircles_;
+        Toggle *decryptSidebar_;
         QLabel *deviceFingerprintValue_;
         QLabel *deviceIdValue_;
 
diff --git a/src/Utils.h b/src/Utils.h
index a3854dd8..663d5a38 100644
--- a/src/Utils.h
+++ b/src/Utils.h
@@ -306,5 +306,4 @@ centerWidget(QWidget *widget, QWidget *parent);
 
 void
 restoreCombobox(QComboBox *combo, const QString &value);
-
 }
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index bb793945..439a7786 100644
--- a/src/timeline/TimelineModel.cpp
+++ b/src/timeline/TimelineModel.cpp
@@ -8,6 +8,7 @@
 #include <QFileDialog>
 #include <QMimeDatabase>
 #include <QRegularExpression>
+#include <QSettings>
 #include <QStandardPaths>
 
 #include "ChatPage.h"
@@ -504,11 +505,15 @@ isMessage(const mtx::events::Event<T> &)
 void
 TimelineModel::updateLastMessage()
 {
+        // Get the user setting to show decrypted messages in side bar
+        bool decrypt = QSettings().value("user/decrypt_sidebar", true).toBool();
         for (auto it = eventOrder.begin(); it != eventOrder.end(); ++it) {
                 auto event = events.value(*it);
                 if (auto e = std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
                       &event)) {
-                        event = decryptEvent(*e).event;
+                        if (decrypt) {
+                                event = decryptEvent(*e).event;
+                        }
                 }
 
                 if (!std::visit([](const auto &e) -> bool { return isMessage(e); }, event))