diff --git a/src/widget/contentdialog.cpp b/src/widget/contentdialog.cpp index 92cd91f11..1934e2426 100644 --- a/src/widget/contentdialog.cpp +++ b/src/widget/contentdialog.cpp @@ -181,7 +181,8 @@ FriendWidget* ContentDialog::addFriend(int friendId, QString id) lastDialog->removeFriend(friendId); friendList.insert(friendId, std::make_tuple(this, friendWidget)); - onChatroomWidgetClicked(friendWidget, false); + // FIXME: emit should be removed + emit friendWidget->chatroomWidgetClicked(friendWidget, false); return friendWidget; } @@ -202,7 +203,8 @@ GroupWidget* ContentDialog::addGroup(int groupId, const QString& name) lastDialog->removeGroup(groupId); groupList.insert(groupId, std::make_tuple(this, groupWidget)); - onChatroomWidgetClicked(groupWidget, false); + // FIXME: emit should be removed + emit groupWidget->chatroomWidgetClicked(groupWidget, false); return groupWidget; } @@ -357,7 +359,10 @@ void ContentDialog::cycleContacts(bool forward, bool loop) GenericChatroomWidget* chatWidget = qobject_cast(currentLayout->itemAt(index)->widget()); if (chatWidget != nullptr && chatWidget != activeChatroomWidget) - onChatroomWidgetClicked(chatWidget, false); + { + // FIXME: emit should be removed + emit chatWidget->chatroomWidgetClicked(chatWidget, false); + } return; } @@ -675,11 +680,6 @@ void ContentDialog::onChatroomWidgetClicked(GenericChatroomWidget *widget, bool widget->resetEventFlags(); widget->updateStatusLight(); updateTitle(widget); - - if (widget->getFriend()) - widget->getFriend()->getFriendWidget()->updateStatusLight(); - else - widget->getGroup()->getGroupWidget()->updateStatusLight(); } void ContentDialog::updateFriendWidget(FriendWidget *w, Status s) diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index aa21da6d2..50c432225 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -1271,6 +1271,18 @@ void Widget::addFriendDialog(Friend *frnd, ContentDialog *dialog) connect(friendWidget, &FriendWidget::copyFriendIdToClipboard, this, &Widget::copyFriendIdToClipboard); + // Signal transmission from the created `friendWidget` (which shown in + // ContentDialog) to the `widget` (which shown in main widget) + // FIXME: emit should be removed + connect(friendWidget, &FriendWidget::chatroomWidgetClicked, + this, [=](GenericChatroomWidget *w, bool group) + { + Q_UNUSED(w); + emit widget->chatroomWidgetClicked(widget, group); + }); + // FIXME: emit should be removed + emit widget->chatroomWidgetClicked(widget, false); + Core* core = Core::getInstance(); connect(core, &Core::friendAvatarChanged, friendWidget, &FriendWidget::onAvatarChange); @@ -1301,6 +1313,19 @@ void Widget::addGroupDialog(Group *group, ContentDialog *dialog) this, SLOT(removeGroup(int))); connect(groupWidget, &GroupWidget::chatroomWidgetClicked, group->getChatForm(), &ChatForm::focusInput); + + // Signal transmission from the created `groupWidget` (which shown in + // ContentDialog) to the `widget` (which shown in main widget) + // FIXME: emit should be removed + connect(groupWidget, &GroupWidget::chatroomWidgetClicked, + this, [=](GenericChatroomWidget *w, bool group) + { + Q_UNUSED(w); + emit widget->chatroomWidgetClicked(widget, group); + }); + + // FIXME: emit should be removed + emit widget->chatroomWidgetClicked(widget, false); } bool Widget::newFriendMessageAlert(int friendId, bool sound)