mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-29 00:37:10 -05:00
fixed some not need things for Chatting which does destroy the Chat format when Chatting, removed lastname and not needed lines which makes chatting bad
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@395 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
7044822e1f
commit
08bdd8f567
@ -118,37 +118,15 @@ void ChatDialog::insertChat()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextEdit *msgWidget = ui.msgText;
|
QTextEdit *msgWidget = ui.msgText;
|
||||||
std::list<ChatInfo>::iterator it;
|
std::list<ChatInfo>::iterator it;
|
||||||
|
|
||||||
static std::string lastChatName("");
|
|
||||||
static int lastChatTime = 0;
|
|
||||||
|
|
||||||
//QString color = ci.messageColor.name();
|
//QString color = ci.messageColor.name();
|
||||||
//QString nickColor;
|
//QString nickColor;
|
||||||
//QString font = ci.messageFont.family();
|
//QString font = ci.messageFont.family();
|
||||||
//QString fontSize = QString::number(ci.messageFont.pointSize());
|
//QString fontSize = QString::number(ci.messageFont.pointSize());
|
||||||
|
|
||||||
|
|
||||||
/* determine how many spaces to add */
|
|
||||||
//int n = msgWidget->width();
|
|
||||||
/* now spaces = (width - txt width) / (pixel / space)
|
|
||||||
*/
|
|
||||||
|
|
||||||
//std::cerr << "Width is : " << n << std::endl;
|
|
||||||
/*n -= 256; 220 pixels for name */
|
|
||||||
/*if (n > 0)
|
|
||||||
{
|
|
||||||
n = 2 + n / 10;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
n = 1;
|
|
||||||
}
|
|
||||||
n = 1 + n / 2;*/ /* shrink it! */
|
|
||||||
|
|
||||||
/* add in lines at the bottom */
|
/* add in lines at the bottom */
|
||||||
int ts = time(NULL);
|
|
||||||
for(it = newchat.begin(); it != newchat.end(); it++)
|
for(it = newchat.begin(); it != newchat.end(); it++)
|
||||||
{
|
{
|
||||||
/* are they private? */
|
/* are they private? */
|
||||||
@ -163,46 +141,20 @@ void ChatDialog::insertChat()
|
|||||||
QString currenttxt = msgWidget->toHtml();
|
QString currenttxt = msgWidget->toHtml();
|
||||||
QString extraTxt;
|
QString extraTxt;
|
||||||
|
|
||||||
if ((it->name == lastChatName) && (ts - lastChatTime < 60))
|
QString timestamp = "[" + QDateTime::currentDateTime().toString("hh:mm:ss") + "]";
|
||||||
{
|
QString name = QString::fromStdString(it->name);
|
||||||
/* no name */
|
QString line = "<span style=\"color:#C00000\"><strong>" + timestamp + "</strong></span>" +
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#if defined(Q_OS_WIN)
|
|
||||||
/* nothing */
|
|
||||||
#else
|
|
||||||
extraTxt += "<br>\n";
|
|
||||||
#endif
|
|
||||||
/*for(int i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
extraTxt += " ";
|
|
||||||
}*/
|
|
||||||
QString timestamp = "[" + QDateTime::currentDateTime().toString("hh:mm:ss") + "]";
|
|
||||||
QString name = QString::fromStdString(it->name);
|
|
||||||
QString line = "<span style=\"color:#C00000\"><strong>" + timestamp + "</strong></span>" +
|
|
||||||
"<span style=\"color:#2D84C9\"><strong>" + " " + name + "</strong></span> <br>";
|
"<span style=\"color:#2D84C9\"><strong>" + " " + name + "</strong></span> <br>";
|
||||||
|
|
||||||
|
extraTxt += line;
|
||||||
|
|
||||||
extraTxt += line;
|
extraTxt += QString::fromStdWString(it->msg);
|
||||||
|
|
||||||
}
|
/* add it everytime */
|
||||||
|
|
||||||
extraTxt += QString::fromStdWString(it->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)
|
|
||||||
extraTxt += "\n";
|
|
||||||
#else
|
|
||||||
extraTxt += "\n";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
lastChatName = it -> name;
|
|
||||||
lastChatTime = ts;
|
|
||||||
|
|
||||||
/* add it everytime */
|
|
||||||
currenttxt += extraTxt;
|
currenttxt += extraTxt;
|
||||||
|
|
||||||
msgWidget->setHtml(currenttxt);
|
msgWidget->setHtml(currenttxt);
|
||||||
|
|
||||||
|
|
||||||
QScrollBar *qsb = msgWidget->verticalScrollBar();
|
QScrollBar *qsb = msgWidget->verticalScrollBar();
|
||||||
qsb -> setValue(qsb->maximum());
|
qsb -> setValue(qsb->maximum());
|
||||||
@ -216,10 +168,10 @@ void ChatDialog::sendMsg()
|
|||||||
{
|
{
|
||||||
QLineEdit *lineWidget = ui.lineEdit;
|
QLineEdit *lineWidget = ui.lineEdit;
|
||||||
|
|
||||||
//QFont font = QFont("Comic Sans MS", 10);
|
QFont font = QFont("Comic Sans MS", 10);
|
||||||
//font.setBold(ui.textboldChatButton->isChecked());
|
font.setBold(ui.textboldChatButton->isChecked());
|
||||||
//font.setUnderline(ui.textunderlineChatButton->isChecked());
|
font.setUnderline(ui.textunderlineChatButton->isChecked());
|
||||||
//font.setItalic(ui.textitalicChatButton->isChecked());
|
font.setItalic(ui.textitalicChatButton->isChecked());
|
||||||
|
|
||||||
ChatInfo ci;
|
ChatInfo ci;
|
||||||
ci.msg = lineWidget->text().toStdWString();
|
ci.msg = lineWidget->text().toStdWString();
|
||||||
|
@ -174,34 +174,13 @@ void PopupChatDialog::updateChat()
|
|||||||
|
|
||||||
void PopupChatDialog::addChatMsg(ChatInfo *ci)
|
void PopupChatDialog::addChatMsg(ChatInfo *ci)
|
||||||
{
|
{
|
||||||
QTextBrowser *msgWidget = ui.textBrowser;
|
QTextBrowser *msgWidget = ui.textBrowser;
|
||||||
|
|
||||||
QString currenttxt = msgWidget->toHtml();
|
QString currenttxt = msgWidget->toHtml();
|
||||||
|
|
||||||
/* determine how many spaces to add */
|
|
||||||
int n = msgWidget->width();
|
|
||||||
/* now spaces = (width - txt width) / (pixel / space)
|
|
||||||
*/
|
|
||||||
|
|
||||||
//std::cerr << "Width is : " << n << std::endl;
|
|
||||||
n -= 256; /* 220 pixels for name */
|
|
||||||
if (n > 0)
|
|
||||||
{
|
|
||||||
n = 2 + n / 10;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
n = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//std::cerr << "Space count : " << n << std::endl;
|
|
||||||
|
|
||||||
std::string spaces(" ");
|
|
||||||
|
|
||||||
|
|
||||||
/* add in lines at the bottom */
|
/* add in lines at the bottom */
|
||||||
QString extraTxt;
|
QString extraTxt;
|
||||||
int ts = time(NULL);
|
|
||||||
|
|
||||||
|
|
||||||
bool offline = true;
|
bool offline = true;
|
||||||
@ -224,46 +203,19 @@ void PopupChatDialog::addChatMsg(ChatInfo *ci)
|
|||||||
|
|
||||||
extraTxt += line;
|
extraTxt += line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((ci->name == lastChatName) && (ts - lastChatTime < 60))
|
|
||||||
{
|
|
||||||
/* no name */
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
|
||||||
// Nothing.
|
|
||||||
#else
|
|
||||||
extraTxt += "<br>\n";
|
|
||||||
#endif
|
|
||||||
for(int i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
extraTxt += " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
QString timestamp = "(" + QDateTime::currentDateTime().toString("hh:mm:ss") + ") ";
|
QString timestamp = "[" + QDateTime::currentDateTime().toString("hh:mm:ss") + "]";
|
||||||
//QString pre = tr("Peer:" );
|
//QString pre = tr("Peer:" );
|
||||||
QString name = QString::fromStdString(ci->name);
|
QString name = QString::fromStdString(ci->name);
|
||||||
QString line = "<span style=\"color:#1D84C9\"><strong>" + timestamp +
|
QString line = "<span style=\"color:#1D84C9\"><strong>" + timestamp +
|
||||||
" " + name + "</strong></span> \n<br>";
|
" " + name + "</strong></span> \n<br>";
|
||||||
|
|
||||||
extraTxt += line;
|
extraTxt += line;
|
||||||
|
|
||||||
}
|
|
||||||
extraTxt += QString::fromStdWString(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)
|
|
||||||
extraTxt += "\n";
|
|
||||||
#else
|
|
||||||
extraTxt += "\n";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
lastChatTime = ts;
|
|
||||||
lastChatName = ci->name;
|
|
||||||
|
|
||||||
currenttxt += extraTxt;
|
currenttxt += extraTxt;
|
||||||
|
|
||||||
msgWidget->setHtml(currenttxt);
|
msgWidget->setHtml(currenttxt);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user