mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Add ability to toggle sidebar messages for encrypted rooms
This commit is contained in:
parent
0e1bb5137b
commit
a4c280a4f9
4 changed files with 24 additions and 3 deletions
|
@ -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());
|
||||
|
|
|
@ -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_;
|
||||
|
||||
|
|
|
@ -306,5 +306,4 @@ centerWidget(QWidget *widget, QWidget *parent);
|
|||
|
||||
void
|
||||
restoreCombobox(QComboBox *combo, const QString &value);
|
||||
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue