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

Merge branch 'pr1605'

Ask to remove history

Also adds ability to cancel friend removal
This commit is contained in:
tux3 2015-05-10 11:41:07 +02:00
commit 260918c1aa
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
2 changed files with 13 additions and 5 deletions

View File

@ -92,9 +92,6 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
} }
else if (selectedItem == removeFriendAction) else if (selectedItem == removeFriendAction)
{ {
hide();
show(); //Toggle visibility to work around bug of repaintEvent() not being fired on parent widget when this is hidden
hide();
emit removeFriend(friendId); emit removeFriend(friendId);
return; return;
} }

View File

@ -858,15 +858,26 @@ void Widget::onFriendRequestReceived(const QString& userId, const QString& messa
void Widget::removeFriend(Friend* f, bool fake) void Widget::removeFriend(Friend* f, bool fake)
{ {
QMessageBox::StandardButton removeFriendMB;
removeFriendMB = QMessageBox::question(0,
tr("Remove history"),
tr("Do you want to remove history as well?"),
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
if (removeFriendMB == QMessageBox::Cancel)
return;
else if (removeFriendMB == QMessageBox::Yes)
HistoryKeeper::getInstance()->removeFriendHistory(f->getToxID().publicKey);
f->getFriendWidget()->setAsInactiveChatroom(); f->getFriendWidget()->setAsInactiveChatroom();
if (static_cast<GenericChatroomWidget*>(f->getFriendWidget()) == activeChatroomWidget) if (static_cast<GenericChatroomWidget*>(f->getFriendWidget()) == activeChatroomWidget)
{ {
activeChatroomWidget = nullptr; activeChatroomWidget = nullptr;
onAddClicked(); onAddClicked();
} }
FriendList::removeFriend(f->getFriendID(), fake); FriendList::removeFriend(f->getFriendID(), fake);
Nexus::getCore()->removeFriend(f->getFriendID(), fake); Nexus::getCore()->removeFriend(f->getFriendID(), fake);
HistoryKeeper::getInstance()->removeFriendHistory(f->getToxID().publicKey);
delete f; delete f;
if (ui->mainHead->layout()->isEmpty()) if (ui->mainHead->layout()->isEmpty())
onAddClicked(); onAddClicked();