mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
innerStyle, groupchats
This commit is contained in:
parent
7a4af239b0
commit
f1f42fc237
|
@ -77,20 +77,24 @@ ChatLog::~ChatLog()
|
|||
delete line;
|
||||
}
|
||||
|
||||
ChatMessage* ChatLog::addChatMessage(const QString& sender, const QString &msg, bool self)
|
||||
ChatMessage* ChatLog::addChatMessage(const QString& sender, const QString &msg, bool self, bool alert)
|
||||
{
|
||||
QString txt = SmileyPack::getInstance().smileyfied(msg);
|
||||
if(alert)
|
||||
txt = "<div class=alert>" + txt + "</div>";
|
||||
|
||||
ChatMessage* line = new ChatMessage(scene, msg);
|
||||
line->addColumn(new Text(sender, self ? Style::getFont(Style::MediumBold) : Style::getFont(Style::Medium), true), ColumnFormat(75.0, ColumnFormat::FixedSize, ColumnFormat::Right));
|
||||
line->addColumn(new Text(SmileyPack::getInstance().smileyfied(msg)), ColumnFormat(1.0, ColumnFormat::VariableSize));
|
||||
line->addColumn(new Text(sender, self ? Style::getFont(Style::BigBold) : Style::getFont(Style::Big), true), ColumnFormat(75.0, ColumnFormat::FixedSize, ColumnFormat::Right));
|
||||
line->addColumn(new Text(txt, Style::getFont(Style::Big)), ColumnFormat(1.0, ColumnFormat::VariableSize));
|
||||
line->addColumn(new Spinner(QSizeF(16, 16)), ColumnFormat(50.0, ColumnFormat::FixedSize, ColumnFormat::Right));
|
||||
|
||||
insertChatline(line);
|
||||
return line;
|
||||
}
|
||||
|
||||
ChatMessage* ChatLog::addChatMessage(const QString& sender, const QString& msg, const QDateTime& timestamp, bool self)
|
||||
ChatMessage* ChatLog::addChatMessage(const QString& sender, const QString& msg, const QDateTime& timestamp, bool self, bool alert)
|
||||
{
|
||||
ChatMessage* line = addChatMessage(sender, msg, self);
|
||||
ChatMessage* line = addChatMessage(sender, msg, self, alert);
|
||||
line->markAsSent(timestamp);
|
||||
|
||||
return line;
|
||||
|
@ -107,8 +111,8 @@ ChatMessage *ChatLog::addChatAction(const QString &sender, const QString &msg, c
|
|||
ChatMessage *ChatLog::addChatAction(const QString &sender, const QString &msg)
|
||||
{
|
||||
ChatMessage* line = new ChatMessage(scene, msg);
|
||||
line->addColumn(new Text("", Style::getFont(Style::Medium), true), ColumnFormat(75.0, ColumnFormat::FixedSize, ColumnFormat::Right));
|
||||
line->addColumn(new Text("<font color=\"red\">*" + sender + " " + SmileyPack::getInstance().smileyfied(msg) + "</font>"), ColumnFormat(1.0, ColumnFormat::VariableSize));
|
||||
line->addColumn(new Text(""), ColumnFormat(75.0, ColumnFormat::FixedSize, ColumnFormat::Right));
|
||||
line->addColumn(new Text("<div class=action>*" + sender + " " + SmileyPack::getInstance().smileyfied(msg) + "</div>", Style::getFont(Style::Big)), ColumnFormat(1.0, ColumnFormat::VariableSize));
|
||||
line->addColumn(new Spinner(QSizeF(16, 16)), ColumnFormat(50.0, ColumnFormat::FixedSize, ColumnFormat::Right));
|
||||
line->setAsAction();
|
||||
|
||||
|
@ -120,8 +124,8 @@ ChatMessage *ChatLog::addSystemMessage(const QString &msg, const QDateTime& time
|
|||
{
|
||||
ChatMessage* line = new ChatMessage(scene, msg);
|
||||
line->addColumn(new Image(QSizeF(16, 16), ":/ui/chatArea/info.png"), ColumnFormat(75.0, ColumnFormat::FixedSize, ColumnFormat::Right));
|
||||
line->addColumn(new Text(msg), ColumnFormat(1.0, ColumnFormat::VariableSize));
|
||||
line->addColumn(new Text(timestamp.toString("hh:mm")), ColumnFormat(50.0, ColumnFormat::FixedSize, ColumnFormat::Right));
|
||||
line->addColumn(new Text(msg, Style::getFont(Style::Big)), ColumnFormat(1.0, ColumnFormat::VariableSize));
|
||||
line->addColumn(new Text(timestamp.toString("hh:mm"), Style::getFont(Style::Big)), ColumnFormat(50.0, ColumnFormat::FixedSize, ColumnFormat::Right));
|
||||
|
||||
insertChatline(line);
|
||||
return line;
|
||||
|
@ -130,9 +134,9 @@ ChatMessage *ChatLog::addSystemMessage(const QString &msg, const QDateTime& time
|
|||
ChatMessage *ChatLog::addFileTransferMessage(const QString &sender, const ToxFile &file, const QDateTime& timestamp, bool self)
|
||||
{
|
||||
ChatMessage* line = new ChatMessage(scene, QString());
|
||||
line->addColumn(new Text(sender, self ? Style::getFont(Style::MediumBold) : Style::getFont(Style::Medium), true), ColumnFormat(75.0, ColumnFormat::FixedSize, ColumnFormat::Right));
|
||||
line->addColumn(new Text(sender, self ? Style::getFont(Style::BigBold) : Style::getFont(Style::Big), true), ColumnFormat(75.0, ColumnFormat::FixedSize, ColumnFormat::Right));
|
||||
line->addColumn(new ChatLineContentProxy(new FileTransferWidget(0, file)), ColumnFormat(1.0, ColumnFormat::VariableSize));
|
||||
line->addColumn(new Text(timestamp.toString("hh:mm")), ColumnFormat(50.0, ColumnFormat::FixedSize, ColumnFormat::Right));
|
||||
line->addColumn(new Text(timestamp.toString("hh:mm"), Style::getFont(Style::Big)), ColumnFormat(50.0, ColumnFormat::FixedSize, ColumnFormat::Right));
|
||||
|
||||
insertChatline(line);
|
||||
return line;
|
||||
|
|
|
@ -35,8 +35,8 @@ public:
|
|||
explicit ChatLog(QWidget* parent = 0);
|
||||
virtual ~ChatLog();
|
||||
|
||||
ChatMessage* addChatMessage(const QString& sender, const QString& msg, const QDateTime& timestamp, bool self);
|
||||
ChatMessage* addChatMessage(const QString& sender, const QString& msg, bool self);
|
||||
ChatMessage* addChatMessage(const QString& sender, const QString& msg, const QDateTime& timestamp, bool self, bool alert);
|
||||
ChatMessage* addChatMessage(const QString& sender, const QString& msg, bool self, bool alert);
|
||||
ChatMessage* addChatAction(const QString& sender, const QString& msg, const QDateTime& timestamp);
|
||||
ChatMessage* addChatAction(const QString& sender, const QString& msg);
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "customtextdocument.h"
|
||||
#include "../misc/smileypack.h"
|
||||
#include "../misc/style.h"
|
||||
|
||||
#include <QIcon>
|
||||
#include <QDebug>
|
||||
|
@ -23,7 +24,7 @@
|
|||
CustomTextDocument::CustomTextDocument(QObject *parent)
|
||||
: QTextDocument(parent)
|
||||
{
|
||||
|
||||
setDefaultStyleSheet(Style::getStylesheet(":ui/chatArea/innerStyle.css"));
|
||||
}
|
||||
|
||||
QVariant CustomTextDocument::loadResource(int type, const QUrl &name)
|
||||
|
|
|
@ -716,7 +716,7 @@ void ChatForm::loadHistory(QDateTime since, bool processUndelivered)
|
|||
|
||||
// Show each messages
|
||||
ToxID id = ToxID::fromString(it.sender);
|
||||
ChatMessage* msg = chatWidget->addChatMessage(Core::getInstance()->getPeerName(id), it.message, id.isMine());
|
||||
ChatMessage* msg = chatWidget->addChatMessage(Core::getInstance()->getPeerName(id), it.message, id.isMine(), false);
|
||||
if (it.isSent)
|
||||
{
|
||||
msg->markAsSent(msgDateTime);
|
||||
|
|
|
@ -174,6 +174,18 @@ void GenericChatForm::show(Ui::MainWindow &ui)
|
|||
QWidget::show();
|
||||
}
|
||||
|
||||
void GenericChatForm::addMessage(const QString &author, const QString &message, bool isAction, const QDateTime &datetime)
|
||||
{
|
||||
if(!isAction)
|
||||
{
|
||||
chatWidget->addChatMessage(author, message, datetime, false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
chatWidget->addChatAction(author, message, datetime);
|
||||
}
|
||||
}
|
||||
|
||||
void GenericChatForm::onChatContextMenuRequested(QPoint pos)
|
||||
{
|
||||
QWidget* sender = (QWidget*)QObject::sender();
|
||||
|
@ -207,7 +219,7 @@ ChatMessage* GenericChatForm::addMessage(const ToxID& author, const QString &mes
|
|||
if(isAction)
|
||||
msg = chatWidget->addChatAction(authorStr, message);
|
||||
else
|
||||
msg = chatWidget->addChatMessage(author != previousId ? authorStr : QString(), message, author.isMine());
|
||||
msg = chatWidget->addChatMessage(author != previousId ? authorStr : QString(), message, author.isMine(), false);
|
||||
|
||||
if(isSent)
|
||||
msg->markAsSent(datetime);
|
||||
|
@ -223,25 +235,11 @@ ChatMessage* GenericChatForm::addSelfMessage(const QString &message, bool isActi
|
|||
return addMessage(Core::getInstance()->getSelfId(), message, isAction, datetime, isSent);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated The only reason it's still alive is because the groupchat API is a bit limited
|
||||
*/
|
||||
//void GenericChatForm::addAlertMessage(const QString& author, QString message, QDateTime datetime)
|
||||
//{
|
||||
// QString date = datetime.toString(Settings::getInstance().getTimestampFormat());
|
||||
// AlertAction *alact = new AlertAction(author, message, date);
|
||||
// alact->markAsSent();
|
||||
// chatWidget->insertMessage(ChatActionPtr(alact));
|
||||
|
||||
// previousId.publicKey = author;
|
||||
//}
|
||||
|
||||
void GenericChatForm::addAlertMessage(const ToxID &author, QString message, QDateTime datetime)
|
||||
{
|
||||
// QString authorStr = Core::getInstance()->getPeerName(author);
|
||||
// QString date = datetime.toString(Settings::getInstance().getTimestampFormat());
|
||||
// chatWidget->insertMessage(ChatActionPtr(new AlertAction(authorStr, message, date)));
|
||||
// previousId = author;
|
||||
QString authorStr = Core::getInstance()->getPeerName(author);
|
||||
chatWidget->addChatMessage(author != previousId ? authorStr : QString(), message, author.isMine(), true);
|
||||
previousId = author;
|
||||
}
|
||||
|
||||
void GenericChatForm::onEmoteButtonClicked()
|
||||
|
@ -282,6 +280,12 @@ void GenericChatForm::addSystemInfoMessage(const QString &message, const QString
|
|||
chatWidget->addSystemMessage(message, datetime);
|
||||
}
|
||||
|
||||
void GenericChatForm::addAlertMessage(const QString &author, QString message, QDateTime datetime)
|
||||
{
|
||||
ChatMessage* msg = chatWidget->addChatMessage(author, message, false, true);
|
||||
msg->markAsSent(datetime);
|
||||
}
|
||||
|
||||
//QString GenericChatForm::getElidedName(const QString& name)
|
||||
//{
|
||||
// // update this whenever you change the font in innerStyle.css
|
||||
|
|
|
@ -900,10 +900,9 @@ void Widget::onGroupMessageReceived(int groupnumber, const QString& message, con
|
|||
|
||||
bool targeted = (author != name) && message.contains(name, Qt::CaseInsensitive);
|
||||
if (targeted)
|
||||
;//TODO: g->chatForm->addAlertMessage(author, message, QDateTime::currentDateTime());
|
||||
g->chatForm->addAlertMessage(author, message, QDateTime::currentDateTime());
|
||||
else
|
||||
|
||||
;//TODO: g->chatForm->addMessage(author, message, isAction, QDateTime::currentDateTime());
|
||||
g->chatForm->addMessage(author, message, isAction, QDateTime::currentDateTime());
|
||||
|
||||
if ((static_cast<GenericChatroomWidget*>(g->widget) != activeChatroomWidget) || isMinimized() || !isActiveWindow())
|
||||
{
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
div.name {
|
||||
color: @black;
|
||||
font: @bigBold;
|
||||
}
|
||||
|
||||
div.message {
|
||||
color: @black;
|
||||
font: @big;
|
||||
|
@ -13,60 +8,10 @@ div.action {
|
|||
font: @big;
|
||||
}
|
||||
|
||||
div.date {
|
||||
color: @black;
|
||||
font: @big;
|
||||
}
|
||||
|
||||
div.name_me {
|
||||
color: @mediumGrey;
|
||||
font: @big;
|
||||
}
|
||||
|
||||
div.message_me {
|
||||
color: @black;
|
||||
font: @big;
|
||||
}
|
||||
|
||||
div.date_me {
|
||||
color: @black;
|
||||
font: @big;
|
||||
}
|
||||
|
||||
span.quote {
|
||||
color: #6bc260;
|
||||
}
|
||||
|
||||
div.green {
|
||||
margin-top: 6px;
|
||||
margin-bottom: 6px;
|
||||
margin-left: 0px;
|
||||
margin-right: 0px;
|
||||
color: @white;
|
||||
background-color: @green;
|
||||
font: @small;
|
||||
}
|
||||
|
||||
div.silver {
|
||||
margin-top: 6px;
|
||||
margin-bottom: 6px;
|
||||
margin-left: 0px;
|
||||
margin-right: 0px;
|
||||
color: @black;
|
||||
background-color: @lightGrey;
|
||||
font: @small;
|
||||
}
|
||||
|
||||
div.red {
|
||||
margin-top: 6px;
|
||||
margin-bottom: 6px;
|
||||
margin-left: 0px;
|
||||
margin-right: 0px;
|
||||
color: @white;
|
||||
background-color: @red;
|
||||
font: @small;
|
||||
}
|
||||
|
||||
div.alert {
|
||||
margin-left: 0px;
|
||||
margin-right: 0px;
|
||||
|
@ -80,10 +25,3 @@ div.alert_name {
|
|||
background-color: @orange;
|
||||
font: @bigBold;
|
||||
}
|
||||
|
||||
div.button {
|
||||
margin-top: 0px;
|
||||
margin-bottom: 0px;
|
||||
margin-left: 0px;
|
||||
color: @white;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user