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

Merge remote-tracking branch 'thenain38/master'

This commit is contained in:
agilob 2015-10-08 19:00:08 +01:00
commit bc6e2287d9
No known key found for this signature in database
GPG Key ID: 296F0B764741106C
3 changed files with 37 additions and 7 deletions

View File

@ -164,7 +164,11 @@ void GroupChatForm::onSendTriggered()
void GroupChatForm::onUserListChanged() void GroupChatForm::onUserListChanged()
{ {
nusersLabel->setText(tr("%1 users in chat", "Number of users in chat").arg(group->getPeersCount())); int peersCount = group->getPeersCount();
if (peersCount == 1)
nusersLabel->setText(tr("1 user in chat", "Number of users in chat"));
else
nusersLabel->setText(tr("%1 users in chat", "Number of users in chat").arg(peersCount));
QLayoutItem *child; QLayoutItem *child;
while ((child = namesListLayout->takeAt(0))) while ((child = namesListLayout->takeAt(0)))
@ -204,7 +208,7 @@ void GroupChatForm::onUserListChanged()
} }
// Enable or disable call button // Enable or disable call button
if (group->getPeersCount() != 1) if (peersCount != 1)
{ {
callButton->setEnabled(true); callButton->setEnabled(true);
callButton->setObjectName("green"); callButton->setObjectName("green");
@ -367,5 +371,9 @@ void GroupChatForm::keyReleaseEvent(QKeyEvent* ev)
void GroupChatForm::retranslateUi() void GroupChatForm::retranslateUi()
{ {
nusersLabel->setText(GroupChatForm::tr("%1 users in chat", "Number of users in chat").arg(group->getPeersCount())); int peersCount = group->getPeersCount();
if (peersCount == 1)
nusersLabel->setText(tr("1 user in chat", "Number of users in chat"));
else
nusersLabel->setText(tr("%1 users in chat", "Number of users in chat").arg(peersCount));
} }

View File

@ -27,6 +27,7 @@
#include "src/widget/style.h" #include "src/widget/style.h"
#include "src/core/core.h" #include "src/core/core.h"
#include "tool/croppinglabel.h" #include "tool/croppinglabel.h"
#include "src/widget/translator.h"
#include <QPalette> #include <QPalette>
#include <QMenu> #include <QMenu>
#include <QContextMenuEvent> #include <QContextMenuEvent>
@ -56,6 +57,7 @@ GroupWidget::GroupWidget(int GroupId, QString Name)
emit g->getChatForm()->groupTitleChanged(groupId, newName.left(128)); emit g->getChatForm()->groupTitleChanged(groupId, newName.left(128));
} }
}); });
Translator::registerHandler(std::bind(&GroupWidget::retranslateUi, this), this);
} }
void GroupWidget::contextMenuEvent(QContextMenuEvent* event) void GroupWidget::contextMenuEvent(QContextMenuEvent* event)
@ -82,7 +84,7 @@ void GroupWidget::contextMenuEvent(QContextMenuEvent* event)
menu.addSeparator(); menu.addSeparator();
QAction* setTitle = menu.addAction(tr("Set title...")); QAction* setTitle = menu.addAction(tr("Set title..."));
QAction* quitGroup = menu.addAction(tr("Quit group","Menu to quit a groupchat")); QAction* quitGroup = menu.addAction(tr("Quit group", "Menu to quit a groupchat"));
QAction* selectedItem = menu.exec(event->globalPos()); QAction* selectedItem = menu.exec(event->globalPos());
@ -145,9 +147,13 @@ 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->getPeersCount())); {
else int peersCount = g->getPeersCount();
statusMessageLabel->setText(tr("0 users in chat")); if (peersCount == 1)
statusMessageLabel->setText(tr("1 user in chat"));
else
statusMessageLabel->setText(tr("%1 users in chat").arg(peersCount));
}
} }
void GroupWidget::setAsActiveChatroom() void GroupWidget::setAsActiveChatroom()
@ -249,3 +255,16 @@ void GroupWidget::setName(const QString& name)
{ {
nameLabel->setText(name); nameLabel->setText(name);
} }
void GroupWidget::retranslateUi()
{
Group* g = GroupList::findGroup(groupId);
if (g)
{
int peersCount = g->getPeersCount();
if (peersCount == 1)
statusMessageLabel->setText(tr("1 user in chat"));
else
statusMessageLabel->setText(tr("%1 users in chat").arg(peersCount));
}
}

View File

@ -52,6 +52,9 @@ protected:
void dragLeaveEvent(QDragLeaveEvent* ev) override; void dragLeaveEvent(QDragLeaveEvent* ev) override;
void dropEvent(QDropEvent* ev) override; void dropEvent(QDropEvent* ev) override;
private:
void retranslateUi();
public: public:
int groupId; int groupId;
}; };