diff --git a/src/friend.cpp b/src/friend.cpp index ddeb748f2..622151f3c 100644 --- a/src/friend.cpp +++ b/src/friend.cpp @@ -37,8 +37,6 @@ Friend::Friend(uint32_t friendId, const ToxPk& friendPk, const QString& userAlia if (userName.isEmpty()) { userName = friendPk.toString(); } - - chatForm = new ChatForm(this); } Friend::~Friend() @@ -142,3 +140,8 @@ ChatForm* Friend::getChatForm() const { return chatForm; } + +void Friend::setChatForm(ChatForm* form) +{ + chatForm = form; +} diff --git a/src/friend.h b/src/friend.h index fc3e9c224..a8172b5f6 100644 --- a/src/friend.h +++ b/src/friend.h @@ -57,9 +57,9 @@ public: Status getStatus() const; ChatForm* getChatForm() const; + void setChatForm(ChatForm* form); signals: - // TODO: move signals to DB object void nameChanged(uint32_t friendId, const QString& name); void aliasChanged(uint32_t friendId, QString alias); void statusChanged(uint32_t friendId, Status status); diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 040edf4dd..ab80fcca1 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -963,10 +963,11 @@ void Widget::addFriend(int friendId, const ToxPk& friendPk) Friend* newfriend = FriendList::addFriend(friendId, friendPk); bool compact = Settings::getInstance().getCompactLayout(); FriendWidget* widget = new FriendWidget(newfriend, compact); - - ChatForm* friendForm = newfriend->getChatForm(); + ChatForm* friendForm = new ChatForm(newfriend); + newfriend->setChatForm(friendForm); friendWidgets[friendId] = widget; + chatForms[friendId] = friendForm; newfriend->loadHistory(); const Settings& s = Settings::getInstance(); diff --git a/src/widget/widget.h b/src/widget/widget.h index 083ce1ee7..11847bf2b 100644 --- a/src/widget/widget.h +++ b/src/widget/widget.h @@ -38,6 +38,7 @@ namespace Ui { class MainWindow; } +class ChatForm; class GenericChatroomWidget; class FriendWidget; class Group; @@ -293,6 +294,7 @@ private: int icon_size; QMap friendWidgets; + QMap chatForms; #ifdef Q_OS_MAC QAction* fileMenu;