/** * @brief Focus the dialog if it exists. * @param id User Id. * @param list List with dialogs * @return ContentDialog if found, nullptr otherwise */ ContentDialog* ContentDialogManager::focusDialog(const ContactId& id, const QHash<const ContactId&, ContentDialog*>& list) { auto iter = list.find(id); if (iter == list.end()) { return nullptr; } ContentDialog* dialog = *iter; if (dialog->windowState() & Qt::WindowMinimized) { dialog->showNormal(); } dialog->raise(); dialog->activateWindow(); return dialog; }
void ContentDialog::onChatroomWidgetClicked(GenericChatroomWidget *widget, bool group) { if (group) { ContentDialog* contentDialog = new ContentDialog(settingsWidget); contentDialog->show(); if (widget->getFriend() != nullptr) { removeFriend(widget->getFriend()->getFriendID()); Widget::getInstance()->addFriendDialog(widget->getFriend(), contentDialog); } else { removeGroup(widget->getGroup()->getGroupId()); Widget::getInstance()->addGroupDialog(widget->getGroup(), contentDialog); } contentDialog->raise(); contentDialog->activateWindow(); return; } // If we clicked on the currently active widget, don't reload and relayout everything if (activeChatroomWidget == widget) return; contentLayout->clear(); if (activeChatroomWidget != nullptr) activeChatroomWidget->setAsInactiveChatroom(); activeChatroomWidget = widget; widget->setChatForm(contentLayout); widget->setAsActiveChatroom(); widget->resetEventFlags(); widget->updateStatusLight(); updateTitle(widget); if (widget->getFriend()) widget->getFriend()->getFriendWidget()->updateStatusLight(); else widget->getGroup()->getGroupWidget()->updateStatusLight(); }