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

Merge branch 'pr1846'

This commit is contained in:
tux3 2015-06-12 12:53:59 +02:00
commit ce2c8309a2
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
2 changed files with 30 additions and 2 deletions

View File

@ -69,9 +69,15 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
namesListLayout = new FlowLayout(0,5,0); namesListLayout = new FlowLayout(0,5,0);
QStringList names(group->getPeerList()); QStringList names(group->getPeerList());
for (const QString& name : names) for (QString& name : names)
{ {
QLabel *l = new QLabel(name); QLabel *l = new QLabel();
QString tooltip = correctNames(name);
if (tooltip.isNull())
{
l->setToolTip(tooltip);
}
l->setText(name);
l->setTextFormat(Qt::PlainText); l->setTextFormat(Qt::PlainText);
namesListLayout->addWidget(l); namesListLayout->addWidget(l);
} }
@ -97,6 +103,24 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
Translator::registerHandler(std::bind(&GroupChatForm::retranslateUi, this), this); Translator::registerHandler(std::bind(&GroupChatForm::retranslateUi, this), this);
} }
// Correct names with "\n" in NamesListLayout widget
QString GroupChatForm::correctNames(QString& name)
{
int pos = name.indexOf(QRegExp("\n|\r\n|\r"));
int len = name.length();
if ( (pos < len) && (pos !=-1) )
{
QString tooltip = name;
name.remove( pos, len-pos );
name.append("...");
return tooltip;
}
else
{
return QString();
}
}
GroupChatForm::~GroupChatForm() GroupChatForm::~GroupChatForm()
{ {
Translator::unregister(this); Translator::unregister(this);
@ -153,7 +177,10 @@ void GroupChatForm::onUserListChanged()
unsigned nNames = names.size(); unsigned nNames = names.size();
for (unsigned i=0; i<nNames; ++i) for (unsigned i=0; i<nNames; ++i)
{ {
QString tooltip = correctNames(names[i]);
peerLabels.append(new QLabel(names[i])); peerLabels.append(new QLabel(names[i]));
if (!tooltip.isEmpty())
peerLabels[i]->setToolTip(tooltip);
peerLabels[i]->setTextFormat(Qt::PlainText); peerLabels[i]->setTextFormat(Qt::PlainText);
orderizer[names[i]] = peerLabels[i]; orderizer[names[i]] = peerLabels[i];
if (group->isSelfPeerNumber(i)) if (group->isSelfPeerNumber(i))

View File

@ -66,6 +66,7 @@ private:
QLabel *nusersLabel; QLabel *nusersLabel;
TabCompleter* tabber; TabCompleter* tabber;
bool inCall; bool inCall;
QString correctNames(QString& name);
}; };
#endif // GROUPCHATFORM_H #endif // GROUPCHATFORM_H