diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index da71693bc..45001615a 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -1,5 +1,5 @@ /* - Copyright © 2014-2019 by The qTox Project Contributors + Copyright © 2014-2022 by The qTox Project Contributors This file is part of qTox, a Qt-based graphical interface for Tox. @@ -1746,7 +1746,16 @@ void Widget::removeFriend(Friend* f, bool fake) { assert(f); if (!fake) { - removeChatHistory(*f); + RemoveChatDialog ask(this, *f); + ask.exec(); + + if (!ask.accepted()) { + return; + } + + if (ask.removeHistory()) { + profile.getHistory()->removeChatHistory(f->getPersistentId()); + } } const ToxPk friendPk = f->getPublicKey(); @@ -2054,7 +2063,16 @@ void Widget::removeGroup(Group* g, bool fake) { assert(g); if (!fake) { - removeChatHistory(*g); + RemoveChatDialog ask(this, *g); + ask.exec(); + + if (!ask.accepted()) { + return; + } + + if (ask.removeHistory()) { + profile.getHistory()->removeChatHistory(g->getPersistentId()); + } } const auto& groupId = g->getPersistentId(); @@ -2737,17 +2755,3 @@ void Widget::formatWindowTitle(const QString& content) setWindowTitle(content + " - qTox"); } } - -void Widget::removeChatHistory(Chat& chat) -{ - RemoveChatDialog ask(this, chat); - ask.exec(); - - if (!ask.accepted()) { - return; - } - - if (ask.removeHistory()) { - profile.getHistory()->removeChatHistory(chat.getPersistentId()); - } -} diff --git a/src/widget/widget.h b/src/widget/widget.h index 6fcf64179..3caad6ca3 100644 --- a/src/widget/widget.h +++ b/src/widget/widget.h @@ -90,6 +90,7 @@ class IMessageBoxManager; class ContentDialogManager; class FriendList; class GroupList; +class RemoveChatDialog; class Widget final : public QMainWindow { @@ -287,7 +288,6 @@ private: void cleanupNotificationSound(); void acceptFileTransfer(const ToxFile &file, const QString &path); void formatWindowTitle(const QString& content); - void removeChatHistory(Chat& chat); private: Profile& profile;