mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Update activity on friendship, fix category friend removing (circles and activity)
This commit is contained in:
parent
e233d7d1c6
commit
c662c0aa92
@ -603,6 +603,7 @@ void Core::acceptFriendRequest(const QString& userId)
|
||||
{
|
||||
profile.saveToxSave();
|
||||
emit friendAdded(friendId, userId);
|
||||
emit friendshipChanged(friendId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -644,6 +645,7 @@ void Core::requestFriendship(const QString& friendAddress, const QString& messag
|
||||
|
||||
HistoryKeeper::getInstance()->addChatEntry(userId, inviteStr, getSelfId().publicKey, QDateTime::currentDateTime(), true);
|
||||
emit friendAdded(friendId, userId);
|
||||
emit friendshipChanged(friendId);
|
||||
}
|
||||
}
|
||||
profile.saveToxSave();
|
||||
|
@ -163,6 +163,7 @@ signals:
|
||||
void friendMessageReceived(uint32_t friendId, const QString& message, bool isAction);
|
||||
|
||||
void friendAdded(uint32_t friendId, const QString& userId);
|
||||
void friendshipChanged(uint32_t friendId);
|
||||
|
||||
void friendStatusChanged(uint32_t friendId, Status status);
|
||||
void friendStatusMessageChanged(uint32_t friendId, const QString& message);
|
||||
|
@ -163,6 +163,7 @@ void Nexus::showMainGUI()
|
||||
connect(core, &Core::statusMessageSet, widget, &Widget::setStatusMessage);
|
||||
connect(core, &Core::selfAvatarChanged, widget, &Widget::onSelfAvatarLoaded);
|
||||
connect(core, &Core::friendAdded, widget, &Widget::addFriend);
|
||||
connect(core, &Core::friendshipChanged, widget, &Widget::onFriendshipChanged);
|
||||
connect(core, &Core::failedToAddFriend, widget, &Widget::addFriendFailed);
|
||||
connect(core, &Core::friendUsernameChanged, widget, &Widget::onFriendUsernameChanged);
|
||||
connect(core, &Core::friendStatusChanged, widget, &Widget::onFriendStatusChanged);
|
||||
|
@ -114,6 +114,12 @@ void CategoryWidget::addFriendWidget(FriendWidget* w, Status s)
|
||||
onAddFriendWidget(w);
|
||||
}
|
||||
|
||||
void CategoryWidget::removeFriendWidget(FriendWidget* w, Status s)
|
||||
{
|
||||
listLayout->removeFriendWidget(w, s);
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
void CategoryWidget::updateStatus()
|
||||
{
|
||||
statusLabel->setText(QString::number(listLayout->friendOnlineCount()) + QStringLiteral(" / ") + QString::number(listLayout->friendTotalCount()));
|
||||
|
@ -40,6 +40,7 @@ public:
|
||||
void setName(const QString &name);
|
||||
|
||||
void addFriendWidget(FriendWidget* w, Status s);
|
||||
void removeFriendWidget(FriendWidget* w, Status s);
|
||||
void updateStatus();
|
||||
|
||||
bool hasChatrooms() const;
|
||||
|
@ -52,6 +52,14 @@ void FriendListLayout::addFriendWidget(FriendWidget* w, Status s)
|
||||
friendOnlineLayout.addSortedWidget(w);
|
||||
}
|
||||
|
||||
void FriendListLayout::removeFriendWidget(FriendWidget *widget, Status s)
|
||||
{
|
||||
if (s == Status::Offline)
|
||||
friendOfflineLayout.removeSortedWidget(widget);
|
||||
else
|
||||
friendOnlineLayout.removeSortedWidget(widget);
|
||||
}
|
||||
|
||||
int FriendListLayout::indexOfFriendWidget(FriendWidget* widget, bool online) const
|
||||
{
|
||||
if (online)
|
||||
|
@ -30,6 +30,7 @@ public:
|
||||
explicit FriendListLayout(QWidget* parent);
|
||||
|
||||
void addFriendWidget(FriendWidget* widget, Status s);
|
||||
void removeFriendWidget(FriendWidget* widget, Status s);
|
||||
int indexOfFriendWidget(FriendWidget* widget, bool online) const;
|
||||
void moveFriendWidgets(FriendListWidget* listWidget);
|
||||
int friendOnlineCount() const;
|
||||
|
@ -283,6 +283,29 @@ void FriendListWidget::addFriendWidget(FriendWidget* w, Status s, int circleInde
|
||||
circleWidget->addFriendWidget(w, s);
|
||||
}
|
||||
|
||||
void FriendListWidget::removeFriendWidget(FriendWidget* w)
|
||||
{
|
||||
Friend* contact = FriendList::findFriend(w->friendId);
|
||||
if (mode == Activity)
|
||||
{
|
||||
QDate activityDate = Settings::getInstance().getFriendActivity(contact->getToxId());
|
||||
Time time = getTime(activityDate);
|
||||
CategoryWidget* categoryWidget = dynamic_cast<CategoryWidget*>(activityLayout->itemAt(time)->widget());
|
||||
categoryWidget->removeFriendWidget(w, contact->getStatus());
|
||||
categoryWidget->setVisible(categoryWidget->hasChatrooms());
|
||||
}
|
||||
else
|
||||
{
|
||||
int id = Settings::getInstance().getFriendCircleID(contact->getToxId());
|
||||
CircleWidget* circleWidget = CircleWidget::getFromID(id);
|
||||
if (circleWidget != nullptr)
|
||||
{
|
||||
circleWidget->removeFriendWidget(w, contact->getStatus());
|
||||
Widget::getInstance()->searchCircle(circleWidget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FriendListWidget::addCircleWidget(int id)
|
||||
{
|
||||
createCircleWidget(id);
|
||||
|
@ -50,6 +50,7 @@ public:
|
||||
|
||||
void addGroupWidget(GroupWidget* widget);
|
||||
void addFriendWidget(FriendWidget* w, Status s, int circleIndex);
|
||||
void removeFriendWidget(FriendWidget* w);
|
||||
void addCircleWidget(int id);
|
||||
void addCircleWidget(FriendWidget* widget = nullptr);
|
||||
void removeCircleWidget(CircleWidget* widget);
|
||||
|
@ -678,6 +678,12 @@ void Widget::addFriendFailed(const QString&, const QString& errorInfo)
|
||||
QMessageBox::critical(0,"Error",info);
|
||||
}
|
||||
|
||||
void Widget::onFriendshipChanged(int friendId)
|
||||
{
|
||||
Friend* who = FriendList::findFriend(friendId);
|
||||
updateFriendActivity(who);
|
||||
}
|
||||
|
||||
void Widget::onFriendStatusChanged(int friendId, Status status)
|
||||
{
|
||||
Friend* f = FriendList::findFriend(friendId);
|
||||
@ -920,6 +926,8 @@ void Widget::removeFriend(Friend* f, bool fake)
|
||||
onAddClicked();
|
||||
}
|
||||
|
||||
contactListWidget->removeFriendWidget(f->getFriendWidget());
|
||||
|
||||
FriendList::removeFriend(f->getFriendID(), fake);
|
||||
Nexus::getCore()->removeFriend(f->getFriendID(), fake);
|
||||
|
||||
|
@ -99,6 +99,7 @@ public slots:
|
||||
void setStatusMessage(const QString &statusMessage);
|
||||
void addFriend(int friendId, const QString& userId);
|
||||
void addFriendFailed(const QString& userId, const QString& errorInfo = QString());
|
||||
void onFriendshipChanged(int friendId);
|
||||
void onFriendStatusChanged(int friendId, Status status);
|
||||
void onFriendStatusMessageChanged(int friendId, const QString& message);
|
||||
void onFriendUsernameChanged(int friendId, const QString& username);
|
||||
|
Loading…
x
Reference in New Issue
Block a user