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

Merge pull request #385 from dubslow/master

Simplify groupchat names
This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-10-06 20:28:53 +02:00
commit 3de960b2aa
13 changed files with 25 additions and 82 deletions

View File

@ -439,9 +439,10 @@ void Core::onGroupInvite(Tox*, int friendnumber, const uint8_t *group_public_key
emit static_cast<Core*>(core)->groupInviteReceived(friendnumber, group_public_key,length);
}
void Core::onGroupMessage(Tox*, int groupnumber, int friendgroupnumber, const uint8_t * message, uint16_t length, void *core)
void Core::onGroupMessage(Tox*, int groupnumber, int peernumber, const uint8_t * message, uint16_t length, void *_core)
{
emit static_cast<Core*>(core)->groupMessageReceived(groupnumber, friendgroupnumber, CString::toString(message, length));
Core* core = static_cast<Core*>(_core);
emit core->groupMessageReceived(groupnumber, CString::toString(message, length), core->getGroupPeerName(groupnumber, peernumber));
}
void Core::onGroupNamelistChange(Tox*, int groupnumber, int peernumber, uint8_t change, void *core)

2
core.h
View File

@ -118,7 +118,7 @@ signals:
void emptyGroupCreated(int groupnumber);
void groupInviteReceived(int friendnumber, const uint8_t *group_public_key,uint16_t length);
void groupMessageReceived(int groupnumber, int friendgroupnumber, const QString& message);
void groupMessageReceived(int groupnumber, const QString& message, const QString& author);
void groupNamelistChanged(int groupnumber, int peernumber, uint8_t change);
void usernameSet(const QString& username);

View File

@ -24,16 +24,14 @@
#include <QTimer>
Group::Group(int GroupId, QString Name)
: groupId(GroupId), nPeers{0}, hasPeerInfo{false}, peerInfoTimer{new QTimer}
: groupId(GroupId), nPeers{0}
{
widget = new GroupWidget(groupId, Name);
chatForm = new GroupChatForm(this);
connect(peerInfoTimer, SIGNAL(timeout()), this, SLOT(queryPeerInfo()));
peerInfoTimer->setInterval(500);
peerInfoTimer->setSingleShot(false);
//peerInfoTimer.start();
//in groupchats, we only notify on messages containing your name
//in groupchats, we only notify on messages containing your name <-- dumb
// sound notifications should be on all messages, but system popup notification
// on naming is appropriate
hasNewMessages = 0;
userWasMentioned = 0;
}
@ -42,53 +40,6 @@ Group::~Group()
{
delete chatForm;
delete widget;
delete peerInfoTimer;
}
void Group::queryPeerInfo()
{
const Core* core = Core::getInstance();
int nPeersResult = core->getGroupNumberPeers(groupId);
if (nPeersResult == -1)
{
qDebug() << "Group::queryPeerInfo: Can't get number of peers";
return;
}
nPeers = nPeersResult;
widget->onUserListChanged();
chatForm->onUserListChanged();
if (nPeersResult == 0)
return;
bool namesOk = true;
QList<QString> names = core->getGroupPeerNames(groupId);
if (names.isEmpty())
{
qDebug() << "Group::queryPeerInfo: Can't get names of peers";
return;
}
for (int i=0; i<names.size(); i++)
{
QString name = names[i];
if (name.isEmpty())
{
name = "<Unknown>";
namesOk = false;
}
peers[i] = name;
}
nPeers = names.size();
widget->onUserListChanged();
chatForm->onUserListChanged();
if (namesOk)
{
qDebug() << "Group::queryPeerInfo: Successfully loaded names";
hasPeerInfo = true;
peerInfoTimer->stop();
}
}
void Group::addPeer(int peerId, QString name)

View File

@ -25,7 +25,6 @@
struct Friend;
class GroupWidget;
class GroupChatForm;
class QTimer;
class Group : public QObject
{
@ -37,17 +36,12 @@ public:
void removePeer(int peerId);
void updatePeer(int peerId, QString newName);
private slots:
void queryPeerInfo();
public:
int groupId;
QMap<int,QString> peers;
int nPeers;
GroupWidget* widget;
GroupChatForm* chatForm;
bool hasPeerInfo;
QTimer* peerInfoTimer;
int hasNewMessages, userWasMentioned;
};

BIN
smileys/default/Kappa.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -82,4 +82,7 @@
<string>XD</string>
</emoticon>
<emoticon file="Kappa.png">
<string>:Kappa:</string>
</emoticon>
</messaging-emoticon-map>

View File

@ -87,7 +87,7 @@ mv qTox-master $VERNAME
# Build packages
cd $VERNAME
./bootstrap.sh
./bootstrap.sh --local
debuild -us -uc -aamd64
debuild -us -uc -ai386
cd ..

View File

@ -38,7 +38,7 @@ ChatAreaWidget::ChatAreaWidget(QWidget *parent)
setFrameStyle(QFrame::NoFrame);
QTextTableFormat tableFormat;
tableFormat.setCellSpacing(15);
tableFormat.setCellSpacing(5);
tableFormat.setBorderStyle(QTextFrameFormat::BorderStyle_None);
tableFormat.setColumnWidthConstraints({QTextLength(QTextLength::FixedLength,nameWidth),
QTextLength(QTextLength::PercentageLength,100),

View File

@ -172,6 +172,12 @@ void GenericChatForm::addMessage(QString author, QString message, bool isAction,
QString date = datetime.toString(Settings::getInstance().getTimestampFormat());
bool isMe = (author == Widget::getInstance()->getUsername());
if (!isAction && message.startsWith("/me "))
{ // always render actions regardless of what core thinks
isAction = true;
message = message.right(message.length()-4);
}
if (isAction)
{
chatWidget->insertMessage(new ActionAction (getElidedName(author), message, date, isMe));

View File

@ -80,17 +80,6 @@ void GroupChatForm::onSendTriggered()
emit sendMessage(group->groupId, msg);
}
void GroupChatForm::addGroupMessage(QString message, int peerId)
{
QString msgAuthor;
if (group->peers.contains(peerId))
msgAuthor = group->peers[peerId];
else
msgAuthor = tr("<Unknown>");
addMessage(msgAuthor, message);
}
void GroupChatForm::onUserListChanged()
{
nusersLabel->setText(tr("%1 users in chat").arg(group->nPeers));

View File

@ -28,7 +28,6 @@ class GroupChatForm : public GenericChatForm
public:
GroupChatForm(Group* chatGroup);
void addGroupMessage(QString message, int peerId);
void onUserListChanged();
private slots:

View File

@ -212,7 +212,7 @@ void Widget::closeEvent(QCloseEvent *event)
QString Widget::getUsername()
{
return ui->nameLabel->text();
return core->getUsername();
}
Camera* Widget::getCamera()
@ -574,21 +574,21 @@ void Widget::onGroupInviteReceived(int32_t friendId, const uint8_t* publicKey,ui
}
}
void Widget::onGroupMessageReceived(int groupnumber, int friendgroupnumber, const QString& message)
void Widget::onGroupMessageReceived(int groupnumber, const QString& message, const QString& author)
{
Group* g = GroupList::findGroup(groupnumber);
if (!g)
return;
g->chatForm->addGroupMessage(message, friendgroupnumber);
g->chatForm->addMessage(author, message);
if ((static_cast<GenericChatroomWidget*>(g->widget) != activeChatroomWidget) || isMinimized() || !isActiveWindow())
{
g->hasNewMessages = 1;
newMessageAlert(); // sound alert on any message, not just naming user
if (message.contains(core->getUsername(), Qt::CaseInsensitive))
{
newMessageAlert();
g->userWasMentioned = 1;
g->userWasMentioned = 1; // useful for highlighting line or desktop notifications
}
g->widget->updateStatusLight();
}

View File

@ -94,7 +94,7 @@ private slots:
void onFriendRequestReceived(const QString& userId, const QString& message);
void onEmptyGroupCreated(int groupId);
void onGroupInviteReceived(int32_t friendId, const uint8_t *publicKey,uint16_t length);
void onGroupMessageReceived(int groupnumber, int friendgroupnumber, const QString& message);
void onGroupMessageReceived(int groupnumber, const QString& message, const QString& author);
void onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t change);
void removeFriend(int friendId);
void copyFriendIdToClipboard(int friendId);