diff --git a/src/persistence/igroupsettings.h b/src/persistence/igroupsettings.h index 46f2064b5..bd67112df 100644 --- a/src/persistence/igroupsettings.h +++ b/src/persistence/igroupsettings.h @@ -19,6 +19,8 @@ #pragma once +#include "util/interface.h" + #include class IGroupSettings @@ -33,4 +35,6 @@ public: virtual QStringList getBlackList() const = 0; virtual void setBlackList(const QStringList& blist) = 0; + + DECLARE_SIGNAL(blackListChanged, QStringList const& blist); }; diff --git a/src/persistence/settings.h b/src/persistence/settings.h index 2ea53b461..2d24f2923 100644 --- a/src/persistence/settings.h +++ b/src/persistence/settings.h @@ -231,7 +231,6 @@ signals: // Privacy void typingNotificationChanged(bool enabled); void dbSyncTypeChanged(Db::syncType type); - void blackListChanged(QStringList const& blist); public: bool applyCommandLineOptions(const QCommandLineParser& parser); @@ -461,9 +460,12 @@ public: // Privacy bool getTypingNotification() const; void setTypingNotification(bool enabled); + QStringList getBlackList() const override; void setBlackList(const QStringList& blist) override; + SIGNAL_IMPL(Settings, blackListChanged, QStringList const& blist) + // State QByteArray getWindowGeometry() const; void setWindowGeometry(const QByteArray& value); diff --git a/src/widget/form/groupchatform.cpp b/src/widget/form/groupchatform.cpp index 0009d13db..f1c7d6658 100644 --- a/src/widget/form/groupchatform.cpp +++ b/src/widget/form/groupchatform.cpp @@ -36,7 +36,7 @@ #include "src/widget/style.h" #include "src/widget/tool/croppinglabel.h" #include "src/widget/translator.h" -#include "src/persistence/settings.h" +#include "src/persistence/igroupsettings.h" #include #include @@ -82,7 +82,7 @@ QString editName(const QString& name) * @brief Timeout = peer stopped sending audio. */ -GroupChatForm::GroupChatForm(Core& _core, Group* chatGroup, IChatLog& chatLog, IMessageDispatcher& messageDispatcher, Settings& _settings) +GroupChatForm::GroupChatForm(Core& _core, Group* chatGroup, IChatLog& chatLog, IMessageDispatcher& messageDispatcher, IGroupSettings& _settings) : GenericChatForm(_core, chatGroup, chatLog, messageDispatcher) , core{_core} , group(chatGroup) @@ -131,7 +131,7 @@ GroupChatForm::GroupChatForm(Core& _core, Group* chatGroup, IChatLog& chatLog, I connect(group, &Group::userLeft, this, &GroupChatForm::onUserLeft); connect(group, &Group::peerNameChanged, this, &GroupChatForm::onPeerNameChanged); connect(group, &Group::numPeersChanged, this, &GroupChatForm::updateUserCount); - connect(&settings, &Settings::blackListChanged, this, &GroupChatForm::updateUserNames); + settings.connectTo_blackListChanged(this, [this](QStringList const&) { this->updateUserNames(); }); updateUserNames(); setAcceptDrops(true); diff --git a/src/widget/form/groupchatform.h b/src/widget/form/groupchatform.h index 034bccfa2..22a1ae1f2 100644 --- a/src/widget/form/groupchatform.h +++ b/src/widget/form/groupchatform.h @@ -34,12 +34,13 @@ class GroupId; class IMessageDispatcher; struct Message; class Settings; +class IGroupSettings; class GroupChatForm : public GenericChatForm { Q_OBJECT public: - explicit GroupChatForm(Core& _core, Group* chatGroup, IChatLog& chatLog, IMessageDispatcher& messageDispatcher, Settings& _settings); + explicit GroupChatForm(Core& _core, Group* chatGroup, IChatLog& chatLog, IMessageDispatcher& messageDispatcher, IGroupSettings& _settings); ~GroupChatForm(); void peerAudioPlaying(ToxPk peerPk); @@ -79,5 +80,5 @@ private: QLabel* nusersLabel; TabCompleter* tabber; bool inCall; - Settings& settings; + IGroupSettings& settings; }; diff --git a/test/model/groupmessagedispatcher_test.cpp b/test/model/groupmessagedispatcher_test.cpp index 584f98bf7..051a3aea2 100644 --- a/test/model/groupmessagedispatcher_test.cpp +++ b/test/model/groupmessagedispatcher_test.cpp @@ -22,6 +22,8 @@ #include "src/model/groupmessagedispatcher.h" #include "src/model/message.h" #include "src/persistence/settings.h" +#include "src/persistence/igroupsettings.h" +#include "util/interface.h" #include "test/mock/mockcoreidhandler.h" #include "test/mock/mockgroupquery.h" @@ -54,13 +56,16 @@ void MockGroupMessageSender::sendGroupMessage(int groupId, const QString& messag numSentMessages++; } -class MockGroupSettings : public IGroupSettings +class MockGroupSettings : public QObject, public IGroupSettings { + Q_OBJECT + public: QStringList getBlackList() const override; - void setBlackList(const QStringList& blist) override; + SIGNAL_IMPL(MockGroupSettings, blackListChanged, QStringList const& blist) + private: QStringList blacklist; };