mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +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();
|
theme_ = settings.value("user/theme", defaultTheme_).toString();
|
||||||
font_ = settings.value("user/font_family", "default").toString();
|
font_ = settings.value("user/font_family", "default").toString();
|
||||||
avatarCircles_ = settings.value("user/avatar_circles", true).toBool();
|
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();
|
emojiFont_ = settings.value("user/emoji_font_family", "default").toString();
|
||||||
baseFontSize_ = settings.value("user/font_size", QFont().pointSizeF()).toDouble();
|
baseFontSize_ = settings.value("user/font_size", QFont().pointSizeF()).toDouble();
|
||||||
|
|
||||||
|
@ -167,7 +168,7 @@ UserSettings::save()
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.setValue("avatar_circles", avatarCircles_);
|
settings.setValue("avatar_circles", avatarCircles_);
|
||||||
|
settings.setValue("decrypt_sidebar", decryptSidebar_);
|
||||||
settings.setValue("font_size", baseFontSize_);
|
settings.setValue("font_size", baseFontSize_);
|
||||||
settings.setValue("typing_notifications", isTypingNotificationsEnabled_);
|
settings.setValue("typing_notifications", isTypingNotificationsEnabled_);
|
||||||
settings.setValue("minor_events", sortByImportance_);
|
settings.setValue("minor_events", sortByImportance_);
|
||||||
|
@ -230,6 +231,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
|
||||||
trayToggle_ = new Toggle{this};
|
trayToggle_ = new Toggle{this};
|
||||||
startInTrayToggle_ = new Toggle{this};
|
startInTrayToggle_ = new Toggle{this};
|
||||||
avatarCircles_ = new Toggle{this};
|
avatarCircles_ = new Toggle{this};
|
||||||
|
decryptSidebar_ = new Toggle(this);
|
||||||
groupViewToggle_ = new Toggle{this};
|
groupViewToggle_ = new Toggle{this};
|
||||||
timelineButtonsToggle_ = new Toggle{this};
|
timelineButtonsToggle_ = new Toggle{this};
|
||||||
typingNotifications_ = new Toggle{this};
|
typingNotifications_ = new Toggle{this};
|
||||||
|
@ -335,6 +337,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
|
||||||
formLayout_->addRow(new HorizontalLine{this});
|
formLayout_->addRow(new HorizontalLine{this});
|
||||||
boxWrap(tr("Circular Avatars"), avatarCircles_);
|
boxWrap(tr("Circular Avatars"), avatarCircles_);
|
||||||
boxWrap(tr("Group's sidebar"), groupViewToggle_);
|
boxWrap(tr("Group's sidebar"), groupViewToggle_);
|
||||||
|
boxWrap(tr("Decrypt messages in sidebar"), decryptSidebar_);
|
||||||
boxWrap(tr("Show buttons in timeline"), timelineButtonsToggle_);
|
boxWrap(tr("Show buttons in timeline"), timelineButtonsToggle_);
|
||||||
boxWrap(tr("Typing notifications"), typingNotifications_);
|
boxWrap(tr("Typing notifications"), typingNotifications_);
|
||||||
boxWrap(tr("Sort rooms by unreads"), sortByImportance_);
|
boxWrap(tr("Sort rooms by unreads"), sortByImportance_);
|
||||||
|
@ -427,6 +430,10 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
|
||||||
settings_->setGroupView(!isDisabled);
|
settings_->setGroupView(!isDisabled);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(decryptSidebar_, &Toggle::toggled, this, [this](bool isDisabled) {
|
||||||
|
settings_->setDecryptSidebar(!isDisabled);
|
||||||
|
});
|
||||||
|
|
||||||
connect(avatarCircles_, &Toggle::toggled, this, [this](bool isDisabled) {
|
connect(avatarCircles_, &Toggle::toggled, this, [this](bool isDisabled) {
|
||||||
settings_->setAvatarCircles(!isDisabled);
|
settings_->setAvatarCircles(!isDisabled);
|
||||||
});
|
});
|
||||||
|
@ -479,6 +486,7 @@ UserSettingsPage::showEvent(QShowEvent *)
|
||||||
trayToggle_->setState(!settings_->isTrayEnabled());
|
trayToggle_->setState(!settings_->isTrayEnabled());
|
||||||
startInTrayToggle_->setState(!settings_->isStartInTrayEnabled());
|
startInTrayToggle_->setState(!settings_->isStartInTrayEnabled());
|
||||||
groupViewToggle_->setState(!settings_->isGroupViewEnabled());
|
groupViewToggle_->setState(!settings_->isGroupViewEnabled());
|
||||||
|
decryptSidebar_->setState(!settings_->isDecryptSidebarEnabled());
|
||||||
avatarCircles_->setState(!settings_->isAvatarCirclesEnabled());
|
avatarCircles_->setState(!settings_->isAvatarCirclesEnabled());
|
||||||
typingNotifications_->setState(!settings_->isTypingNotificationsEnabled());
|
typingNotifications_->setState(!settings_->isTypingNotificationsEnabled());
|
||||||
sortByImportance_->setState(!settings_->isSortByImportanceEnabled());
|
sortByImportance_->setState(!settings_->isSortByImportanceEnabled());
|
||||||
|
|
|
@ -111,11 +111,18 @@ public:
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setDecryptSidebar(bool state)
|
||||||
|
{
|
||||||
|
decryptSidebar_ = state;
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
QString theme() const { return !theme_.isEmpty() ? theme_ : defaultTheme_; }
|
QString theme() const { return !theme_.isEmpty() ? theme_ : defaultTheme_; }
|
||||||
bool isTrayEnabled() const { return isTrayEnabled_; }
|
bool isTrayEnabled() const { return isTrayEnabled_; }
|
||||||
bool isStartInTrayEnabled() const { return isStartInTrayEnabled_; }
|
bool isStartInTrayEnabled() const { return isStartInTrayEnabled_; }
|
||||||
bool isGroupViewEnabled() const { return isGroupViewEnabled_; }
|
bool isGroupViewEnabled() const { return isGroupViewEnabled_; }
|
||||||
bool isAvatarCirclesEnabled() const { return avatarCircles_; }
|
bool isAvatarCirclesEnabled() const { return avatarCircles_; }
|
||||||
|
bool isDecryptSidebarEnabled() const { return decryptSidebar_; }
|
||||||
bool isMarkdownEnabled() const { return isMarkdownEnabled_; }
|
bool isMarkdownEnabled() const { return isMarkdownEnabled_; }
|
||||||
bool isTypingNotificationsEnabled() const { return isTypingNotificationsEnabled_; }
|
bool isTypingNotificationsEnabled() const { return isTypingNotificationsEnabled_; }
|
||||||
bool isSortByImportanceEnabled() const { return sortByImportance_; }
|
bool isSortByImportanceEnabled() const { return sortByImportance_; }
|
||||||
|
@ -147,6 +154,7 @@ private:
|
||||||
bool isReadReceiptsEnabled_;
|
bool isReadReceiptsEnabled_;
|
||||||
bool hasDesktopNotifications_;
|
bool hasDesktopNotifications_;
|
||||||
bool avatarCircles_;
|
bool avatarCircles_;
|
||||||
|
bool decryptSidebar_;
|
||||||
double baseFontSize_;
|
double baseFontSize_;
|
||||||
QString font_;
|
QString font_;
|
||||||
QString emojiFont_;
|
QString emojiFont_;
|
||||||
|
@ -199,6 +207,7 @@ private:
|
||||||
Toggle *markdownEnabled_;
|
Toggle *markdownEnabled_;
|
||||||
Toggle *desktopNotifications_;
|
Toggle *desktopNotifications_;
|
||||||
Toggle *avatarCircles_;
|
Toggle *avatarCircles_;
|
||||||
|
Toggle *decryptSidebar_;
|
||||||
QLabel *deviceFingerprintValue_;
|
QLabel *deviceFingerprintValue_;
|
||||||
QLabel *deviceIdValue_;
|
QLabel *deviceIdValue_;
|
||||||
|
|
||||||
|
|
|
@ -306,5 +306,4 @@ centerWidget(QWidget *widget, QWidget *parent);
|
||||||
|
|
||||||
void
|
void
|
||||||
restoreCombobox(QComboBox *combo, const QString &value);
|
restoreCombobox(QComboBox *combo, const QString &value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMimeDatabase>
|
#include <QMimeDatabase>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
#include <QSettings>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
#include "ChatPage.h"
|
#include "ChatPage.h"
|
||||||
|
@ -504,11 +505,15 @@ isMessage(const mtx::events::Event<T> &)
|
||||||
void
|
void
|
||||||
TimelineModel::updateLastMessage()
|
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) {
|
for (auto it = eventOrder.begin(); it != eventOrder.end(); ++it) {
|
||||||
auto event = events.value(*it);
|
auto event = events.value(*it);
|
||||||
if (auto e = std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
|
if (auto e = std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
|
||||||
&event)) {
|
&event)) {
|
||||||
event = decryptEvent(*e).event;
|
if (decrypt) {
|
||||||
|
event = decryptEvent(*e).event;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!std::visit([](const auto &e) -> bool { return isMessage(e); }, event))
|
if (!std::visit([](const auto &e) -> bool { return isMessage(e); }, event))
|
||||||
|
|
Loading…
Reference in a new issue