Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
feat(Settings): Add setting for hiding group join and leave system me…
Browse files Browse the repository at this point in the history
…ssages

Messages can become spammy is long lasting quiet groups, drowning out real user
messages

Backported from 1be5b99
  • Loading branch information
anthonybilinski committed Mar 5, 2022
1 parent d0d288a commit 916e797
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/persistence/igroupsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ class IGroupSettings
virtual bool getGroupAlwaysNotify() const = 0;
virtual void setGroupAlwaysNotify(bool newValue) = 0;

virtual bool getShowGroupJoinLeaveMessages() const = 0;
virtual void setShowGroupJoinLeaveMessages(bool newValue) = 0;

DECLARE_SIGNAL(blackListChanged, QStringList const& blist);
DECLARE_SIGNAL(showGroupJoinLeaveMessagesChanged, bool show);
};

#endif /*IGROUP_SETTINGS_H*/
17 changes: 17 additions & 0 deletions src/persistence/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ void Settings::loadGlobal()
lightTrayIcon = s.value("lightTrayIcon", false).toBool();
useEmoticons = s.value("useEmoticons", true).toBool();
statusChangeNotificationEnabled = s.value("statusChangeNotificationEnabled", false).toBool();
showGroupJoinLeaveMessages = s.value("showGroupJoinLeaveMessages", false).toBool();
spellCheckingEnabled = s.value("spellCheckingEnabled", true).toBool();
themeColor = s.value("themeColor", 0).toInt();
style = s.value("style", "").toString();
Expand Down Expand Up @@ -680,6 +681,7 @@ void Settings::saveGlobal()
s.setValue("style", style);
s.setValue("nameColors", nameColors);
s.setValue("statusChangeNotificationEnabled", statusChangeNotificationEnabled);
s.setValue("showGroupJoinLeaveMessages", showGroupJoinLeaveMessages);
s.setValue("spellCheckingEnabled", spellCheckingEnabled);
}
s.endGroup();
Expand Down Expand Up @@ -1155,6 +1157,21 @@ void Settings::setStatusChangeNotificationEnabled(bool newValue)
}
}

bool Settings::getShowGroupJoinLeaveMessages() const
{
QMutexLocker locker{&bigLock};
return showGroupJoinLeaveMessages;
}

void Settings::setShowGroupJoinLeaveMessages(bool newValue)
{
QMutexLocker locker{&bigLock};
if (newValue != showGroupJoinLeaveMessages) {
showGroupJoinLeaveMessages = newValue;
emit showGroupJoinLeaveMessagesChanged(showGroupJoinLeaveMessages);
}
}

bool Settings::getSpellCheckingEnabled() const
{
const QMutexLocker locker{&bigLock};
Expand Down
6 changes: 5 additions & 1 deletion src/persistence/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,12 @@ public slots:

QStringList getBlackList() const override;
void setBlackList(const QStringList& blist) override;

SIGNAL_IMPL(Settings, blackListChanged, QStringList const& blist)

bool getShowGroupJoinLeaveMessages() const override;
void setShowGroupJoinLeaveMessages(bool newValue) override;
SIGNAL_IMPL(Settings, showGroupJoinLeaveMessagesChanged, bool show)

// State
QByteArray getWindowGeometry() const;
void setWindowGeometry(const QByteArray& value);
Expand Down Expand Up @@ -654,6 +657,7 @@ public slots:
QString timestampFormat;
QString dateFormat;
bool statusChangeNotificationEnabled;
bool showGroupJoinLeaveMessages;
bool spellCheckingEnabled;

// Privacy
Expand Down
4 changes: 4 additions & 0 deletions test/model/groupmessagedispatcher_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ class MockGroupSettings : public QObject, public IGroupSettings
void setGroupAlwaysNotify(bool newValue) override {}
SIGNAL_IMPL(MockGroupSettings, blackListChanged, QStringList const& blist)

bool getShowGroupJoinLeaveMessages() const override { return true; };
void setShowGroupJoinLeaveMessages(bool newValue) override {};
SIGNAL_IMPL(MockGroupSettings, showGroupJoinLeaveMessagesChanged, bool show)

private:
QStringList blacklist;
};
Expand Down

0 comments on commit 916e797

Please sign in to comment.