Showing the changes to interface/src/ui/DialogsManager.cpp (1 of 14 files). Show all
Unified · Split
| @@ -162,54 +162,3 @@ void DialogsManager::showScriptEditor() { · 161 unmodified lines | |||
| 162 | maybeCreateDialog(_scriptEditor); | 162 | maybeCreateDialog(_scriptEditor); |
| 163 | _scriptEditor->raise(); | 163 | _scriptEditor->raise(); |
| 164 | } | 164 | } |
| 165 | |||
| 166 | void DialogsManager::setupChat() { | ||
| 167 | #ifdef HAVE_QXMPP | ||
| 168 | const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient(); | ||
| 169 | connect(&xmppClient, &QXmppClient::connected, this, &DialogsManager::toggleChat); | ||
| 170 | connect(&xmppClient, &QXmppClient::disconnected, this, &DialogsManager::toggleChat); | ||
| 171 | |||
| 172 | QDir::setCurrent(PathUtils::resourcesPath()); | ||
| 173 | // init chat window to listen chat | ||
| 174 | maybeCreateDialog(_chatWindow); | ||
| 175 | #endif | ||
| 176 | } | ||
| 177 | |||
| 178 | void DialogsManager::showChat() { | ||
| 179 | if (AccountManager::getInstance().isLoggedIn()) { | ||
| 180 | maybeCreateDialog(_chatWindow); | ||
| 181 | |||
| 182 | if (_chatWindow->isHidden()) { | ||
| 183 | _chatWindow->show(); | ||
| 184 | } | ||
| 185 | _chatWindow->raise(); | ||
| 186 | _chatWindow->activateWindow(); | ||
| 187 | _chatWindow->setFocus(); | ||
| 188 | } else { | ||
| 189 | qApp->getTrayIcon()->showMessage("Interface", | ||
| 190 | "You need to login to be able to chat with others on this domain."); | ||
| 191 | } | ||
| 192 | } | ||
| 193 | |||
| 194 | void DialogsManager::toggleChat() { | ||
| 195 | #ifdef HAVE_QXMPP | ||
| 196 | QAction* chatAction = Menu::getInstance()->getActionForOption(MenuOption::Login); | ||
| 197 | Q_CHECK_PTR(chatAction); | ||
| 198 | |||
| 199 | chatAction->setEnabled(XmppClient::getInstance().getXMPPClient().isConnected()); | ||
| 200 | if (!chatAction->isEnabled() && _chatWindow && AccountManager::getInstance().isLoggedIn()) { | ||
| 201 | if (_chatWindow->isHidden()) { | ||
| 202 | _chatWindow->show(); | ||
| 203 | _chatWindow->raise(); | ||
| 204 | _chatWindow->activateWindow(); | ||
| 205 | _chatWindow->setFocus(); | ||
| 206 | } else { | ||
| 207 | _chatWindow->hide(); | ||
| 208 | } | ||
| 209 | } | ||
| 210 | #endif | ||
| 211 | } | ||
| 212 | |||
| 213 | |||
| 214 | |||
| 215 | |||