mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
set aliases from chat form (half of #780)
This commit is contained in:
parent
bc45ff3a28
commit
845216fa2f
|
@ -76,6 +76,8 @@ ChatForm::ChatForm(Friend* chatFriend)
|
|||
connect(chatWidget, &ChatAreaWidget::onFileTranfertInterract, this, &ChatForm::onFileTansBtnClicked);
|
||||
connect(Core::getInstance(), &Core::fileSendFailed, this, &ChatForm::onFileSendFailed);
|
||||
connect(this, SIGNAL(chatAreaCleared()), this, SLOT(clearReciepts()));
|
||||
connect(nameLabel, &CroppingLabel::textChanged, this, [=](QString text, QString orig)
|
||||
{if (text != orig) emit aliasChanged(text);} );
|
||||
|
||||
setAcceptDrops(true);
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ signals:
|
|||
void cancelCall(int callId, int friendId);
|
||||
void micMuteToggle(int callId);
|
||||
void volMuteToggle(int callId);
|
||||
void aliasChanged(const QString& alias);
|
||||
|
||||
public slots:
|
||||
void deliverOfflineMsgs();
|
||||
|
|
|
@ -47,6 +47,7 @@ GenericChatForm::GenericChatForm(QWidget *parent) :
|
|||
nameLabel = new CroppingLabel();
|
||||
nameLabel->setObjectName("nameLabel");
|
||||
nameLabel->setMinimumHeight(Style::getFont(Style::Medium).pixelSize());
|
||||
nameLabel->setEditable(true);
|
||||
|
||||
avatar = new MaskablePixmapWidget(this, QSize(40,40), ":/img/avatar_mask.png");
|
||||
QHBoxLayout *headLayout = new QHBoxLayout(), *mainFootLayout = new QHBoxLayout();
|
||||
|
|
|
@ -52,7 +52,6 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
|
|||
}
|
||||
|
||||
nameLabel->setText(group->widget->getName());
|
||||
nameLabel->setEditable(true);
|
||||
|
||||
nusersLabel->setFont(Style::getFont(Style::Medium));
|
||||
nusersLabel->setText(GroupChatForm::tr("%1 users in chat","Number of users in chat").arg(group->peers.size()));
|
||||
|
|
|
@ -218,6 +218,18 @@ void FriendWidget::mouseMoveEvent(QMouseEvent *ev)
|
|||
}
|
||||
}
|
||||
|
||||
void FriendWidget::setAlias(const QString& _alias)
|
||||
{
|
||||
QString alias = _alias.trimmed();
|
||||
alias.remove(QRegExp("[\\t\\n\\v\\f\\r\\x0000]")); // we should really treat regular names this way as well (*ahem* zetok)
|
||||
alias = alias.left(128); // same as TOX_MAX_NAME_LENGTH
|
||||
Friend* f = FriendList::findFriend(friendId);
|
||||
f->setAlias(alias);
|
||||
Settings::getInstance().setFriendAlias(f->getToxID(), alias);
|
||||
hide();
|
||||
show();
|
||||
}
|
||||
|
||||
void FriendWidget::setFriendAlias()
|
||||
{
|
||||
bool ok;
|
||||
|
@ -227,13 +239,5 @@ void FriendWidget::setFriendAlias()
|
|||
f->getDisplayedName(), &ok);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
alias = alias.trimmed();
|
||||
alias.remove(QRegExp("[\t\n\v\f\r]"));
|
||||
alias = alias.left(128); // same as TOX_MAX_NAME_LENGTH
|
||||
f->setAlias(alias);
|
||||
Settings::getInstance().setFriendAlias(f->getToxID(), alias);
|
||||
hide();
|
||||
show();
|
||||
}
|
||||
setAlias(alias);
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ signals:
|
|||
public slots:
|
||||
void onAvatarChange(int FriendId, const QPixmap& pic);
|
||||
void onAvatarRemoved(int FriendId);
|
||||
void setAlias(const QString& alias);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent* ev);
|
||||
|
|
|
@ -646,6 +646,7 @@ void Widget::addFriend(int friendId, const QString &userId)
|
|||
connect(newfriend->getChatForm(), SIGNAL(cancelCall(int,int)), core, SLOT(cancelCall(int,int)));
|
||||
connect(newfriend->getChatForm(), SIGNAL(micMuteToggle(int)), core, SLOT(micMuteToggle(int)));
|
||||
connect(newfriend->getChatForm(), SIGNAL(volMuteToggle(int)), core, SLOT(volMuteToggle(int)));
|
||||
connect(newfriend->getChatForm(), &ChatForm::aliasChanged, newfriend->getFriendWidget(), &FriendWidget::setAlias);
|
||||
connect(core, &Core::fileReceiveRequested, newfriend->getChatForm(), &ChatForm::onFileRecvRequest);
|
||||
connect(core, &Core::avInvite, newfriend->getChatForm(), &ChatForm::onAvInvite);
|
||||
connect(core, &Core::avStart, newfriend->getChatForm(), &ChatForm::onAvStart);
|
||||
|
|
Loading…
Reference in New Issue
Block a user