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

fix(addfriendform, widget): Remove Accepted Request

Fix #3066.
Fix #3166.
This commit is contained in:
Diadlo 2016-04-19 10:48:33 +03:00
parent 5966c84b84
commit 53071e952e
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
3 changed files with 18 additions and 1 deletions

View File

@ -173,6 +173,7 @@ void AddFriendForm::onSendTriggered()
id = toxId.toString();
}
deleteFriendRequest(id);
if (id.toUpper() == Core::getInstance()->getSelfId().toString().toUpper())
GUI::showWarning(tr("Couldn't add friend"), tr("You can't add yourself as a friend!","When trying to add your own Tox ID as friend"));
else
@ -222,6 +223,20 @@ void AddFriendForm::setIdFromClipboard()
}
}
void AddFriendForm::deleteFriendRequest(const QString& toxId)
{
int size = Settings::getInstance().getFriendRequestSize();
for (int i = 0; i < size; i++)
{
Settings::Request request = Settings::getInstance().getFriendRequest(i);
if (ToxId(toxId) == ToxId(request.address))
{
Settings::getInstance().removeFriendRequest(i);
return;
}
}
}
void AddFriendForm::onFriendRequestAccepted()
{
QPushButton* acceptButton = static_cast<QPushButton*>(sender());

View File

@ -75,9 +75,10 @@ private:
void removeFriendRequestWidget(QWidget *friendWidget);
void retranslateAcceptButton(QPushButton* acceptButton);
void retranslateRejectButton(QPushButton* rejectButton);
void deleteFriendRequest(const QString &toxId);
void setIdFromClipboard();
private:
void setIdFromClipboard();
QLabel headLabel, toxIdLabel, messageLabel;
QPushButton sendButton;
QLineEdit toxId;

View File

@ -392,6 +392,7 @@ void Widget::init()
groupInvitesButton = nullptr;
unreadGroupInvites = 0;
connect(addFriendForm, &AddFriendForm::friendRequested, this, &Widget::friendRequestsUpdate);
connect(addFriendForm, &AddFriendForm::friendRequestsSeen, this, &Widget::friendRequestsUpdate);
connect(addFriendForm, &AddFriendForm::friendRequestAccepted, this, &Widget::friendRequestAccepted);
connect(groupInviteForm, &GroupInviteForm::groupInvitesSeen, this, &Widget::groupInvitesClear);