changes to support i8n in the gui (chat and messages)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@318 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2008-01-26 13:08:28 +00:00
parent bfb0b2be2b
commit f9d6f1c418
9 changed files with 734 additions and 397 deletions

View file

@ -200,7 +200,7 @@ void PopupChatDialog::addChatMsg(ChatInfo *ci)
/* add in lines at the bottom */
std::ostringstream out;
QString extraTxt;
int ts = time(NULL);
@ -222,70 +222,65 @@ void PopupChatDialog::addChatMsg(ChatInfo *ci)
{
QString line = "<br>\n<span style=\"color:#1D84C9\"><strong> ----- PEER OFFLINE (Chat will be lost) -----</strong></span> \n<br>";
out << line.toStdString();
extraTxt += line;
}
if ((ci->name == lastChatName) && (ts - lastChatTime < 60))
{
/* no name */
}
else
{
if ((ci->name == lastChatName) && (ts - lastChatTime < 60))
{
/* no name */
}
else
{
#if defined(Q_OS_WIN)
// Nothing.
#else
out << "<br>" << std::endl;
extraTxt += "<br>\n";
#endif
for(int i = 0; i < n; i++)
{
out << spaces;
}
for(int i = 0; i < n; i++)
{
extraTxt += " ";
}
//out << "[ " << ci->name << " +" << ts - lastChatTime << "s ]" << std::endl;
//out << "<br>" << std::endl;
QString timestamp = "(" + QDateTime::currentDateTime().toString("hh:mm:ss") + ") ";
//QString pre = tr("Peer:" );
QString name = QString::fromStdString(ci->name);
QString line = "<span style=\"color:#1D84C9\"><strong>" + timestamp +
" " + name + "</strong></span> \n<br>";
out << line.toStdString();
extraTxt += line;
}
out << ci -> msg;
}
extraTxt += QString::fromStdWString(ci -> msg);
/* This might be WIN32 only - or maybe Qt4.2.2 only - but need it for windows at the mom */
#if defined(Q_OS_WIN)
//out << "<br>"; // << std::endl;
out << std::endl;
extraTxt += "\n";
#else
out << std::endl;
extraTxt += "\n";
#endif
lastChatTime = ts;
lastChatName = ci->name;
QString extra = QString::fromStdString(out.str());
currenttxt += extra;
msgWidget->setHtml(currenttxt);
// std::cerr << " Added Text: " << std::endl;
// std::cerr << out.str() << std::endl;
QScrollBar *qsb = msgWidget->verticalScrollBar();
qsb -> setValue(qsb->maximum());
}
void PopupChatDialog::sendChat()
{
QLineEdit *lineWidget = ui.lineEdit;
ChatInfo ci;
lastChatTime = ts;
lastChatName = ci->name;
currenttxt += extraTxt;
msgWidget->setHtml(currenttxt);
// std::cerr << " Added Text: " << std::endl;
// std::cerr << out.str() << std::endl;
QScrollBar *qsb = msgWidget->verticalScrollBar();
qsb -> setValue(qsb->maximum());
}
void PopupChatDialog::sendChat()
{
QLineEdit *lineWidget = ui.lineEdit;
ChatInfo ci;
{
rsiface->lockData(); /* Lock Interface */
const RsConfig &conf = rsiface->getConfig();
@ -296,7 +291,7 @@ void PopupChatDialog::sendChat()
rsiface->unlockData(); /* Unlock Interface */
}
ci.msg = lineWidget->text().toStdString();
ci.msg = lineWidget->text().toStdWString();
ci.chatflags = RS_CHAT_PRIVATE;
addChatMsg(&ci);