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

refactor: Remove using 'Friend::getChatForm'

This commit is contained in:
Diadlo 2018-02-02 00:18:20 +03:00
parent 61e0dff8a4
commit 254f5cc4b1
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
4 changed files with 12 additions and 11 deletions

View File

@ -116,23 +116,19 @@ void CircleWidget::contextMenuEvent(QContextMenuEvent* event)
ContentDialog* dialog = Widget::getInstance()->createContentDialog();
for (int i = 0; i < friendOnlineLayout()->count(); ++i) {
FriendWidget* friendWidget =
qobject_cast<FriendWidget*>(friendOnlineLayout()->itemAt(i)->widget());
QWidget* const widget = friendOnlineLayout()->itemAt(i)->widget();
FriendWidget* const friendWidget = qobject_cast<FriendWidget*>(widget);
if (friendWidget != nullptr) {
const Friend* const f = friendWidget->getFriend();
ChatForm* const form = f->getChatForm();
dialog->addFriend(f, form);
friendWidget->activate();
}
}
for (int i = 0; i < friendOfflineLayout()->count(); ++i) {
FriendWidget* friendWidget =
qobject_cast<FriendWidget*>(friendOfflineLayout()->itemAt(i)->widget());
QWidget* const widget = friendOfflineLayout()->itemAt(i)->widget();
FriendWidget* const friendWidget = qobject_cast<FriendWidget*>(widget);
if (friendWidget != nullptr) {
const Friend* f = friendWidget->getFriend();
ChatForm* const form = f->getChatForm();
dialog->addFriend(f, form);
friendWidget->activate();
}
}

View File

@ -179,6 +179,11 @@ void GenericChatroomWidget::reloadTheme()
setPalette(p);
}
void GenericChatroomWidget::activate()
{
emit chatroomWidgetClicked(this);
}
void GenericChatroomWidget::mouseReleaseEvent(QMouseEvent* event)
{
if (event->button() == Qt::LeftButton)

View File

@ -63,6 +63,7 @@ public:
void reloadTheme();
public slots:
void activate();
void compactChange(bool compact);
signals:

View File

@ -977,7 +977,6 @@ void Widget::addFriend(uint32_t friendId, const ToxPk& friendPk)
FriendWidget* widget = new FriendWidget(newfriend, compact);
History* history = Nexus::getProfile()->getHistory();
ChatForm* friendForm = new ChatForm(newfriend, history);
newfriend->setChatForm(friendForm);
friendWidgets[friendId] = widget;
chatForms[friendId] = friendForm;