Informed users who want to chat they have to log in first.

This commit is contained in:
Dimitar Dobrev 2014-04-03 19:45:46 +03:00
parent 4a1687c023
commit 716858e6f6
3 changed files with 25 additions and 22 deletions

View file

@ -44,32 +44,37 @@
<source> online now:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/ui/ChatWindow.cpp" line="47"/>
<source>You must be logged in to chat with others.</source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<location filename="src/ui/ChatWindow.cpp" line="135"/>
<location filename="src/ui/ChatWindow.cpp" line="139"/>
<source>day</source>
<translation type="unfinished">
<numerusform></numerusform>
<numerusform></numerusform>
<numerusform>%n day</numerusform>
<numerusform>%n days</numerusform>
</translation>
</message>
<message numerus="yes">
<location filename="src/ui/ChatWindow.cpp" line="135"/>
<location filename="src/ui/ChatWindow.cpp" line="139"/>
<source>hour</source>
<translation type="unfinished">
<numerusform></numerusform>
<numerusform></numerusform>
<numerusform>%n hour</numerusform>
<numerusform>%n hours</numerusform>
</translation>
</message>
<message numerus="yes">
<location filename="src/ui/ChatWindow.cpp" line="135"/>
<location filename="src/ui/ChatWindow.cpp" line="139"/>
<source>minute</source>
<translation type="unfinished">
<numerusform></numerusform>
<numerusform></numerusform>
<numerusform>%n minute</numerusform>
<numerusform>%n minutes</numerusform>
</translation>
</message>
<message>
<location filename="src/ui/ChatWindow.cpp" line="191"/>
<location filename="src/ui/ChatWindow.cpp" line="195"/>
<source>%1 online now:</source>
<translation type="unfinished"></translation>
</message>
@ -106,18 +111,18 @@
<context>
<name>Menu</name>
<message>
<location filename="src/Menu.cpp" line="462"/>
<location filename="src/Menu.cpp" line="461"/>
<source>Open .ini config file</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/Menu.cpp" line="464"/>
<location filename="src/Menu.cpp" line="476"/>
<location filename="src/Menu.cpp" line="463"/>
<location filename="src/Menu.cpp" line="475"/>
<source>Text files (*.ini)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/Menu.cpp" line="474"/>
<location filename="src/Menu.cpp" line="473"/>
<source>Save .ini config file</source>
<translation type="unfinished"></translation>
</message>

View file

@ -180,18 +180,17 @@ Menu::Menu() :
QMenu* toolsMenu = addMenu("Tools");
addActionToQMenuAndActionHash(toolsMenu, MenuOption::MetavoxelEditor, 0, this, SLOT(showMetavoxelEditor()));
#ifdef HAVE_QXMPP
_chatAction = addActionToQMenuAndActionHash(toolsMenu,
MenuOption::Chat,
Qt::Key_Return,
this,
SLOT(showChat()));
#ifdef HAVE_QXMPP
const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient();
toggleChat();
connect(&xmppClient, SIGNAL(connected()), this, SLOT(toggleChat()));
connect(&xmppClient, SIGNAL(disconnected()), this, SLOT(toggleChat()));
#else
_chatAction->setEnabled(false);
#endif
QMenu* viewMenu = addMenu("View");
@ -1155,11 +1154,6 @@ void Menu::showMetavoxelEditor() {
}
void Menu::showChat() {
if (!_chatAction->isEnabled()) {
// Don't do anything if chat is disabled (No
// QXMPP library or xmpp is disconnected).
return;
}
QMainWindow* mainWindow = Application::getInstance()->getWindow();
if (!_chatWindow) {
mainWindow->addDockWidget(Qt::NoDockWidgetArea, _chatWindow = new ChatWindow());

View file

@ -42,6 +42,10 @@ ChatWindow::ChatWindow() :
ui->messagesGridLayout->setColumnStretch(1, 3);
ui->messagePlainTextEdit->installEventFilter(this);
if (!AccountManager::getInstance().isLoggedIn()) {
ui->connectingToXMPPLabel->setText(tr("You must be logged in to chat with others."));
}
#ifdef HAVE_QXMPP
const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient();