TabMessage::TabMessage(TabSupervisor *_tabSupervisor, AbstractClient *_client, const ServerInfo_User &_ownUserInfo, const ServerInfo_User &_otherUserInfo) : Tab(_tabSupervisor), client(_client), ownUserInfo(new ServerInfo_User(_ownUserInfo)), otherUserInfo(new ServerInfo_User(_otherUserInfo)), userOnline(true) { chatView = new ChatView(tabSupervisor, 0, true); connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString))); connect(chatView, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString))); connect(chatView, SIGNAL(addMentionTag(QString)), this, SLOT(addMentionTag(QString))); sayEdit = new QLineEdit; connect(sayEdit, SIGNAL(returnPressed()), this, SLOT(sendMessage())); QVBoxLayout *vbox = new QVBoxLayout; vbox->addWidget(chatView); vbox->addWidget(sayEdit); aLeave = new QAction(this); connect(aLeave, SIGNAL(triggered()), this, SLOT(actLeave())); messageMenu = new QMenu(this); messageMenu->addAction(aLeave); addTabMenu(messageMenu); retranslateUi(); QWidget * mainWidget = new QWidget(this); mainWidget->setLayout(vbox); setCentralWidget(mainWidget); }
void ChatView::mousePressEvent(QMouseEvent *event) { switch (hoveredItemType) { case HoveredCard: { if ((event->button() == Qt::MidButton) || (event->button() == Qt::LeftButton)) emit showCardInfoPopup(event->globalPos(), hoveredContent); break; } case HoveredUser: { if (event->button() != Qt::MidButton) { const int delimiterIndex = hoveredContent.indexOf("_"); const QString userName = hoveredContent.mid(delimiterIndex + 1); switch(event->button()) { case Qt::RightButton :{ UserLevelFlags userLevel(hoveredContent.left(delimiterIndex).toInt()); userContextMenu->showContextMenu(event->globalPos(), userName, userLevel); break; } case Qt::LeftButton :{ if (event->modifiers() == Qt::ControlModifier) { emit openMessageDialog(userName, true); } else emit addMentionTag("@" + userName); break; } default: break; } } break; } default: { QTextBrowser::mousePressEvent(event); } } }
TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerInfo_User *_ownUser, const ServerInfo_Room &info) : Tab(_tabSupervisor), client(_client), roomId(info.room_id()), roomName(QString::fromStdString(info.name())), ownUser(_ownUser) { const int gameTypeListSize = info.gametype_list_size(); for (int i = 0; i < gameTypeListSize; ++i) gameTypes.insert(info.gametype_list(i).game_type_id(), QString::fromStdString(info.gametype_list(i).description())); QMap<int, GameTypeMap> tempMap; tempMap.insert(info.room_id(), gameTypes); gameSelector = new GameSelector(client, tabSupervisor, this, QMap<int, QString>(), tempMap, true, true); userList = new UserList(tabSupervisor, client, UserList::RoomList); connect(userList, SIGNAL(openMessageDialog(const QString &, bool)), this, SIGNAL(openMessageDialog(const QString &, bool))); chatView = new ChatView(tabSupervisor, 0, true); connect(chatView, SIGNAL(showMentionPopup(QString&)), this, SLOT(actShowMentionPopup(QString&))); connect(chatView, SIGNAL(messageClickedSignal()), this, SLOT(focusTab())); connect(chatView, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool))); connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString))); connect(chatView, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString))); connect(chatView, SIGNAL(addMentionTag(QString)), this, SLOT(addMentionTag(QString))); connect(settingsCache, SIGNAL(chatMentionCompleterChanged()), this, SLOT(actCompleterChanged())); sayLabel = new QLabel; sayEdit = new LineEditCompleter; sayLabel->setBuddy(sayEdit); connect(sayEdit, SIGNAL(returnPressed()), this, SLOT(sendMessage())); QMenu *chatSettingsMenu = new QMenu(this); aClearChat = chatSettingsMenu->addAction(QString()); connect(aClearChat, SIGNAL(triggered()), this, SLOT(actClearChat())); chatSettingsMenu->addSeparator(); aOpenChatSettings = chatSettingsMenu->addAction(QString()); connect(aOpenChatSettings, SIGNAL(triggered()), this, SLOT(actOpenChatSettings())); QToolButton *chatSettingsButton = new QToolButton; chatSettingsButton->setIcon(QPixmap("theme:icons/settings")); chatSettingsButton->setMenu(chatSettingsMenu); chatSettingsButton->setPopupMode(QToolButton::InstantPopup); QHBoxLayout *sayHbox = new QHBoxLayout; sayHbox->addWidget(sayLabel); sayHbox->addWidget(sayEdit); sayHbox->addWidget(chatSettingsButton); QVBoxLayout *chatVbox = new QVBoxLayout; chatVbox->addWidget(chatView); chatVbox->addLayout(sayHbox); chatGroupBox = new QGroupBox; chatGroupBox->setLayout(chatVbox); QSplitter *splitter = new QSplitter(Qt::Vertical); splitter->addWidget(gameSelector); splitter->addWidget(chatGroupBox); QHBoxLayout *hbox = new QHBoxLayout; hbox->addWidget(splitter, 3); hbox->addWidget(userList, 1); aLeaveRoom = new QAction(this); connect(aLeaveRoom, SIGNAL(triggered()), this, SLOT(actLeaveRoom())); roomMenu = new QMenu(this); roomMenu->addAction(aLeaveRoom); addTabMenu(roomMenu); const int userListSize = info.user_list_size(); for (int i = 0; i < userListSize; ++i){ userList->processUserInfo(info.user_list(i), true); autocompleteUserList.append("@" + QString::fromStdString(info.user_list(i).name())); } userList->sortItems(); const int gameListSize = info.game_list_size(); for (int i = 0; i < gameListSize; ++i) gameSelector->processGameInfo(info.game_list(i)); completer = new QCompleter(autocompleteUserList, sayEdit); completer->setCaseSensitivity(Qt::CaseInsensitive); completer->setMaxVisibleItems(5); #if QT_VERSION >= 0x050000 completer->setFilterMode(Qt::MatchStartsWith); #endif sayEdit->setCompleter(completer); actCompleterChanged(); connect(&settingsCache->shortcuts(), SIGNAL(shortCutchanged()),this,SLOT(refreshShortcuts())); refreshShortcuts(); retranslateUi(); QWidget * mainWidget = new QWidget(this); mainWidget->setLayout(hbox); setCentralWidget(mainWidget); }
TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerInfo_User *_ownUser, const ServerInfo_Room &info) : Tab(_tabSupervisor), client(_client), roomId(info.room_id()), roomName(QString::fromStdString(info.name())), ownUser(_ownUser) { const int gameTypeListSize = info.gametype_list_size(); for (int i = 0; i < gameTypeListSize; ++i) gameTypes.insert(info.gametype_list(i).game_type_id(), QString::fromStdString(info.gametype_list(i).description())); QMap<int, GameTypeMap> tempMap; tempMap.insert(info.room_id(), gameTypes); gameSelector = new GameSelector(client, tabSupervisor, this, QMap<int, QString>(), tempMap, true, true); userList = new UserList(tabSupervisor, client, UserList::RoomList); connect(userList, SIGNAL(openMessageDialog(const QString &, bool)), this, SIGNAL(openMessageDialog(const QString &, bool))); chatView = new ChatView(tabSupervisor, 0, true); connect(chatView, SIGNAL(showMentionPopup(QString&)), this, SLOT(actShowMentionPopup(QString&))); connect(chatView, SIGNAL(messageClickedSignal()), this, SLOT(focusTab())); connect(chatView, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool))); connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString))); connect(chatView, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString))); connect(chatView, SIGNAL(addMentionTag(QString)), this, SLOT(addMentionTag(QString))); sayLabel = new QLabel; sayEdit = new QLineEdit; sayLabel->setBuddy(sayEdit); connect(sayEdit, SIGNAL(returnPressed()), this, SLOT(sendMessage())); QMenu *chatSettingsMenu = new QMenu(this); aClearChat = chatSettingsMenu->addAction(QString()); aClearChat->setShortcut(QKeySequence("F12")); connect(aClearChat, SIGNAL(triggered()), this, SLOT(actClearChat())); chatSettingsMenu->addSeparator(); aOpenChatSettings = chatSettingsMenu->addAction(QString()); connect(aOpenChatSettings, SIGNAL(triggered()), this, SLOT(actOpenChatSettings())); QToolButton *chatSettingsButton = new QToolButton; chatSettingsButton->setIcon(QIcon(":/resources/icon_settings.svg")); chatSettingsButton->setMenu(chatSettingsMenu); chatSettingsButton->setPopupMode(QToolButton::InstantPopup); QHBoxLayout *sayHbox = new QHBoxLayout; sayHbox->addWidget(sayLabel); sayHbox->addWidget(sayEdit); sayHbox->addWidget(chatSettingsButton); QVBoxLayout *chatVbox = new QVBoxLayout; chatVbox->addWidget(chatView); chatVbox->addLayout(sayHbox); chatGroupBox = new QGroupBox; chatGroupBox->setLayout(chatVbox); QSplitter *splitter = new QSplitter(Qt::Vertical); splitter->addWidget(gameSelector); splitter->addWidget(chatGroupBox); QHBoxLayout *hbox = new QHBoxLayout; hbox->addWidget(splitter, 3); hbox->addWidget(userList, 1); aLeaveRoom = new QAction(this); connect(aLeaveRoom, SIGNAL(triggered()), this, SLOT(actLeaveRoom())); roomMenu = new QMenu(this); roomMenu->addAction(aLeaveRoom); addTabMenu(roomMenu); retranslateUi(); setLayout(hbox); const int userListSize = info.user_list_size(); for (int i = 0; i < userListSize; ++i) userList->processUserInfo(info.user_list(i), true); userList->sortItems(); const int gameListSize = info.game_list_size(); for (int i = 0; i < gameListSize; ++i) gameSelector->processGameInfo(info.game_list(i)); }