mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
parent
2ecfbf7f28
commit
aa7542f729
|
@ -296,6 +296,7 @@ void FriendListWidget::addFriendWidget(FriendWidget* w, Status s, int circleInde
|
|||
moveWidget(w, s, true);
|
||||
else
|
||||
circleWidget->addFriendWidget(w, s);
|
||||
connect(w, &FriendWidget::friendWidgetRenamed, this, &FriendListWidget::onFriendWidgetRenamed);
|
||||
}
|
||||
|
||||
void FriendListWidget::removeGroupWidget(GroupWidget* w)
|
||||
|
@ -395,6 +396,31 @@ void FriendListWidget::renameCircleWidget(CircleWidget* circleWidget, const QStr
|
|||
circleLayout->addSortedWidget(circleWidget);
|
||||
}
|
||||
|
||||
void FriendListWidget::onFriendWidgetRenamed(FriendWidget* friendWidget)
|
||||
{
|
||||
const Friend* contact = friendWidget->getFriend();
|
||||
auto status = contact->getStatus();
|
||||
if (mode == Activity) {
|
||||
QDate activityDate = getDateFriend(contact);
|
||||
int time = static_cast<int>(getTime(activityDate));
|
||||
QWidget* widget = activityLayout->itemAt(time)->widget();
|
||||
CategoryWidget* categoryWidget = qobject_cast<CategoryWidget*>(widget);
|
||||
categoryWidget->removeFriendWidget(friendWidget, status);
|
||||
categoryWidget->addFriendWidget(friendWidget, status);
|
||||
} else {
|
||||
int id = Settings::getInstance().getFriendCircleID(contact->getPublicKey());
|
||||
CircleWidget* circleWidget = CircleWidget::getFromID(id);
|
||||
if (circleWidget != nullptr) {
|
||||
circleWidget->removeFriendWidget(friendWidget, status);
|
||||
circleWidget->addFriendWidget(friendWidget, status);
|
||||
Widget::getInstance()->searchCircle(circleWidget);
|
||||
} else {
|
||||
listLayout->removeFriendWidget(friendWidget, status);
|
||||
listLayout->addFriendWidget(friendWidget, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FriendListWidget::onGroupchatPositionChanged(bool top)
|
||||
{
|
||||
groupsOnTop = top;
|
||||
|
|
|
@ -70,6 +70,7 @@ signals:
|
|||
public slots:
|
||||
void renameGroupWidget(GroupWidget* groupWidget, const QString& newName);
|
||||
void renameCircleWidget(CircleWidget* circleWidget, const QString& newName);
|
||||
void onFriendWidgetRenamed(FriendWidget* friendWidget);
|
||||
void onGroupchatPositionChanged(bool top);
|
||||
void moveWidget(FriendWidget* w, Status s, bool add = false);
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ FriendWidget::FriendWidget(std::shared_ptr<FriendChatroom> chatroom, bool compac
|
|||
connect(nameLabel, &CroppingLabel::editFinished, frnd, &Friend::setAlias);
|
||||
// update on changes of the displayed name
|
||||
connect(frnd, &Friend::displayedNameChanged, nameLabel, &CroppingLabel::setText);
|
||||
connect(frnd, &Friend::displayedNameChanged, [this](const QString /* &newName */){emit friendWidgetRenamed(this);});
|
||||
connect(chatroom.get(), &FriendChatroom::activeChanged, this, &FriendWidget::setActive);
|
||||
statusMessageLabel->setTextFormat(Qt::PlainText);
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ signals:
|
|||
void copyFriendIdToClipboard(int friendId);
|
||||
void contextMenuCalled(QContextMenuEvent* event);
|
||||
void friendHistoryRemoved();
|
||||
void friendWidgetRenamed(FriendWidget* friendWidget);
|
||||
|
||||
public slots:
|
||||
void onAvatarSet(const ToxPk& friendPk, const QPixmap& pic);
|
||||
|
|
Loading…
Reference in New Issue
Block a user