|
|
@ -161,6 +161,7 @@ Widget::Widget(Profile &profile_, IAudioControl& audio_, CameraSource& cameraSou |
|
|
|
, style{style_} |
|
|
|
, style{style_} |
|
|
|
, messageBoxManager(new MessageBoxManager(this)) |
|
|
|
, messageBoxManager(new MessageBoxManager(this)) |
|
|
|
, friendList(new FriendList()) |
|
|
|
, friendList(new FriendList()) |
|
|
|
|
|
|
|
, groupList(new GroupList()) |
|
|
|
, contentDialogManager(new ContentDialogManager(*friendList)) |
|
|
|
, contentDialogManager(new ContentDialogManager(*friendList)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
installEventFilter(this); |
|
|
|
installEventFilter(this); |
|
|
@ -268,7 +269,7 @@ void Widget::init() |
|
|
|
sharedMessageProcessorParams.reset(new MessageProcessor::SharedParams(core->getMaxMessageSize(), coreExt->getMaxExtendedMessageSize())); |
|
|
|
sharedMessageProcessorParams.reset(new MessageProcessor::SharedParams(core->getMaxMessageSize(), coreExt->getMaxExtendedMessageSize())); |
|
|
|
|
|
|
|
|
|
|
|
chatListWidget = new FriendListWidget(*core, this, settings, style, |
|
|
|
chatListWidget = new FriendListWidget(*core, this, settings, style, |
|
|
|
*messageBoxManager, *friendList, profile, settings.getGroupchatPosition()); |
|
|
|
*messageBoxManager, *friendList, *groupList, profile, settings.getGroupchatPosition()); |
|
|
|
connect(chatListWidget, &FriendListWidget::searchCircle, this, &Widget::searchCircle); |
|
|
|
connect(chatListWidget, &FriendListWidget::searchCircle, this, &Widget::searchCircle); |
|
|
|
connect(chatListWidget, &FriendListWidget::connectCircleWidget, this, |
|
|
|
connect(chatListWidget, &FriendListWidget::connectCircleWidget, this, |
|
|
|
&Widget::connectCircleWidget); |
|
|
|
&Widget::connectCircleWidget); |
|
|
@ -620,7 +621,7 @@ Widget::~Widget() |
|
|
|
icon->hide(); |
|
|
|
icon->hide(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (Group* g : GroupList::getAllGroups()) { |
|
|
|
for (Group* g : groupList->getAllGroups()) { |
|
|
|
removeGroup(g, true); |
|
|
|
removeGroup(g, true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -642,7 +643,7 @@ Widget::~Widget() |
|
|
|
delete settingsWidget; |
|
|
|
delete settingsWidget; |
|
|
|
|
|
|
|
|
|
|
|
friendList->clear(); |
|
|
|
friendList->clear(); |
|
|
|
GroupList::clear(); |
|
|
|
groupList->clear(); |
|
|
|
delete trayMenu; |
|
|
|
delete trayMenu; |
|
|
|
delete ui; |
|
|
|
delete ui; |
|
|
|
instance = nullptr; |
|
|
|
instance = nullptr; |
|
|
@ -1156,7 +1157,7 @@ void Widget::addFriend(uint32_t friendId, const ToxPk& friendPk) |
|
|
|
settings.updateFriendAddress(friendPk.toString()); |
|
|
|
settings.updateFriendAddress(friendPk.toString()); |
|
|
|
|
|
|
|
|
|
|
|
Friend* newfriend = friendList->addFriend(friendId, friendPk, settings); |
|
|
|
Friend* newfriend = friendList->addFriend(friendId, friendPk, settings); |
|
|
|
auto rawChatroom = new FriendChatroom(newfriend, contentDialogManager.get(), *core, settings); |
|
|
|
auto rawChatroom = new FriendChatroom(newfriend, contentDialogManager.get(), *core, settings, *groupList); |
|
|
|
std::shared_ptr<FriendChatroom> chatroom(rawChatroom); |
|
|
|
std::shared_ptr<FriendChatroom> chatroom(rawChatroom); |
|
|
|
const auto compact = settings.getCompactLayout(); |
|
|
|
const auto compact = settings.getCompactLayout(); |
|
|
|
auto widget = new FriendWidget(chatroom, compact, settings, style, *messageBoxManager, profile); |
|
|
|
auto widget = new FriendWidget(chatroom, compact, settings, style, *messageBoxManager, profile); |
|
|
@ -1171,10 +1172,12 @@ void Widget::addFriend(uint32_t friendId, const ToxPk& friendPk) |
|
|
|
// ChatHistory hooks them up in a very specific order
|
|
|
|
// ChatHistory hooks them up in a very specific order
|
|
|
|
auto chatHistory = |
|
|
|
auto chatHistory = |
|
|
|
std::make_shared<ChatHistory>(*newfriend, history, *core, settings, |
|
|
|
std::make_shared<ChatHistory>(*newfriend, history, *core, settings, |
|
|
|
*friendMessageDispatcher, *friendList); |
|
|
|
*friendMessageDispatcher, *friendList, |
|
|
|
|
|
|
|
*groupList); |
|
|
|
auto friendForm = new ChatForm(profile, newfriend, *chatHistory, |
|
|
|
auto friendForm = new ChatForm(profile, newfriend, *chatHistory, |
|
|
|
*friendMessageDispatcher, *documentCache, *smileyPack, cameraSource, |
|
|
|
*friendMessageDispatcher, *documentCache, *smileyPack, cameraSource, |
|
|
|
settings, style, *messageBoxManager, *contentDialogManager, *friendList); |
|
|
|
settings, style, *messageBoxManager, *contentDialogManager, *friendList, |
|
|
|
|
|
|
|
*groupList); |
|
|
|
connect(friendForm, &ChatForm::updateFriendActivity, this, &Widget::updateFriendActivity); |
|
|
|
connect(friendForm, &ChatForm::updateFriendActivity, this, &Widget::updateFriendActivity); |
|
|
|
|
|
|
|
|
|
|
|
friendMessageDispatchers[friendPk] = friendMessageDispatcher; |
|
|
|
friendMessageDispatchers[friendPk] = friendMessageDispatcher; |
|
|
@ -1307,7 +1310,7 @@ void Widget::onFriendDisplayedNameChanged(const QString& displayed) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Friend* f = qobject_cast<Friend*>(sender()); |
|
|
|
Friend* f = qobject_cast<Friend*>(sender()); |
|
|
|
const auto& friendPk = f->getPublicKey(); |
|
|
|
const auto& friendPk = f->getPublicKey(); |
|
|
|
for (Group* g : GroupList::getAllGroups()) { |
|
|
|
for (Group* g : groupList->getAllGroups()) { |
|
|
|
if (g->getPeerList().contains(friendPk)) { |
|
|
|
if (g->getPeerList().contains(friendPk)) { |
|
|
|
g->updateUsername(friendPk, displayed); |
|
|
|
g->updateUsername(friendPk, displayed); |
|
|
|
} |
|
|
|
} |
|
|
@ -1619,7 +1622,7 @@ bool Widget::newGroupMessageAlert(const GroupId& groupId, const ToxPk& authorPk, |
|
|
|
bool hasActive; |
|
|
|
bool hasActive; |
|
|
|
QWidget* currentWindow; |
|
|
|
QWidget* currentWindow; |
|
|
|
ContentDialog* contentDialog = contentDialogManager->getGroupDialog(groupId); |
|
|
|
ContentDialog* contentDialog = contentDialogManager->getGroupDialog(groupId); |
|
|
|
Group* g = GroupList::findGroup(groupId); |
|
|
|
Group* g = groupList->findGroup(groupId); |
|
|
|
GroupWidget* widget = groupWidgets[groupId]; |
|
|
|
GroupWidget* widget = groupWidgets[groupId]; |
|
|
|
|
|
|
|
|
|
|
|
if (contentDialog != nullptr) { |
|
|
|
if (contentDialog != nullptr) { |
|
|
@ -1768,7 +1771,7 @@ void Widget::removeFriend(Friend* f, bool fake) |
|
|
|
if (!fake) { |
|
|
|
if (!fake) { |
|
|
|
core->removeFriend(f->getId()); |
|
|
|
core->removeFriend(f->getId()); |
|
|
|
// aliases aren't supported for non-friend peers in groups, revert to basic username
|
|
|
|
// aliases aren't supported for non-friend peers in groups, revert to basic username
|
|
|
|
for (Group* g : GroupList::getAllGroups()) { |
|
|
|
for (Group* g : groupList->getAllGroups()) { |
|
|
|
if (g->getPeerList().contains(friendPk)) { |
|
|
|
if (g->getPeerList().contains(friendPk)) { |
|
|
|
g->updateUsername(friendPk, f->getUserName()); |
|
|
|
g->updateUsername(friendPk, f->getUserName()); |
|
|
|
} |
|
|
|
} |
|
|
@ -1831,7 +1834,7 @@ void Widget::onUpdateAvailable() |
|
|
|
ContentDialog* Widget::createContentDialog() const |
|
|
|
ContentDialog* Widget::createContentDialog() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
ContentDialog* contentDialog = new ContentDialog(*core, settings, style, |
|
|
|
ContentDialog* contentDialog = new ContentDialog(*core, settings, style, |
|
|
|
*messageBoxManager, *friendList, profile); |
|
|
|
*messageBoxManager, *friendList, *groupList, profile); |
|
|
|
|
|
|
|
|
|
|
|
registerContentDialog(*contentDialog); |
|
|
|
registerContentDialog(*contentDialog); |
|
|
|
return contentDialog; |
|
|
|
return contentDialog; |
|
|
@ -1991,8 +1994,8 @@ void Widget::onGroupInviteAccepted(const GroupInvite& inviteInfo) |
|
|
|
void Widget::onGroupMessageReceived(int groupnumber, int peernumber, const QString& message, |
|
|
|
void Widget::onGroupMessageReceived(int groupnumber, int peernumber, const QString& message, |
|
|
|
bool isAction) |
|
|
|
bool isAction) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const GroupId& groupId = GroupList::id2Key(groupnumber); |
|
|
|
const GroupId& groupId = groupList->id2Key(groupnumber); |
|
|
|
assert(GroupList::findGroup(groupId)); |
|
|
|
assert(groupList->findGroup(groupId)); |
|
|
|
|
|
|
|
|
|
|
|
ToxPk author = core->getGroupPeerPk(groupnumber, peernumber); |
|
|
|
ToxPk author = core->getGroupPeerPk(groupnumber, peernumber); |
|
|
|
|
|
|
|
|
|
|
@ -2001,16 +2004,16 @@ void Widget::onGroupMessageReceived(int groupnumber, int peernumber, const QStri |
|
|
|
|
|
|
|
|
|
|
|
void Widget::onGroupPeerlistChanged(uint32_t groupnumber) |
|
|
|
void Widget::onGroupPeerlistChanged(uint32_t groupnumber) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const GroupId& groupId = GroupList::id2Key(groupnumber); |
|
|
|
const GroupId& groupId = groupList->id2Key(groupnumber); |
|
|
|
Group* g = GroupList::findGroup(groupId); |
|
|
|
Group* g = groupList->findGroup(groupId); |
|
|
|
assert(g); |
|
|
|
assert(g); |
|
|
|
g->regeneratePeerList(); |
|
|
|
g->regeneratePeerList(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Widget::onGroupPeerNameChanged(uint32_t groupnumber, const ToxPk& peerPk, const QString& newName) |
|
|
|
void Widget::onGroupPeerNameChanged(uint32_t groupnumber, const ToxPk& peerPk, const QString& newName) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const GroupId& groupId = GroupList::id2Key(groupnumber); |
|
|
|
const GroupId& groupId = groupList->id2Key(groupnumber); |
|
|
|
Group* g = GroupList::findGroup(groupId); |
|
|
|
Group* g = groupList->findGroup(groupId); |
|
|
|
assert(g); |
|
|
|
assert(g); |
|
|
|
|
|
|
|
|
|
|
|
const QString setName = friendList->decideNickname(peerPk, newName); |
|
|
|
const QString setName = friendList->decideNickname(peerPk, newName); |
|
|
@ -2019,8 +2022,8 @@ void Widget::onGroupPeerNameChanged(uint32_t groupnumber, const ToxPk& peerPk, c |
|
|
|
|
|
|
|
|
|
|
|
void Widget::onGroupTitleChanged(uint32_t groupnumber, const QString& author, const QString& title) |
|
|
|
void Widget::onGroupTitleChanged(uint32_t groupnumber, const QString& author, const QString& title) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const GroupId& groupId = GroupList::id2Key(groupnumber); |
|
|
|
const GroupId& groupId = groupList->id2Key(groupnumber); |
|
|
|
Group* g = GroupList::findGroup(groupId); |
|
|
|
Group* g = groupList->findGroup(groupId); |
|
|
|
assert(g); |
|
|
|
assert(g); |
|
|
|
|
|
|
|
|
|
|
|
GroupWidget* widget = groupWidgets[groupId]; |
|
|
|
GroupWidget* widget = groupWidgets[groupId]; |
|
|
@ -2041,8 +2044,8 @@ void Widget::titleChangedByUser(const QString& title) |
|
|
|
|
|
|
|
|
|
|
|
void Widget::onGroupPeerAudioPlaying(int groupnumber, ToxPk peerPk) |
|
|
|
void Widget::onGroupPeerAudioPlaying(int groupnumber, ToxPk peerPk) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const GroupId& groupId = GroupList::id2Key(groupnumber); |
|
|
|
const GroupId& groupId = groupList->id2Key(groupnumber); |
|
|
|
assert(GroupList::findGroup(groupId)); |
|
|
|
assert(groupList->findGroup(groupId)); |
|
|
|
|
|
|
|
|
|
|
|
auto form = groupChatForms[groupId].data(); |
|
|
|
auto form = groupChatForms[groupId].data(); |
|
|
|
form->peerAudioPlaying(peerPk); |
|
|
|
form->peerAudioPlaying(peerPk); |
|
|
@ -2069,7 +2072,7 @@ void Widget::removeGroup(Group* g, bool fake) |
|
|
|
onAddClicked(); |
|
|
|
onAddClicked(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GroupList::removeGroup(groupId, fake); |
|
|
|
groupList->removeGroup(groupId, fake); |
|
|
|
ContentDialog* contentDialog = contentDialogManager->getGroupDialog(groupId); |
|
|
|
ContentDialog* contentDialog = contentDialogManager->getGroupDialog(groupId); |
|
|
|
if (contentDialog != nullptr) { |
|
|
|
if (contentDialog != nullptr) { |
|
|
|
contentDialog->removeGroup(groupId); |
|
|
|
contentDialog->removeGroup(groupId); |
|
|
@ -2098,14 +2101,14 @@ void Widget::removeGroup(Group* g, bool fake) |
|
|
|
|
|
|
|
|
|
|
|
void Widget::removeGroup(const GroupId& groupId) |
|
|
|
void Widget::removeGroup(const GroupId& groupId) |
|
|
|
{ |
|
|
|
{ |
|
|
|
removeGroup(GroupList::findGroup(groupId)); |
|
|
|
removeGroup(groupList->findGroup(groupId)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Group* Widget::createGroup(uint32_t groupnumber, const GroupId& groupId) |
|
|
|
Group* Widget::createGroup(uint32_t groupnumber, const GroupId& groupId) |
|
|
|
{ |
|
|
|
{ |
|
|
|
assert(core != nullptr); |
|
|
|
assert(core != nullptr); |
|
|
|
|
|
|
|
|
|
|
|
Group* g = GroupList::findGroup(groupId); |
|
|
|
Group* g = groupList->findGroup(groupId); |
|
|
|
if (g) { |
|
|
|
if (g) { |
|
|
|
qWarning() << "Group already exists"; |
|
|
|
qWarning() << "Group already exists"; |
|
|
|
return g; |
|
|
|
return g; |
|
|
@ -2114,7 +2117,7 @@ Group* Widget::createGroup(uint32_t groupnumber, const GroupId& groupId) |
|
|
|
const auto groupName = tr("Groupchat #%1").arg(groupnumber); |
|
|
|
const auto groupName = tr("Groupchat #%1").arg(groupnumber); |
|
|
|
const bool enabled = core->getGroupAvEnabled(groupnumber); |
|
|
|
const bool enabled = core->getGroupAvEnabled(groupnumber); |
|
|
|
Group* newgroup = |
|
|
|
Group* newgroup = |
|
|
|
GroupList::addGroup(*core, groupnumber, groupId, groupName, enabled, core->getUsername(), |
|
|
|
groupList->addGroup(*core, groupnumber, groupId, groupName, enabled, core->getUsername(), |
|
|
|
*friendList); |
|
|
|
*friendList); |
|
|
|
assert(newgroup); |
|
|
|
assert(newgroup); |
|
|
|
|
|
|
|
|
|
|
@ -2141,7 +2144,7 @@ Group* Widget::createGroup(uint32_t groupnumber, const GroupId& groupId) |
|
|
|
// ChatHistory hooks them up in a very specific order
|
|
|
|
// ChatHistory hooks them up in a very specific order
|
|
|
|
auto chatHistory = |
|
|
|
auto chatHistory = |
|
|
|
std::make_shared<ChatHistory>(*newgroup, history, *core, settings, |
|
|
|
std::make_shared<ChatHistory>(*newgroup, history, *core, settings, |
|
|
|
*messageDispatcher, *friendList); |
|
|
|
*messageDispatcher, *friendList, *groupList); |
|
|
|
|
|
|
|
|
|
|
|
auto notifyReceivedCallback = [this, groupId](const ToxPk& author, const Message& message) { |
|
|
|
auto notifyReceivedCallback = [this, groupId](const ToxPk& author, const Message& message) { |
|
|
|
auto isTargeted = std::any_of(message.metadata.begin(), message.metadata.end(), |
|
|
|
auto isTargeted = std::any_of(message.metadata.begin(), message.metadata.end(), |
|
|
@ -2157,7 +2160,7 @@ Group* Widget::createGroup(uint32_t groupnumber, const GroupId& groupId) |
|
|
|
groupAlertConnections.insert(groupId, notifyReceivedConnection); |
|
|
|
groupAlertConnections.insert(groupId, notifyReceivedConnection); |
|
|
|
|
|
|
|
|
|
|
|
auto form = new GroupChatForm(*core, newgroup, *chatHistory, *messageDispatcher, |
|
|
|
auto form = new GroupChatForm(*core, newgroup, *chatHistory, *messageDispatcher, |
|
|
|
settings, *documentCache, *smileyPack, style, *messageBoxManager, *friendList); |
|
|
|
settings, *documentCache, *smileyPack, style, *messageBoxManager, *friendList, *groupList); |
|
|
|
connect(&settings, &Settings::nameColorsChanged, form, &GenericChatForm::setColorizedNames); |
|
|
|
connect(&settings, &Settings::nameColorsChanged, form, &GenericChatForm::setColorizedNames); |
|
|
|
form->setColorizedNames(settings.getEnableGroupChatsColor()); |
|
|
|
form->setColorizedNames(settings.getEnableGroupChatsColor()); |
|
|
|
groupMessageDispatchers[groupId] = messageDispatcher; |
|
|
|
groupMessageDispatchers[groupId] = messageDispatcher; |
|
|
@ -2355,8 +2358,8 @@ void Widget::setStatusBusy() |
|
|
|
|
|
|
|
|
|
|
|
void Widget::onGroupSendFailed(uint32_t groupnumber) |
|
|
|
void Widget::onGroupSendFailed(uint32_t groupnumber) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const auto& groupId = GroupList::id2Key(groupnumber); |
|
|
|
const auto& groupId = groupList->id2Key(groupnumber); |
|
|
|
assert(GroupList::findGroup(groupId)); |
|
|
|
assert(groupList->findGroup(groupId)); |
|
|
|
|
|
|
|
|
|
|
|
const auto curTime = QDateTime::currentDateTime(); |
|
|
|
const auto curTime = QDateTime::currentDateTime(); |
|
|
|
auto form = groupChatForms[groupId].data(); |
|
|
|
auto form = groupChatForms[groupId].data(); |
|
|
@ -2706,7 +2709,7 @@ void Widget::focusChatInput() |
|
|
|
|
|
|
|
|
|
|
|
void Widget::refreshPeerListsLocal(const QString& username) |
|
|
|
void Widget::refreshPeerListsLocal(const QString& username) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (Group* g : GroupList::getAllGroups()) { |
|
|
|
for (Group* g : groupList->getAllGroups()) { |
|
|
|
g->updateUsername(core->getSelfPublicKey(), username); |
|
|
|
g->updateUsername(core->getSelfPublicKey(), username); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|