diff --git a/src/widget/friendwidget.cpp b/src/widget/friendwidget.cpp index 8a85ea321..65d6eded5 100644 --- a/src/widget/friendwidget.cpp +++ b/src/widget/friendwidget.cpp @@ -92,9 +92,6 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event) } 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); return; } diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 5a75bad49..c78efe3d6 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -857,16 +857,27 @@ void Widget::onFriendRequestReceived(const QString& userId, const QString& messa } 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(); if (static_cast(f->getFriendWidget()) == activeChatroomWidget) { activeChatroomWidget = nullptr; onAddClicked(); } + FriendList::removeFriend(f->getFriendID(), fake); Nexus::getCore()->removeFriend(f->getFriendID(), fake); - HistoryKeeper::getInstance()->removeFriendHistory(f->getToxID().publicKey); + delete f; if (ui->mainHead->layout()->isEmpty()) onAddClicked();