Browse Source

feat(Settings): Add setting for hiding group join and leave system messages

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

Backported from 1be5b99d17
reviewable/pr6512/r6
Anthony Bilinski 3 years ago
parent
commit
916e797c10
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
  1. 4
      src/persistence/igroupsettings.h
  2. 17
      src/persistence/settings.cpp
  3. 6
      src/persistence/settings.h
  4. 4
      test/model/groupmessagedispatcher_test.cpp

4
src/persistence/igroupsettings.h

@ -33,7 +33,11 @@ public:
virtual bool getGroupAlwaysNotify() const = 0; virtual bool getGroupAlwaysNotify() const = 0;
virtual void setGroupAlwaysNotify(bool newValue) = 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(blackListChanged, QStringList const& blist);
DECLARE_SIGNAL(showGroupJoinLeaveMessagesChanged, bool show);
}; };
#endif /*IGROUP_SETTINGS_H*/ #endif /*IGROUP_SETTINGS_H*/

17
src/persistence/settings.cpp

@ -203,6 +203,7 @@ void Settings::loadGlobal()
lightTrayIcon = s.value("lightTrayIcon", false).toBool(); lightTrayIcon = s.value("lightTrayIcon", false).toBool();
useEmoticons = s.value("useEmoticons", true).toBool(); useEmoticons = s.value("useEmoticons", true).toBool();
statusChangeNotificationEnabled = s.value("statusChangeNotificationEnabled", false).toBool(); statusChangeNotificationEnabled = s.value("statusChangeNotificationEnabled", false).toBool();
showGroupJoinLeaveMessages = s.value("showGroupJoinLeaveMessages", false).toBool();
spellCheckingEnabled = s.value("spellCheckingEnabled", true).toBool(); spellCheckingEnabled = s.value("spellCheckingEnabled", true).toBool();
themeColor = s.value("themeColor", 0).toInt(); themeColor = s.value("themeColor", 0).toInt();
style = s.value("style", "").toString(); style = s.value("style", "").toString();
@ -680,6 +681,7 @@ void Settings::saveGlobal()
s.setValue("style", style); s.setValue("style", style);
s.setValue("nameColors", nameColors); s.setValue("nameColors", nameColors);
s.setValue("statusChangeNotificationEnabled", statusChangeNotificationEnabled); s.setValue("statusChangeNotificationEnabled", statusChangeNotificationEnabled);
s.setValue("showGroupJoinLeaveMessages", showGroupJoinLeaveMessages);
s.setValue("spellCheckingEnabled", spellCheckingEnabled); s.setValue("spellCheckingEnabled", spellCheckingEnabled);
} }
s.endGroup(); s.endGroup();
@ -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 bool Settings::getSpellCheckingEnabled() const
{ {
const QMutexLocker locker{&bigLock}; const QMutexLocker locker{&bigLock};

6
src/persistence/settings.h

@ -464,9 +464,12 @@ public:
QStringList getBlackList() const override; QStringList getBlackList() const override;
void setBlackList(const QStringList& blist) override; void setBlackList(const QStringList& blist) override;
SIGNAL_IMPL(Settings, blackListChanged, QStringList const& blist) SIGNAL_IMPL(Settings, blackListChanged, QStringList const& blist)
bool getShowGroupJoinLeaveMessages() const override;
void setShowGroupJoinLeaveMessages(bool newValue) override;
SIGNAL_IMPL(Settings, showGroupJoinLeaveMessagesChanged, bool show)
// State // State
QByteArray getWindowGeometry() const; QByteArray getWindowGeometry() const;
void setWindowGeometry(const QByteArray& value); void setWindowGeometry(const QByteArray& value);
@ -654,6 +657,7 @@ private:
QString timestampFormat; QString timestampFormat;
QString dateFormat; QString dateFormat;
bool statusChangeNotificationEnabled; bool statusChangeNotificationEnabled;
bool showGroupJoinLeaveMessages;
bool spellCheckingEnabled; bool spellCheckingEnabled;
// Privacy // Privacy

4
test/model/groupmessagedispatcher_test.cpp

@ -151,6 +151,10 @@ public:
void setGroupAlwaysNotify(bool newValue) override {} void setGroupAlwaysNotify(bool newValue) override {}
SIGNAL_IMPL(MockGroupSettings, blackListChanged, QStringList const& blist) 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: private:
QStringList blacklist; QStringList blacklist;
}; };

Loading…
Cancel
Save