From 69972e0d80d65ddda6deb86dadc3c4753282290b Mon Sep 17 00:00:00 2001 From: agilob Date: Sun, 10 May 2015 10:12:49 +0100 Subject: [PATCH] ask to remove history --- src/widget/friendwidget.cpp | 3 --- src/widget/widget.cpp | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) 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..e6c4443e6 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(this, + 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();