mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-26 23:36:59 -05:00
enable new popupchat style. Default style will be provided if no style file exist.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@555 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
9cd24b315f
commit
807472f427
@ -157,11 +157,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 message = msgWidget->toHtml();
|
||||||
|
|
||||||
|
|
||||||
/* add in lines at the bottom */
|
/* add in lines at the bottom */
|
||||||
QString extraTxt;
|
//QString extraTxt;
|
||||||
|
|
||||||
bool offline = true;
|
bool offline = true;
|
||||||
|
|
||||||
@ -181,30 +183,26 @@ void PopupChatDialog::addChatMsg(ChatInfo *ci)
|
|||||||
{
|
{
|
||||||
QString line = "<br>\n<span style=\"color:#1D84C9\"><strong> ----- PEER OFFLINE (Chat will be lost) -----</strong></span> \n<br>";
|
QString line = "<br>\n<span style=\"color:#1D84C9\"><strong> ----- PEER OFFLINE (Chat will be lost) -----</strong></span> \n<br>";
|
||||||
|
|
||||||
extraTxt += line;
|
//extraTxt += line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString timestamp = "[" + QDateTime::currentDateTime().toString("hh:mm:ss") + "]";
|
QString timestamp = "[" + QDateTime::currentDateTime().toString("hh:mm:ss") + "]";
|
||||||
QString name = QString::fromStdString(ci ->name);
|
QString name = QString::fromStdString(ci ->name);
|
||||||
QString line = "<span style=\"color:#C00000\"><strong>" + timestamp + "</strong></span>" +
|
//QString line = "<span style=\"color:#C00000\"><strong>" + timestamp + "</strong></span>" +
|
||||||
"<span style=\"color:#2D84C9\"><strong>" + " " + name + "</strong></span>";
|
// "<span style=\"color:#2D84C9\"><strong>" + " " + name + "</strong></span>";
|
||||||
extraTxt += line;
|
//extraTxt += line;
|
||||||
extraTxt += QString::fromStdWString(ci -> msg);
|
|
||||||
|
|
||||||
//QString message = QString::fromStdWString(ci -> msg);
|
QString message = QString::fromStdWString(ci -> msg);
|
||||||
|
|
||||||
|
//currenttxt += extraTxt;
|
||||||
|
|
||||||
QHashIterator<QString, QString> i(smileys);
|
QHashIterator<QString, QString> i(smileys);
|
||||||
while(i.hasNext())
|
while(i.hasNext())
|
||||||
{
|
{
|
||||||
i.next();
|
i.next();
|
||||||
extraTxt.replace(i.key(), "<img src=\"" + i.value() + "\">");
|
message.replace(i.key(), "<img src=\"" + i.value() + "\">");
|
||||||
//message.replace(i.key(), "<img src=\"" + i.value() + "\">");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
currenttxt += extraTxt;
|
|
||||||
ui.textBrowser->setHtml(currenttxt);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
history /*<< nickColor << color << font << fontSize*/ << timestamp << name << message;
|
history /*<< nickColor << color << font << fontSize*/ << timestamp << name << message;
|
||||||
|
|
||||||
QString formatMsg = loadEmptyStyle()/*.replace(nickColor)
|
QString formatMsg = loadEmptyStyle()/*.replace(nickColor)
|
||||||
@ -216,7 +214,6 @@ void PopupChatDialog::addChatMsg(ChatInfo *ci)
|
|||||||
.replace("%message%", message);
|
.replace("%message%", message);
|
||||||
|
|
||||||
ui.textBrowser->setHtml(ui.textBrowser->toHtml() + formatMsg + "\n");
|
ui.textBrowser->setHtml(ui.textBrowser->toHtml() + formatMsg + "\n");
|
||||||
#endif
|
|
||||||
|
|
||||||
QTextCursor cursor = ui.textBrowser->textCursor();
|
QTextCursor cursor = ui.textBrowser->textCursor();
|
||||||
cursor.movePosition(QTextCursor::End);
|
cursor.movePosition(QTextCursor::End);
|
||||||
@ -271,6 +268,8 @@ void PopupChatDialog::sendChat()
|
|||||||
ci.msg = chatWidget->toHtml().toStdWString();
|
ci.msg = chatWidget->toHtml().toStdWString();
|
||||||
ci.chatflags = RS_CHAT_PRIVATE;
|
ci.chatflags = RS_CHAT_PRIVATE;
|
||||||
|
|
||||||
|
std::cout << "PopupChatDialog:sendChat " << styleHtm.toStdString() << std::endl;
|
||||||
|
|
||||||
addChatMsg(&ci);
|
addChatMsg(&ci);
|
||||||
|
|
||||||
/* put proper destination */
|
/* put proper destination */
|
||||||
@ -399,20 +398,34 @@ void PopupChatDialog::addSmiley()
|
|||||||
|
|
||||||
QString PopupChatDialog::loadEmptyStyle()
|
QString PopupChatDialog::loadEmptyStyle()
|
||||||
{
|
{
|
||||||
|
std::cout << "PopupChatDialog:loadEmptyStyle " << styleHtm.toStdString() << std::endl;
|
||||||
QString ret;
|
QString ret;
|
||||||
QFile file(styleHtm);
|
QFile file(styleHtm);
|
||||||
file.open(QIODevice::ReadOnly);
|
//file.open(QIODevice::ReadOnly);
|
||||||
|
if (file.open(QIODevice::ReadOnly)) {
|
||||||
ret = file.readAll();
|
ret = file.readAll();
|
||||||
file.close();
|
file.close();
|
||||||
QString styleTmp = styleHtm;
|
QString styleTmp = styleHtm;
|
||||||
QString styleCss = styleTmp.remove(styleHtm.lastIndexOf("."), styleHtm.length()-styleHtm.lastIndexOf(".")) + ".css";
|
QString styleCss = styleTmp.remove(styleHtm.lastIndexOf("."), styleHtm.length()-styleHtm.lastIndexOf(".")) + ".css";
|
||||||
qDebug() << styleCss.toAscii();
|
qDebug() << styleCss.toAscii();
|
||||||
QFile css(styleCss);
|
QFile css(styleCss);
|
||||||
css.open(QIODevice::ReadOnly);
|
QString tmp;
|
||||||
QString tmp = css.readAll();
|
if (css.open(QIODevice::ReadOnly)) {
|
||||||
|
tmp = css.readAll();
|
||||||
css.close();
|
css.close();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
std::cerr << "PopupChatDialog:loadEmptyStyle " << "Missing file of default css " << std::endl;
|
||||||
|
tmp = "";
|
||||||
|
}
|
||||||
ret.replace("%css-style%", tmp);
|
ret.replace("%css-style%", tmp);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
std::cerr << "PopupChatDialog:loadEmptyStyle " << "Missing file of default style " << std::endl;
|
||||||
|
ret="%timestamp% %name% \n %message% ";
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupChatDialog::changeStyle()
|
void PopupChatDialog::changeStyle()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user