1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor: remove getInstance() from groupchatroom.cpp

This commit is contained in:
sudden6 2020-07-07 22:07:43 +02:00
parent 040a833d56
commit c5e21be0f8
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
3 changed files with 7 additions and 4 deletions

View File

@ -28,9 +28,10 @@
#include "src/model/status.h"
#include "src/persistence/settings.h"
GroupChatroom::GroupChatroom(Group* group, IDialogsManager* dialogsManager)
GroupChatroom::GroupChatroom(Group* group, IDialogsManager* dialogsManager, Core& _core)
: group{group}
, dialogsManager{dialogsManager}
, core{_core}
{
}
@ -68,7 +69,7 @@ void GroupChatroom::inviteFriend(const ToxPk& pk)
const auto canInvite = Status::isOnline(frnd->getStatus());
if (canInvite) {
Core::getInstance()->groupInviteFriend(friendId, groupId);
core.groupInviteFriend(friendId, groupId);
}
}

View File

@ -23,6 +23,7 @@
#include <QObject>
class Core;
class IDialogsManager;
class Group;
class ToxPk;
@ -31,7 +32,7 @@ class GroupChatroom : public QObject, public Chatroom
{
Q_OBJECT
public:
GroupChatroom(Group* group, IDialogsManager* dialogsManager);
GroupChatroom(Group* group, IDialogsManager* dialogsManager, Core& _core);
Contact* getContact() override;
@ -50,4 +51,5 @@ public:
private:
Group* group{nullptr};
IDialogsManager* dialogsManager{nullptr};
Core& core;
};

View File

@ -2068,7 +2068,7 @@ Group* Widget::createGroup(uint32_t groupnumber, const GroupId& groupId)
});
}
auto dialogManager = ContentDialogManager::getInstance();
auto rawChatroom = new GroupChatroom(newgroup, dialogManager);
auto rawChatroom = new GroupChatroom(newgroup, dialogManager, *core);
std::shared_ptr<GroupChatroom> chatroom(rawChatroom);
const auto compact = settings.getCompactLayout();