Commit 1a2230d3 authored by Rafał Malinowski's avatar Rafał Malinowski

gui: added OpenChatActivation parameter to ChatWidgetManager::openChat

Signed-off-by: Rafał Malinowski's avatarRafał Malinowski <rafal.przemyslaw.malinowski@gmail.com>
parent c66608b1
......@@ -58,7 +58,7 @@ void RecentChatsAction::actionInstanceCreated(Action *action)
void RecentChatsAction::openRecentChats(QAction *action)
{
ChatWidgetManager::instance()->openChat(action->data().value<Chat>());
ChatWidgetManager::instance()->openChat(action->data().value<Chat>(), OpenChatActivation::Activate);
}
#include "moc_recent-chats-action.cpp"
......@@ -487,7 +487,7 @@ void ChatWidgetActions::openChatActionActivated(QAction *sender, bool toggled)
if (!action)
return;
ChatWidgetManager::instance()->openChat(action->context()->chat());
ChatWidgetManager::instance()->openChat(action->context()->chat(), OpenChatActivation::Activate);
kdebugf2();
}
......
......@@ -130,13 +130,14 @@ void ChatWidgetManager::chatWidgetCreated(ChatWidget *chatWidget)
}
}
void ChatWidgetManager::openChat(const Chat &chat)
void ChatWidgetManager::openChat(const Chat &chat, OpenChatActivation activation)
{
if (!m_chatWidgetRepository)
return;
auto chatWidget = m_chatWidgetRepository.data()->widgetForChat(chat);
chatWidget->tryActivate();
if (activation == OpenChatActivation::Activate)
chatWidget->tryActivate();
}
void ChatWidgetManager::closeChat(const Chat &chat)
......
......@@ -35,6 +35,12 @@ class ChatWidgetRepository;
class ChatWindowStorage;
class ChatWindowRepository;
enum class OpenChatActivation
{
DoNotActivate,
Activate
};
/**
* @addtogroup Gui
* @{
......@@ -83,7 +89,7 @@ public:
ChatWidget * byChat(const Chat &chat, const bool create);
public slots:
void openChat(const Chat &chat);
void openChat(const Chat &chat, OpenChatActivation activation);
/**
* @short Close ChatWidget for given chat.
......
......@@ -276,7 +276,7 @@ void AddConferenceWindow::start()
if (!DisplayNameEdit->text().isEmpty())
chat.setDisplay(DisplayNameEdit->text());
ChatWidgetManager::instance()->openChat(computeChat());
ChatWidgetManager::instance()->openChat(computeChat(), OpenChatActivation::Activate);
QDialog::accept();
}
......
......@@ -227,7 +227,7 @@ void AddRoomChatWindow::start()
if (!DisplayNameEdit->text().isEmpty())
chat.setDisplay(DisplayNameEdit->text());
ChatWidgetManager::instance()->openChat(computeChat());
ChatWidgetManager::instance()->openChat(computeChat(), OpenChatActivation::Activate);
ChatDetailsRoom *details = qobject_cast<ChatDetailsRoom *>(chat.details());
Q_ASSERT(details);
......
......@@ -296,7 +296,7 @@ void KaduWindow::talkableActivatedSlot(const Talkable &talkable)
const Chat &chat = talkable.toChat();
if (chat && !chat.contacts().toBuddySet().contains(Core::instance()->myself()))
{
ChatWidgetManager::instance()->openChat(chat);
ChatWidgetManager::instance()->openChat(chat, OpenChatActivation::Activate);
return;
}
......
......@@ -224,7 +224,7 @@ void OpenChatWith::itemActivated(int index)
if (!chat)
return;
ChatWidgetManager::instance()->openChat(chat);
ChatWidgetManager::instance()->openChat(chat, OpenChatActivation::Activate);
deleteLater();
}
......
......@@ -337,7 +337,7 @@ void SearchWindow::chatFound()
const Chat &chat = 1 == contacts.size()
? ChatTypeContact::findChat(*contacts.constBegin(), ActionCreateAndAdd)
: ChatTypeContactSet::findChat(contacts, ActionCreateAndAdd);
ChatWidgetManager::instance()->openChat(chat);
ChatWidgetManager::instance()->openChat(chat, OpenChatActivation::Activate);
}
}
......
......@@ -38,7 +38,7 @@ void ChatNotification::openChat()
{
close();
ChatWidgetManager::instance()->openChat(chat());
ChatWidgetManager::instance()->openChat(chat(), OpenChatActivation::Activate);
}
void ChatNotification::callbackAccept()
......
......@@ -399,7 +399,7 @@ void DockingManager::hideKaduWindow()
void DockingManager::openUnreadMessages()
{
const Message &message = Core::instance()->unreadMessageRepository()->unreadMessage();
ChatWidgetManager::instance()->openChat(message.messageChat());
ChatWidgetManager::instance()->openChat(message.messageChat(), OpenChatActivation::Activate);
}
void DockingManager::trayMousePressEvent(QMouseEvent * e)
......
......@@ -71,7 +71,7 @@ void GaduUrlHandler::openUrl(const QByteArray &url, bool disableMenu)
const Chat &chat = ChatTypeContact::findChat(contact, ActionCreateAndAdd);
if (chat)
{
ChatWidgetManager::instance()->openChat(chat);
ChatWidgetManager::instance()->openChat(chat, OpenChatActivation::Activate);
return;
}
}
......@@ -108,7 +108,7 @@ void GaduUrlHandler::accountSelected(QAction *action)
const Contact &contact = ContactManager::instance()->byId(account, ids[1], ActionCreateAndAdd);
const Chat &chat = ChatTypeContact::findChat(contact, ActionCreateAndAdd);
ChatWidgetManager::instance()->openChat(chat);
ChatWidgetManager::instance()->openChat(chat, OpenChatActivation::Activate);
}
#include "moc_gadu-url-handler.cpp"
......@@ -375,7 +375,7 @@ void HintManager::openChat(Hint *hint)
if ((hint->getNotification()->type() != "NewChat") && (hint->getNotification()->type() != "NewMessage"))
return;
ChatWidgetManager::instance()->openChat(hint->chat());
ChatWidgetManager::instance()->openChat(hint->chat(), OpenChatActivation::Activate);
deleteHintAndUpdate(hint);
......
......@@ -90,7 +90,7 @@ void JabberUrlHandler::openUrl(const QByteArray &url, bool disableMenu)
const Chat &chat = ChatTypeContact::findChat(contact, ActionCreateAndAdd);
if (chat)
{
ChatWidgetManager::instance()->openChat(chat);
ChatWidgetManager::instance()->openChat(chat, OpenChatActivation::Activate);
return;
}
}
......@@ -127,7 +127,7 @@ void JabberUrlHandler::accountSelected(QAction *action)
const Contact &contact = ContactManager::instance()->byId(account, ids[1], ActionCreateAndAdd);
const Chat &chat = ChatTypeContact::findChat(contact, ActionCreateAndAdd);
ChatWidgetManager::instance()->openChat(chat);
ChatWidgetManager::instance()->openChat(chat, OpenChatActivation::Activate);
}
#include "moc_jabber-url-handler.cpp"
......@@ -133,7 +133,7 @@ void Qt4Notify::notify(Notification *notification)
void Qt4Notify::messageClicked()
{
ChatWidgetManager::instance()->openChat(chat);
ChatWidgetManager::instance()->openChat(chat, OpenChatActivation::Activate);
}
NotifierConfigurationWidget *Qt4Notify::createConfigurationWidget(QWidget *parent)
......
......@@ -461,7 +461,7 @@ void TabWidget::openTabsList()
void TabWidget::openRecentChat(QAction *action)
{
ChatWidgetManager::instance()->openChat(action->data().value<Chat>());
ChatWidgetManager::instance()->openChat(action->data().value<Chat>(), OpenChatActivation::Activate);
}
void TabWidget::deleteTab()
......
......@@ -581,7 +581,7 @@ bool TabsManager::detachChat(ChatWidget *chatWidget)
// omg this is bad
chat.addProperty("tabs:detached", true, CustomProperties::Storable);
ChatWidgetManager::instance()->openChat(chat);
ChatWidgetManager::instance()->openChat(chat, OpenChatActivation::Activate);
return true;
}
......@@ -782,7 +782,7 @@ void TabsManager::reopenClosedChat()
if (ClosedChats.isEmpty())
return;
ChatWidgetManager::instance()->openChat(ClosedChats.takeFirst());
ChatWidgetManager::instance()->openChat(ClosedChats.takeFirst(), OpenChatActivation::Activate);
ReopenClosedTabMenuAction->setEnabled(ClosedChats.isEmpty());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment