mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 21:18:48 +03:00
Added toggle in the settings to ignore minor events
This commit is contained in:
parent
81c9cb5c79
commit
b6bd36ac16
7 changed files with 46 additions and 13 deletions
|
@ -100,7 +100,7 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
||||||
|
|
||||||
user_info_widget_ = new UserInfoWidget(sideBar_);
|
user_info_widget_ = new UserInfoWidget(sideBar_);
|
||||||
user_mentions_popup_ = new popups::UserMentions();
|
user_mentions_popup_ = new popups::UserMentions();
|
||||||
room_list_ = new RoomList(sideBar_);
|
room_list_ = new RoomList(userSettings, sideBar_);
|
||||||
connect(room_list_, &RoomList::joinRoom, this, &ChatPage::joinRoom);
|
connect(room_list_, &RoomList::joinRoom, this, &ChatPage::joinRoom);
|
||||||
|
|
||||||
sideBarLayout_->addWidget(user_info_widget_);
|
sideBarLayout_->addWidget(user_info_widget_);
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "RoomInfoListItem.h"
|
#include "RoomInfoListItem.h"
|
||||||
#include "Splitter.h"
|
#include "Splitter.h"
|
||||||
|
#include "UserSettingsPage.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "ui/Menu.h"
|
#include "ui/Menu.h"
|
||||||
#include "ui/Ripple.h"
|
#include "ui/Ripple.h"
|
||||||
|
@ -99,7 +100,10 @@ RoomInfoListItem::init(QWidget *parent)
|
||||||
menu_->addAction(leaveRoom_);
|
menu_->addAction(leaveRoom_);
|
||||||
}
|
}
|
||||||
|
|
||||||
RoomInfoListItem::RoomInfoListItem(QString room_id, const RoomInfo &info, QWidget *parent)
|
RoomInfoListItem::RoomInfoListItem(QString room_id,
|
||||||
|
const RoomInfo &info,
|
||||||
|
QSharedPointer<UserSettings> userSettings,
|
||||||
|
QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, roomType_{info.is_invite ? RoomType::Invited : RoomType::Joined}
|
, roomType_{info.is_invite ? RoomType::Invited : RoomType::Joined}
|
||||||
, roomId_(std::move(room_id))
|
, roomId_(std::move(room_id))
|
||||||
|
@ -107,6 +111,7 @@ RoomInfoListItem::RoomInfoListItem(QString room_id, const RoomInfo &info, QWidge
|
||||||
, isPressed_(false)
|
, isPressed_(false)
|
||||||
, unreadMsgCount_(0)
|
, unreadMsgCount_(0)
|
||||||
, unreadHighlightedMsgCount_(0)
|
, unreadHighlightedMsgCount_(0)
|
||||||
|
, settings(userSettings)
|
||||||
{
|
{
|
||||||
init(parent);
|
init(parent);
|
||||||
}
|
}
|
||||||
|
@ -336,18 +341,16 @@ enum NotificationImportance : unsigned short
|
||||||
unsigned short int
|
unsigned short int
|
||||||
RoomInfoListItem::calculateImportance() const
|
RoomInfoListItem::calculateImportance() const
|
||||||
{
|
{
|
||||||
// 0: All messages and minor events read
|
// Returns the degree of importance of the unread messages in the room.
|
||||||
// 1: Contains unread minor events (joins/notices/muted messages)
|
// If ignoreMinorEvents is set to true in the settings, then
|
||||||
// 2: Contains unread messages
|
// NewMinorEvents will always be rounded down to AllEventsRead
|
||||||
// 3: Contains mentions
|
|
||||||
// 4: Is a room invite
|
|
||||||
if (isInvite()) {
|
if (isInvite()) {
|
||||||
return Invite;
|
return Invite;
|
||||||
} else if (unreadHighlightedMsgCount_) {
|
} else if (unreadHighlightedMsgCount_) {
|
||||||
return NewMentions;
|
return NewMentions;
|
||||||
} else if (unreadMsgCount_) {
|
} else if (unreadMsgCount_) {
|
||||||
return NewMessage;
|
return NewMessage;
|
||||||
} else if (hasUnreadMessages_) {
|
} else if (hasUnreadMessages_ && !settings->isIgnoreMinorEventsEnabled()) {
|
||||||
return NewMinorEvents;
|
return NewMinorEvents;
|
||||||
} else {
|
} else {
|
||||||
return AllEventsRead;
|
return AllEventsRead;
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <mtx/responses.hpp>
|
#include <mtx/responses.hpp>
|
||||||
|
|
||||||
#include "CacheStructs.h"
|
#include "CacheStructs.h"
|
||||||
|
#include "UserSettingsPage.h"
|
||||||
#include "ui/Avatar.h"
|
#include "ui/Avatar.h"
|
||||||
|
|
||||||
class Menu;
|
class Menu;
|
||||||
|
@ -63,7 +64,10 @@ class RoomInfoListItem : public QWidget
|
||||||
Q_PROPERTY(QColor btnTextColor READ btnTextColor WRITE setBtnTextColor)
|
Q_PROPERTY(QColor btnTextColor READ btnTextColor WRITE setBtnTextColor)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RoomInfoListItem(QString room_id, const RoomInfo &info, QWidget *parent = nullptr);
|
RoomInfoListItem(QString room_id,
|
||||||
|
const RoomInfo &info,
|
||||||
|
QSharedPointer<UserSettings> userSettings,
|
||||||
|
QWidget *parent = nullptr);
|
||||||
|
|
||||||
void updateUnreadMessageCount(int count, int highlightedCount);
|
void updateUnreadMessageCount(int count, int highlightedCount);
|
||||||
void clearUnreadMessageCount() { updateUnreadMessageCount(0, 0); };
|
void clearUnreadMessageCount() { updateUnreadMessageCount(0, 0); };
|
||||||
|
@ -216,4 +220,6 @@ private:
|
||||||
|
|
||||||
QColor bubbleBgColor_;
|
QColor bubbleBgColor_;
|
||||||
QColor bubbleFgColor_;
|
QColor bubbleFgColor_;
|
||||||
|
|
||||||
|
QSharedPointer<UserSettings> settings;
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,11 +27,13 @@
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "RoomInfoListItem.h"
|
#include "RoomInfoListItem.h"
|
||||||
#include "RoomList.h"
|
#include "RoomList.h"
|
||||||
|
#include "UserSettingsPage.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "ui/OverlayModal.h"
|
#include "ui/OverlayModal.h"
|
||||||
|
|
||||||
RoomList::RoomList(QWidget *parent)
|
RoomList::RoomList(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
|
, settings(userSettings)
|
||||||
{
|
{
|
||||||
topLayout_ = new QVBoxLayout(this);
|
topLayout_ = new QVBoxLayout(this);
|
||||||
topLayout_->setSpacing(0);
|
topLayout_->setSpacing(0);
|
||||||
|
@ -68,7 +70,7 @@ RoomList::RoomList(QWidget *parent)
|
||||||
void
|
void
|
||||||
RoomList::addRoom(const QString &room_id, const RoomInfo &info)
|
RoomList::addRoom(const QString &room_id, const RoomInfo &info)
|
||||||
{
|
{
|
||||||
auto room_item = new RoomInfoListItem(room_id, info, scrollArea_);
|
auto room_item = new RoomInfoListItem(room_id, info, settings, scrollArea_);
|
||||||
room_item->setRoomName(QString::fromStdString(std::move(info.name)));
|
room_item->setRoomName(QString::fromStdString(std::move(info.name)));
|
||||||
|
|
||||||
connect(room_item, &RoomInfoListItem::clicked, this, &RoomList::highlightSelectedRoom);
|
connect(room_item, &RoomInfoListItem::clicked, this, &RoomList::highlightSelectedRoom);
|
||||||
|
@ -492,7 +494,7 @@ RoomList::updateRoom(const QString &room_id, const RoomInfo &info)
|
||||||
void
|
void
|
||||||
RoomList::addInvitedRoom(const QString &room_id, const RoomInfo &info)
|
RoomList::addInvitedRoom(const QString &room_id, const RoomInfo &info)
|
||||||
{
|
{
|
||||||
auto room_item = new RoomInfoListItem(room_id, info, scrollArea_);
|
auto room_item = new RoomInfoListItem(room_id, info, settings, scrollArea_);
|
||||||
|
|
||||||
connect(room_item, &RoomInfoListItem::acceptInvite, this, &RoomList::acceptInvite);
|
connect(room_item, &RoomInfoListItem::acceptInvite, this, &RoomList::acceptInvite);
|
||||||
connect(room_item, &RoomInfoListItem::declineInvite, this, &RoomList::declineInvite);
|
connect(room_item, &RoomInfoListItem::declineInvite, this, &RoomList::declineInvite);
|
||||||
|
|
|
@ -23,6 +23,9 @@
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "CacheStructs.h"
|
||||||
|
#include "UserSettingsPage.h"
|
||||||
|
|
||||||
class LeaveRoomDialog;
|
class LeaveRoomDialog;
|
||||||
class OverlayModal;
|
class OverlayModal;
|
||||||
class RoomInfoListItem;
|
class RoomInfoListItem;
|
||||||
|
@ -35,7 +38,7 @@ class RoomList : public QWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RoomList(QWidget *parent = nullptr);
|
explicit RoomList(QSharedPointer<UserSettings> userSettings, QWidget *parent = nullptr);
|
||||||
|
|
||||||
void initialize(const QMap<QString, RoomInfo> &info);
|
void initialize(const QMap<QString, RoomInfo> &info);
|
||||||
void sync(const std::map<QString, RoomInfo> &info);
|
void sync(const std::map<QString, RoomInfo> &info);
|
||||||
|
@ -100,4 +103,5 @@ private:
|
||||||
QString selectedRoom_;
|
QString selectedRoom_;
|
||||||
|
|
||||||
bool isSortPending_ = false;
|
bool isSortPending_ = false;
|
||||||
|
QSharedPointer<UserSettings> settings;
|
||||||
};
|
};
|
||||||
|
|
|
@ -57,6 +57,7 @@ UserSettings::load()
|
||||||
isGroupViewEnabled_ = settings.value("user/group_view", true).toBool();
|
isGroupViewEnabled_ = settings.value("user/group_view", true).toBool();
|
||||||
isMarkdownEnabled_ = settings.value("user/markdown_enabled", true).toBool();
|
isMarkdownEnabled_ = settings.value("user/markdown_enabled", true).toBool();
|
||||||
isTypingNotificationsEnabled_ = settings.value("user/typing_notifications", true).toBool();
|
isTypingNotificationsEnabled_ = settings.value("user/typing_notifications", true).toBool();
|
||||||
|
ignoreMinorEvents_ = settings.value("user/minor_events", false).toBool();
|
||||||
isReadReceiptsEnabled_ = settings.value("user/read_receipts", true).toBool();
|
isReadReceiptsEnabled_ = settings.value("user/read_receipts", true).toBool();
|
||||||
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();
|
||||||
|
@ -130,6 +131,7 @@ UserSettings::save()
|
||||||
|
|
||||||
settings.setValue("font_size", baseFontSize_);
|
settings.setValue("font_size", baseFontSize_);
|
||||||
settings.setValue("typing_notifications", isTypingNotificationsEnabled_);
|
settings.setValue("typing_notifications", isTypingNotificationsEnabled_);
|
||||||
|
settings.setValue("minor_events", ignoreMinorEvents_);
|
||||||
settings.setValue("read_receipts", isReadReceiptsEnabled_);
|
settings.setValue("read_receipts", isReadReceiptsEnabled_);
|
||||||
settings.setValue("group_view", isGroupViewEnabled_);
|
settings.setValue("group_view", isGroupViewEnabled_);
|
||||||
settings.setValue("markdown_enabled", isMarkdownEnabled_);
|
settings.setValue("markdown_enabled", isMarkdownEnabled_);
|
||||||
|
@ -191,6 +193,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
|
||||||
avatarCircles_ = new Toggle{this};
|
avatarCircles_ = new Toggle{this};
|
||||||
groupViewToggle_ = new Toggle{this};
|
groupViewToggle_ = new Toggle{this};
|
||||||
typingNotifications_ = new Toggle{this};
|
typingNotifications_ = new Toggle{this};
|
||||||
|
ignoreMinorEvents_ = new Toggle{this};
|
||||||
readReceipts_ = new Toggle{this};
|
readReceipts_ = new Toggle{this};
|
||||||
markdownEnabled_ = new Toggle{this};
|
markdownEnabled_ = new Toggle{this};
|
||||||
desktopNotifications_ = new Toggle{this};
|
desktopNotifications_ = new Toggle{this};
|
||||||
|
@ -293,6 +296,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
|
||||||
boxWrap(tr("Circular Avatars"), avatarCircles_);
|
boxWrap(tr("Circular Avatars"), avatarCircles_);
|
||||||
boxWrap(tr("Group's sidebar"), groupViewToggle_);
|
boxWrap(tr("Group's sidebar"), groupViewToggle_);
|
||||||
boxWrap(tr("Typing notifications"), typingNotifications_);
|
boxWrap(tr("Typing notifications"), typingNotifications_);
|
||||||
|
boxWrap(tr("Ignore minor events in room list"), ignoreMinorEvents_);
|
||||||
formLayout_->addRow(new HorizontalLine{this});
|
formLayout_->addRow(new HorizontalLine{this});
|
||||||
boxWrap(tr("Read receipts"), readReceipts_);
|
boxWrap(tr("Read receipts"), readReceipts_);
|
||||||
boxWrap(tr("Send messages as Markdown"), markdownEnabled_);
|
boxWrap(tr("Send messages as Markdown"), markdownEnabled_);
|
||||||
|
@ -394,6 +398,10 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
|
||||||
settings_->setTypingNotifications(!isDisabled);
|
settings_->setTypingNotifications(!isDisabled);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(ignoreMinorEvents_, &Toggle::toggled, this, [this](bool isDisabled) {
|
||||||
|
settings_->setIgnoreMinorEvents(!isDisabled);
|
||||||
|
});
|
||||||
|
|
||||||
connect(readReceipts_, &Toggle::toggled, this, [this](bool isDisabled) {
|
connect(readReceipts_, &Toggle::toggled, this, [this](bool isDisabled) {
|
||||||
settings_->setReadReceipts(!isDisabled);
|
settings_->setReadReceipts(!isDisabled);
|
||||||
});
|
});
|
||||||
|
@ -428,6 +436,7 @@ UserSettingsPage::showEvent(QShowEvent *)
|
||||||
groupViewToggle_->setState(!settings_->isGroupViewEnabled());
|
groupViewToggle_->setState(!settings_->isGroupViewEnabled());
|
||||||
avatarCircles_->setState(!settings_->isAvatarCirclesEnabled());
|
avatarCircles_->setState(!settings_->isAvatarCirclesEnabled());
|
||||||
typingNotifications_->setState(!settings_->isTypingNotificationsEnabled());
|
typingNotifications_->setState(!settings_->isTypingNotificationsEnabled());
|
||||||
|
ignoreMinorEvents_->setState(!settings_->isIgnoreMinorEventsEnabled());
|
||||||
readReceipts_->setState(!settings_->isReadReceiptsEnabled());
|
readReceipts_->setState(!settings_->isReadReceiptsEnabled());
|
||||||
markdownEnabled_->setState(!settings_->isMarkdownEnabled());
|
markdownEnabled_->setState(!settings_->isMarkdownEnabled());
|
||||||
desktopNotifications_->setState(!settings_->hasDesktopNotifications());
|
desktopNotifications_->setState(!settings_->hasDesktopNotifications());
|
||||||
|
|
|
@ -87,6 +87,12 @@ public:
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setIgnoreMinorEvents(bool state)
|
||||||
|
{
|
||||||
|
ignoreMinorEvents_ = state;
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
void setDesktopNotifications(bool state)
|
void setDesktopNotifications(bool state)
|
||||||
{
|
{
|
||||||
hasDesktopNotifications_ = state;
|
hasDesktopNotifications_ = state;
|
||||||
|
@ -106,6 +112,7 @@ public:
|
||||||
bool isAvatarCirclesEnabled() const { return avatarCircles_; }
|
bool isAvatarCirclesEnabled() const { return avatarCircles_; }
|
||||||
bool isMarkdownEnabled() const { return isMarkdownEnabled_; }
|
bool isMarkdownEnabled() const { return isMarkdownEnabled_; }
|
||||||
bool isTypingNotificationsEnabled() const { return isTypingNotificationsEnabled_; }
|
bool isTypingNotificationsEnabled() const { return isTypingNotificationsEnabled_; }
|
||||||
|
bool isIgnoreMinorEventsEnabled() const { return ignoreMinorEvents_; }
|
||||||
bool isReadReceiptsEnabled() const { return isReadReceiptsEnabled_; }
|
bool isReadReceiptsEnabled() const { return isReadReceiptsEnabled_; }
|
||||||
bool hasDesktopNotifications() const { return hasDesktopNotifications_; }
|
bool hasDesktopNotifications() const { return hasDesktopNotifications_; }
|
||||||
double fontSize() const { return baseFontSize_; }
|
double fontSize() const { return baseFontSize_; }
|
||||||
|
@ -127,6 +134,7 @@ private:
|
||||||
bool isGroupViewEnabled_;
|
bool isGroupViewEnabled_;
|
||||||
bool isMarkdownEnabled_;
|
bool isMarkdownEnabled_;
|
||||||
bool isTypingNotificationsEnabled_;
|
bool isTypingNotificationsEnabled_;
|
||||||
|
bool ignoreMinorEvents_;
|
||||||
bool isReadReceiptsEnabled_;
|
bool isReadReceiptsEnabled_;
|
||||||
bool hasDesktopNotifications_;
|
bool hasDesktopNotifications_;
|
||||||
bool avatarCircles_;
|
bool avatarCircles_;
|
||||||
|
@ -176,6 +184,7 @@ private:
|
||||||
Toggle *startInTrayToggle_;
|
Toggle *startInTrayToggle_;
|
||||||
Toggle *groupViewToggle_;
|
Toggle *groupViewToggle_;
|
||||||
Toggle *typingNotifications_;
|
Toggle *typingNotifications_;
|
||||||
|
Toggle *ignoreMinorEvents_;
|
||||||
Toggle *readReceipts_;
|
Toggle *readReceipts_;
|
||||||
Toggle *markdownEnabled_;
|
Toggle *markdownEnabled_;
|
||||||
Toggle *desktopNotifications_;
|
Toggle *desktopNotifications_;
|
||||||
|
|
Loading…
Reference in a new issue