mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor(settings): Use IGroupSettings in GroupChatForm
Move interface signals from Settings to be declared by the interface itself
This commit is contained in:
parent
0adf4a00f3
commit
e5df648e1a
|
@ -19,6 +19,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "util/interface.h"
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
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);
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 <QDragEnterEvent>
|
||||
#include <QMimeData>
|
||||
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user