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:
parent
61e0dff8a4
commit
254f5cc4b1
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
void reloadTheme();
|
||||
|
||||
public slots:
|
||||
void activate();
|
||||
void compactChange(bool compact);
|
||||
|
||||
signals:
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user