mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Group class refactoring
This commit is contained in:
parent
85718fa637
commit
f59a67f08a
|
@ -79,3 +79,65 @@ void Group::setName(const QString& name)
|
||||||
if (widget->isActive())
|
if (widget->isActive())
|
||||||
Widget::getInstance()->setWindowTitle(name);
|
Widget::getInstance()->setWindowTitle(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Group::regeneratePeerList()
|
||||||
|
{
|
||||||
|
QList<QString> peerLst = Core::getInstance()->getGroupPeerNames(groupId);
|
||||||
|
peers.clear();
|
||||||
|
nPeers = peerLst.size();
|
||||||
|
for (int i = 0; i < peerLst.size(); i++)
|
||||||
|
peers[i] = peerLst.at(i);
|
||||||
|
|
||||||
|
widget->onUserListChanged();
|
||||||
|
chatForm->onUserListChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Group::isAvGroupchat() const
|
||||||
|
{
|
||||||
|
return avGroupchat;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Group::getGroupId() const
|
||||||
|
{
|
||||||
|
return groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Group::getPeersCount() const
|
||||||
|
{
|
||||||
|
return nPeers;
|
||||||
|
}
|
||||||
|
|
||||||
|
GroupChatForm *Group::getChatForm()
|
||||||
|
{
|
||||||
|
return chatForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
GroupWidget *Group::getGroupWidget()
|
||||||
|
{
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList Group::getPeerList() const
|
||||||
|
{
|
||||||
|
return peers.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Group::setEventFlag(int f)
|
||||||
|
{
|
||||||
|
hasNewMessages = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Group::getEventFlag() const
|
||||||
|
{
|
||||||
|
return hasNewMessages;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Group::setMentionedFlag(int f)
|
||||||
|
{
|
||||||
|
userWasMentioned = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Group::getMentionedFlag() const
|
||||||
|
{
|
||||||
|
return userWasMentioned;
|
||||||
|
}
|
||||||
|
|
28
src/group.h
28
src/group.h
|
@ -31,20 +31,38 @@ class Group : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Group(int GroupId, QString Name, bool IsAvGroupchat);
|
Group(int GroupId, QString Name, bool IsAvGroupchat);
|
||||||
~Group();
|
virtual ~Group();
|
||||||
|
|
||||||
|
bool isAvGroupchat() const;
|
||||||
|
int getGroupId() const;
|
||||||
|
int getPeersCount() const;
|
||||||
|
void regeneratePeerList();
|
||||||
|
QStringList getPeerList() const;
|
||||||
|
|
||||||
|
GroupChatForm *getChatForm();
|
||||||
|
GroupWidget *getGroupWidget();
|
||||||
|
|
||||||
|
void setEventFlag(int f);
|
||||||
|
int getEventFlag() const;
|
||||||
|
|
||||||
|
void setMentionedFlag(int f);
|
||||||
|
int getMentionedFlag() const;
|
||||||
|
|
||||||
void addPeer(int peerId, QString name);
|
void addPeer(int peerId, QString name);
|
||||||
void removePeer(int peerId);
|
void removePeer(int peerId);
|
||||||
|
|
||||||
void updatePeer(int peerId, QString newName);
|
void updatePeer(int peerId, QString newName);
|
||||||
void setName(const QString& name);
|
void setName(const QString& name);
|
||||||
|
|
||||||
public:
|
private:
|
||||||
int groupId;
|
|
||||||
QMap<int,QString> peers;
|
|
||||||
int nPeers;
|
|
||||||
GroupWidget* widget;
|
GroupWidget* widget;
|
||||||
GroupChatForm* chatForm;
|
GroupChatForm* chatForm;
|
||||||
|
QMap<int, QString> peers;
|
||||||
int hasNewMessages, userWasMentioned;
|
int hasNewMessages, userWasMentioned;
|
||||||
|
int groupId;
|
||||||
|
int nPeers;
|
||||||
bool avGroupchat;
|
bool avGroupchat;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GROUP_H
|
#endif // GROUP_H
|
||||||
|
|
|
@ -38,7 +38,7 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
|
||||||
tabber = new TabCompleter(msgEdit, group);
|
tabber = new TabCompleter(msgEdit, group);
|
||||||
|
|
||||||
fileButton->setEnabled(false);
|
fileButton->setEnabled(false);
|
||||||
if (group->avGroupchat)
|
if (group->isAvGroupchat())
|
||||||
{
|
{
|
||||||
videoButton->setEnabled(false);
|
videoButton->setEnabled(false);
|
||||||
videoButton->setObjectName("grey");
|
videoButton->setObjectName("grey");
|
||||||
|
@ -51,10 +51,10 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
|
||||||
micButton->setVisible(false);
|
micButton->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
nameLabel->setText(group->widget->getName());
|
nameLabel->setText(group->getGroupWidget()->getName());
|
||||||
|
|
||||||
nusersLabel->setFont(Style::getFont(Style::Medium));
|
nusersLabel->setFont(Style::getFont(Style::Medium));
|
||||||
nusersLabel->setText(GroupChatForm::tr("%1 users in chat","Number of users in chat").arg(group->peers.size()));
|
nusersLabel->setText(GroupChatForm::tr("%1 users in chat","Number of users in chat").arg(group->getPeersCount()));
|
||||||
nusersLabel->setObjectName("statusLabel");
|
nusersLabel->setObjectName("statusLabel");
|
||||||
|
|
||||||
avatar->setPixmap(QPixmap(":/img/group_dark.png"), Qt::transparent);
|
avatar->setPixmap(QPixmap(":/img/group_dark.png"), Qt::transparent);
|
||||||
|
@ -62,7 +62,7 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
|
||||||
msgEdit->setObjectName("group");
|
msgEdit->setObjectName("group");
|
||||||
|
|
||||||
namesListLayout = new FlowLayout(0,5,0);
|
namesListLayout = new FlowLayout(0,5,0);
|
||||||
QStringList names(group->peers.values());
|
QStringList names(group->getPeerList());
|
||||||
for (const QString& name : names)
|
for (const QString& name : names)
|
||||||
namesListLayout->addWidget(new QLabel(name));
|
namesListLayout->addWidget(new QLabel(name));
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
|
||||||
connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle()));
|
connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle()));
|
||||||
connect(volButton, SIGNAL(clicked()), this, SLOT(onVolMuteToggle()));
|
connect(volButton, SIGNAL(clicked()), this, SLOT(onVolMuteToggle()));
|
||||||
connect(nameLabel, &CroppingLabel::textChanged, this, [=](QString text, QString orig)
|
connect(nameLabel, &CroppingLabel::textChanged, this, [=](QString text, QString orig)
|
||||||
{if (text != orig) emit groupTitleChanged(group->groupId, text.left(128));} );
|
{if (text != orig) emit groupTitleChanged(group->getGroupId(), text.left(128));} );
|
||||||
|
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
}
|
}
|
||||||
|
@ -97,15 +97,15 @@ void GroupChatForm::onSendTriggered()
|
||||||
if (msg.startsWith("/me "))
|
if (msg.startsWith("/me "))
|
||||||
{
|
{
|
||||||
msg = msg.right(msg.length() - 4);
|
msg = msg.right(msg.length() - 4);
|
||||||
emit sendAction(group->groupId, msg);
|
emit sendAction(group->getGroupId(), msg);
|
||||||
} else {
|
} else {
|
||||||
emit sendMessage(group->groupId, msg);
|
emit sendMessage(group->getGroupId(), msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupChatForm::onUserListChanged()
|
void GroupChatForm::onUserListChanged()
|
||||||
{
|
{
|
||||||
nusersLabel->setText(tr("%1 users in chat").arg(group->nPeers));
|
nusersLabel->setText(tr("%1 users in chat").arg(group->getPeersCount()));
|
||||||
|
|
||||||
QLayoutItem *child;
|
QLayoutItem *child;
|
||||||
while ((child = namesListLayout->takeAt(0)))
|
while ((child = namesListLayout->takeAt(0)))
|
||||||
|
@ -115,7 +115,7 @@ void GroupChatForm::onUserListChanged()
|
||||||
delete child;
|
delete child;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList names(group->peers.values());
|
QStringList names(group->getPeerList());
|
||||||
unsigned nNames = names.size();
|
unsigned nNames = names.size();
|
||||||
for (unsigned i=0; i<nNames; ++i)
|
for (unsigned i=0; i<nNames; ++i)
|
||||||
{
|
{
|
||||||
|
@ -139,7 +139,7 @@ void GroupChatForm::dropEvent(QDropEvent *ev)
|
||||||
if (ev->mimeData()->hasFormat("friend"))
|
if (ev->mimeData()->hasFormat("friend"))
|
||||||
{
|
{
|
||||||
int friendId = ev->mimeData()->data("friend").toInt();
|
int friendId = ev->mimeData()->data("friend").toInt();
|
||||||
Core::getInstance()->groupInviteFriend(friendId, group->groupId);
|
Core::getInstance()->groupInviteFriend(friendId, group->getGroupId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,12 +149,12 @@ void GroupChatForm::onMicMuteToggle()
|
||||||
{
|
{
|
||||||
if (micButton->objectName() == "red")
|
if (micButton->objectName() == "red")
|
||||||
{
|
{
|
||||||
Core::getInstance()->enableGroupCallMic(group->groupId);
|
Core::getInstance()->enableGroupCallMic(group->getGroupId());
|
||||||
micButton->setObjectName("green");
|
micButton->setObjectName("green");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Core::getInstance()->disableGroupCallMic(group->groupId);
|
Core::getInstance()->disableGroupCallMic(group->getGroupId());
|
||||||
micButton->setObjectName("red");
|
micButton->setObjectName("red");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,12 +168,12 @@ void GroupChatForm::onVolMuteToggle()
|
||||||
{
|
{
|
||||||
if (volButton->objectName() == "red")
|
if (volButton->objectName() == "red")
|
||||||
{
|
{
|
||||||
Core::getInstance()->enableGroupCallVol(group->groupId);
|
Core::getInstance()->enableGroupCallVol(group->getGroupId());
|
||||||
volButton->setObjectName("green");
|
volButton->setObjectName("green");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Core::getInstance()->disableGroupCallVol(group->groupId);
|
Core::getInstance()->disableGroupCallVol(group->getGroupId());
|
||||||
volButton->setObjectName("red");
|
volButton->setObjectName("red");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ void GroupChatForm::onCallClicked()
|
||||||
{
|
{
|
||||||
if (!inCall)
|
if (!inCall)
|
||||||
{
|
{
|
||||||
Core::getInstance()->joinGroupCall(group->groupId);
|
Core::getInstance()->joinGroupCall(group->getGroupId());
|
||||||
audioInputFlag = true;
|
audioInputFlag = true;
|
||||||
audioOutputFlag = true;
|
audioOutputFlag = true;
|
||||||
callButton->setObjectName("red");
|
callButton->setObjectName("red");
|
||||||
|
@ -194,7 +194,7 @@ void GroupChatForm::onCallClicked()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Core::getInstance()->leaveGroupCall(group->groupId);
|
Core::getInstance()->leaveGroupCall(group->getGroupId());
|
||||||
audioInputFlag = false;
|
audioInputFlag = false;
|
||||||
audioOutputFlag = false;
|
audioOutputFlag = false;
|
||||||
micButton->setObjectName("green");
|
micButton->setObjectName("green");
|
||||||
|
@ -216,9 +216,9 @@ void GroupChatForm::keyPressEvent(QKeyEvent* ev)
|
||||||
if (ev->key() == Qt::Key_P && inCall)
|
if (ev->key() == Qt::Key_P && inCall)
|
||||||
{
|
{
|
||||||
Core* core = Core::getInstance();
|
Core* core = Core::getInstance();
|
||||||
if (!core->isGroupCallMicEnabled(group->groupId))
|
if (!core->isGroupCallMicEnabled(group->getGroupId()))
|
||||||
{
|
{
|
||||||
core->enableGroupCallMic(group->groupId);
|
core->enableGroupCallMic(group->getGroupId());
|
||||||
micButton->setObjectName("green");
|
micButton->setObjectName("green");
|
||||||
micButton->style()->polish(micButton);
|
micButton->style()->polish(micButton);
|
||||||
Style::repolish(micButton);
|
Style::repolish(micButton);
|
||||||
|
@ -235,9 +235,9 @@ void GroupChatForm::keyReleaseEvent(QKeyEvent* ev)
|
||||||
if (ev->key() == Qt::Key_P && inCall)
|
if (ev->key() == Qt::Key_P && inCall)
|
||||||
{
|
{
|
||||||
Core* core = Core::getInstance();
|
Core* core = Core::getInstance();
|
||||||
if (core->isGroupCallMicEnabled(group->groupId))
|
if (core->isGroupCallMicEnabled(group->getGroupId()))
|
||||||
{
|
{
|
||||||
core->disableGroupCallMic(group->groupId);
|
core->disableGroupCallMic(group->getGroupId());
|
||||||
micButton->setObjectName("red");
|
micButton->setObjectName("red");
|
||||||
micButton->style()->polish(micButton);
|
micButton->style()->polish(micButton);
|
||||||
Style::repolish(micButton);
|
Style::repolish(micButton);
|
||||||
|
|
|
@ -52,7 +52,7 @@ void TabCompleter::buildCompletionList()
|
||||||
// that section is then used as the completion regex
|
// that section is then used as the completion regex
|
||||||
QRegExp regex(QString("^[-_\\[\\]{}|`^.\\\\]*").append(QRegExp::escape(tabAbbrev)), Qt::CaseInsensitive);
|
QRegExp regex(QString("^[-_\\[\\]{}|`^.\\\\]*").append(QRegExp::escape(tabAbbrev)), Qt::CaseInsensitive);
|
||||||
|
|
||||||
for(auto name : group->peers.values())
|
for(auto name : group->getPeerList())
|
||||||
if (regex.indexIn(name) > -1)
|
if (regex.indexIn(name) > -1)
|
||||||
completionMap[name.toLower()] = name;
|
completionMap[name.toLower()] = name;
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||||
|
|
||||||
for (Group* group : GroupList::getAllGroups())
|
for (Group* group : GroupList::getAllGroups())
|
||||||
{
|
{
|
||||||
QAction* groupAction = inviteMenu->addAction(group->widget->getName());
|
QAction* groupAction = inviteMenu->addAction(group->getGroupWidget()->getName());
|
||||||
groupActions[groupAction] = group;
|
groupActions[groupAction] = group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||||
else if (groupActions.contains(selectedItem))
|
else if (groupActions.contains(selectedItem))
|
||||||
{
|
{
|
||||||
Group* group = groupActions[selectedItem];
|
Group* group = groupActions[selectedItem];
|
||||||
Core::getInstance()->groupInviteFriend(friendId, group->groupId);
|
Core::getInstance()->groupInviteFriend(friendId, group->getGroupId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ GroupWidget::GroupWidget(int GroupId, QString Name)
|
||||||
|
|
||||||
Group* g = GroupList::findGroup(groupId);
|
Group* g = GroupList::findGroup(groupId);
|
||||||
if (g)
|
if (g)
|
||||||
statusMessageLabel->setText(GroupWidget::tr("%1 users in chat").arg(g->peers.size()));
|
statusMessageLabel->setText(GroupWidget::tr("%1 users in chat").arg(g->getPeersCount()));
|
||||||
else
|
else
|
||||||
statusMessageLabel->setText(GroupWidget::tr("0 users in chat"));
|
statusMessageLabel->setText(GroupWidget::tr("0 users in chat"));
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ void GroupWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||||
nameLabel->fullText(), &ok);
|
nameLabel->fullText(), &ok);
|
||||||
|
|
||||||
if (ok && alias != nameLabel->fullText())
|
if (ok && alias != nameLabel->fullText())
|
||||||
emit g->chatForm->groupTitleChanged(groupId, alias.left(128));
|
emit g->getChatForm()->groupTitleChanged(groupId, alias.left(128));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ void GroupWidget::onUserListChanged()
|
||||||
{
|
{
|
||||||
Group* g = GroupList::findGroup(groupId);
|
Group* g = GroupList::findGroup(groupId);
|
||||||
if (g)
|
if (g)
|
||||||
statusMessageLabel->setText(tr("%1 users in chat").arg(g->nPeers));
|
statusMessageLabel->setText(tr("%1 users in chat").arg(g->getPeersCount()));
|
||||||
else
|
else
|
||||||
statusMessageLabel->setText(tr("0 users in chat"));
|
statusMessageLabel->setText(tr("0 users in chat"));
|
||||||
}
|
}
|
||||||
|
@ -98,13 +98,13 @@ void GroupWidget::updateStatusLight()
|
||||||
{
|
{
|
||||||
Group *g = GroupList::findGroup(groupId);
|
Group *g = GroupList::findGroup(groupId);
|
||||||
|
|
||||||
if (g->hasNewMessages == 0)
|
if (!g->getEventFlag())
|
||||||
{
|
{
|
||||||
statusPic.setPixmap(QPixmap(":img/status/dot_online.png"));
|
statusPic.setPixmap(QPixmap(":img/status/dot_online.png"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (g->userWasMentioned == 0)
|
if (!g->getMentionedFlag())
|
||||||
statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png"));
|
statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png"));
|
||||||
else
|
else
|
||||||
statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png"));
|
statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png"));
|
||||||
|
@ -114,14 +114,14 @@ void GroupWidget::updateStatusLight()
|
||||||
void GroupWidget::setChatForm(Ui::MainWindow &ui)
|
void GroupWidget::setChatForm(Ui::MainWindow &ui)
|
||||||
{
|
{
|
||||||
Group* g = GroupList::findGroup(groupId);
|
Group* g = GroupList::findGroup(groupId);
|
||||||
g->chatForm->show(ui);
|
g->getChatForm()->show(ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupWidget::resetEventFlags()
|
void GroupWidget::resetEventFlags()
|
||||||
{
|
{
|
||||||
Group* g = GroupList::findGroup(groupId);
|
Group* g = GroupList::findGroup(groupId);
|
||||||
g->hasNewMessages = 0;
|
g->setEventFlag(false);
|
||||||
g->userWasMentioned = 0;
|
g->setMentionedFlag(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupWidget::dragEnterEvent(QDragEnterEvent *ev)
|
void GroupWidget::dragEnterEvent(QDragEnterEvent *ev)
|
||||||
|
@ -143,7 +143,7 @@ void GroupWidget::keyPressEvent(QKeyEvent* ev)
|
||||||
{
|
{
|
||||||
Group* g = GroupList::findGroup(groupId);
|
Group* g = GroupList::findGroup(groupId);
|
||||||
if (g)
|
if (g)
|
||||||
g->chatForm->keyPressEvent(ev);
|
g->getChatForm()->keyPressEvent(ev);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ void GroupWidget::keyReleaseEvent(QKeyEvent* ev)
|
||||||
{
|
{
|
||||||
Group* g = GroupList::findGroup(groupId);
|
Group* g = GroupList::findGroup(groupId);
|
||||||
if (g)
|
if (g)
|
||||||
g->chatForm->keyReleaseEvent(ev);
|
g->getChatForm()->keyReleaseEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupWidget::setName(const QString& name)
|
void GroupWidget::setName(const QString& name)
|
||||||
|
|
|
@ -920,19 +920,19 @@ void Widget::onGroupMessageReceived(int groupnumber, const QString& message, con
|
||||||
|
|
||||||
bool targeted = (author != name) && message.contains(name, Qt::CaseInsensitive);
|
bool targeted = (author != name) && message.contains(name, Qt::CaseInsensitive);
|
||||||
if (targeted)
|
if (targeted)
|
||||||
g->chatForm->addAlertMessage(author, message, QDateTime::currentDateTime());
|
g->getChatForm()->addAlertMessage(author, message, QDateTime::currentDateTime());
|
||||||
else
|
else
|
||||||
g->chatForm->addMessage(author, message, isAction, QDateTime::currentDateTime());
|
g->getChatForm()->addMessage(author, message, isAction, QDateTime::currentDateTime());
|
||||||
|
|
||||||
if ((static_cast<GenericChatroomWidget*>(g->widget) != activeChatroomWidget) || isMinimized() || !isActiveWindow())
|
if ((static_cast<GenericChatroomWidget*>(g->getGroupWidget()) != activeChatroomWidget) || isMinimized() || !isActiveWindow())
|
||||||
{
|
{
|
||||||
g->hasNewMessages = 1;
|
g->setEventFlag(true);
|
||||||
if (targeted)
|
if (targeted)
|
||||||
{
|
{
|
||||||
newMessageAlert(g->widget);
|
newMessageAlert(g->getGroupWidget());
|
||||||
g->userWasMentioned = 1; // useful for highlighting line or desktop notifications
|
g->setMentionedFlag(true); // useful for highlighting line or desktop notifications
|
||||||
}
|
}
|
||||||
g->widget->updateStatusLight();
|
g->getGroupWidget()->updateStatusLight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -951,14 +951,16 @@ void Widget::onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t Cha
|
||||||
{
|
{
|
||||||
if (name.isEmpty())
|
if (name.isEmpty())
|
||||||
name = tr("<Unknown>", "Placeholder when we don't know someone's name in a group chat");
|
name = tr("<Unknown>", "Placeholder when we don't know someone's name in a group chat");
|
||||||
g->addPeer(peernumber,name);
|
// g->addPeer(peernumber,name);
|
||||||
|
g->regeneratePeerList();
|
||||||
//g->chatForm->addSystemInfoMessage(tr("%1 has joined the chat").arg(name), "green");
|
//g->chatForm->addSystemInfoMessage(tr("%1 has joined the chat").arg(name), "green");
|
||||||
// we can't display these messages until irungentoo fixes peernumbers
|
// we can't display these messages until irungentoo fixes peernumbers
|
||||||
// https://github.com/irungentoo/toxcore/issues/1128
|
// https://github.com/irungentoo/toxcore/issues/1128
|
||||||
}
|
}
|
||||||
else if (change == TOX_CHAT_CHANGE_PEER_DEL)
|
else if (change == TOX_CHAT_CHANGE_PEER_DEL)
|
||||||
{
|
{
|
||||||
g->removePeer(peernumber);
|
// g->removePeer(peernumber);
|
||||||
|
g->regeneratePeerList();
|
||||||
//g->chatForm->addSystemInfoMessage(tr("%1 has left the chat").arg(name), "silver");
|
//g->chatForm->addSystemInfoMessage(tr("%1 has left the chat").arg(name), "silver");
|
||||||
}
|
}
|
||||||
else if (change == TOX_CHAT_CHANGE_PEER_NAME) // core overwrites old name before telling us it changed...
|
else if (change == TOX_CHAT_CHANGE_PEER_NAME) // core overwrites old name before telling us it changed...
|
||||||
|
@ -973,19 +975,19 @@ void Widget::onGroupTitleChanged(int groupnumber, const QString& author, const Q
|
||||||
|
|
||||||
g->setName(title);
|
g->setName(title);
|
||||||
if (!author.isEmpty())
|
if (!author.isEmpty())
|
||||||
g->chatForm->addSystemInfoMessage(tr("%1 has set the title to %2").arg(author, title), "silver", QDateTime::currentDateTime());
|
g->getChatForm()->addSystemInfoMessage(tr("%1 has set the title to %2").arg(author, title), "silver", QDateTime::currentDateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::removeGroup(Group* g, bool fake)
|
void Widget::removeGroup(Group* g, bool fake)
|
||||||
{
|
{
|
||||||
g->widget->setAsInactiveChatroom();
|
g->getGroupWidget()->setAsInactiveChatroom();
|
||||||
if (static_cast<GenericChatroomWidget*>(g->widget) == activeChatroomWidget)
|
if (static_cast<GenericChatroomWidget*>(g->getGroupWidget()) == activeChatroomWidget)
|
||||||
{
|
{
|
||||||
activeChatroomWidget = nullptr;
|
activeChatroomWidget = nullptr;
|
||||||
onAddClicked();
|
onAddClicked();
|
||||||
}
|
}
|
||||||
GroupList::removeGroup(g->groupId, fake);
|
GroupList::removeGroup(g->getGroupId(), fake);
|
||||||
core->removeGroup(g->groupId, fake);
|
core->removeGroup(g->getGroupId(), fake);
|
||||||
delete g;
|
delete g;
|
||||||
if (ui->mainHead->layout()->isEmpty())
|
if (ui->mainHead->layout()->isEmpty())
|
||||||
onAddClicked();
|
onAddClicked();
|
||||||
|
@ -1016,15 +1018,15 @@ Group *Widget::createGroup(int groupId)
|
||||||
QString groupName = QString("Groupchat #%1").arg(groupId);
|
QString groupName = QString("Groupchat #%1").arg(groupId);
|
||||||
Group* newgroup = GroupList::addGroup(groupId, groupName, true);
|
Group* newgroup = GroupList::addGroup(groupId, groupName, true);
|
||||||
QLayout* layout = contactListWidget->getGroupLayout();
|
QLayout* layout = contactListWidget->getGroupLayout();
|
||||||
layout->addWidget(newgroup->widget);
|
layout->addWidget(newgroup->getGroupWidget());
|
||||||
newgroup->widget->updateStatusLight();
|
newgroup->getGroupWidget()->updateStatusLight();
|
||||||
|
|
||||||
connect(newgroup->widget, SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), this, SLOT(onChatroomWidgetClicked(GenericChatroomWidget*)));
|
connect(newgroup->getGroupWidget(), SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), this, SLOT(onChatroomWidgetClicked(GenericChatroomWidget*)));
|
||||||
connect(newgroup->widget, SIGNAL(removeGroup(int)), this, SLOT(removeGroup(int)));
|
connect(newgroup->getGroupWidget(), SIGNAL(removeGroup(int)), this, SLOT(removeGroup(int)));
|
||||||
connect(newgroup->widget, SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), newgroup->chatForm, SLOT(focusInput()));
|
connect(newgroup->getGroupWidget(), SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), newgroup->getChatForm(), SLOT(focusInput()));
|
||||||
connect(newgroup->chatForm, SIGNAL(sendMessage(int,QString)), core, SLOT(sendGroupMessage(int,QString)));
|
connect(newgroup->getChatForm(), SIGNAL(sendMessage(int,QString)), core, SLOT(sendGroupMessage(int,QString)));
|
||||||
connect(newgroup->chatForm, SIGNAL(sendAction(int,QString)), core, SLOT(sendGroupAction(int,QString)));
|
connect(newgroup->getChatForm(), SIGNAL(sendAction(int,QString)), core, SLOT(sendGroupAction(int,QString)));
|
||||||
connect(newgroup->chatForm, &GroupChatForm::groupTitleChanged, core, &Core::changeGroupTitle);
|
connect(newgroup->getChatForm(), &GroupChatForm::groupTitleChanged, core, &Core::changeGroupTitle);
|
||||||
return newgroup;
|
return newgroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1122,7 +1124,7 @@ void Widget::onGroupSendResult(int groupId, const QString& message, int result)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (result == -1)
|
if (result == -1)
|
||||||
g->chatForm->addSystemInfoMessage(tr("Message failed to send"), "red", QDateTime::currentDateTime());
|
g->getChatForm()->addSystemInfoMessage(tr("Message failed to send"), "red", QDateTime::currentDateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::getPassword(QString info, int passtype, uint8_t* salt)
|
void Widget::getPassword(QString info, int passtype, uint8_t* salt)
|
||||||
|
@ -1214,5 +1216,5 @@ void Widget::reloadTheme()
|
||||||
f->getFriendWidget()->reloadTheme();
|
f->getFriendWidget()->reloadTheme();
|
||||||
|
|
||||||
for (Group* g : GroupList::getAllGroups())
|
for (Group* g : GroupList::getAllGroups())
|
||||||
g->widget->reloadTheme();
|
g->getGroupWidget()->reloadTheme();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user