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

refactor: Remove ContentDialog::openNewDialog

It duplicates logic on Widget::openNewDialog
This commit is contained in:
Diadlo 2018-12-24 21:36:05 +03:00
parent e1d912bbeb
commit a446d9b197
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
3 changed files with 2 additions and 25 deletions

View File

@ -175,7 +175,6 @@ FriendWidget* ContentDialog::addFriend(std::shared_ptr<FriendChatroom> chatroom,
// TODO(sudden6): move this connection to the Friend::displayedNameChanged signal
connect(frnd, &Friend::aliasChanged, this, &ContentDialog::updateFriendWidget);
connect(friendWidget, &FriendWidget::chatroomWidgetClicked, this, &ContentDialog::activate);
connect(friendWidget, &FriendWidget::newWindowOpened, this, &ContentDialog::openNewDialog);
ContentDialog* lastDialog = getFriendDialog(friendId);
if (lastDialog) {
@ -199,7 +198,6 @@ GroupWidget* ContentDialog::addGroup(std::shared_ptr<GroupChatroom> chatroom, Ge
groupChatForms[groupId] = form;
connect(groupWidget, &GroupWidget::chatroomWidgetClicked, this, &ContentDialog::activate);
connect(groupWidget, &FriendWidget::newWindowOpened, this, &ContentDialog::openNewDialog);
ContentDialog* lastDialog = getGroupDialog(groupId);
@ -686,27 +684,6 @@ void ContentDialog::keyPressEvent(QKeyEvent* event)
}
}
/**
* @brief Open a new dialog window associated with widget
* @param widget Widget associated with contact.
*/
void ContentDialog::openNewDialog(GenericChatroomWidget* widget)
{
ContentDialog* contentDialog = new ContentDialog();
contentDialog->show();
if (widget->getFriend()) {
removeFriend(widget->getFriend()->getId());
Widget::getInstance()->addFriendDialog(widget->getFriend(), contentDialog);
} else {
removeGroup(widget->getGroup()->getId());
Widget::getInstance()->addGroupDialog(widget->getGroup(), contentDialog);
}
contentDialog->raise();
contentDialog->activateWindow();
}
/**
* @brief Show ContentDialog, activate chatroom widget.
* @param widget Widget which should be activated.

View File

@ -102,8 +102,6 @@ protected:
void keyPressEvent(QKeyEvent* event) override;
private slots:
void activate(GenericChatroomWidget* widget);
void openNewDialog(GenericChatroomWidget* widget);
void updateFriendWidget(uint32_t friendId, QString alias);
void onGroupchatPositionChanged(bool top);

View File

@ -1261,6 +1261,7 @@ void Widget::addFriendDialog(const Friend* frnd, ContentDialog* dialog)
[=]() { dialog->removeFriend(friendId); });
connect(friendWidget, &FriendWidget::copyFriendIdToClipboard, this,
&Widget::copyFriendIdToClipboard);
connect(friendWidget, &FriendWidget::newWindowOpened, this, &Widget::openNewDialog);
// Signal transmission from the created `friendWidget` (which shown in
// ContentDialog) to the `widget` (which shown in main widget)
@ -1313,6 +1314,7 @@ void Widget::addGroupDialog(Group* group, ContentDialog* dialog)
connect(groupWidget, &GroupWidget::middleMouseClicked, dialog,
[=]() { dialog->removeGroup(groupId); });
connect(groupWidget, &GroupWidget::chatroomWidgetClicked, chatForm, &ChatForm::focusInput);
connect(groupWidget, &GroupWidget::newWindowOpened, this, &Widget::openNewDialog);
// Signal transmission from the created `groupWidget` (which shown in
// ContentDialog) to the `widget` (which shown in main widget)