mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fixes action bugs
1) action received gets modified on restart 2) sender's name is written twice if action is sent using offline messaging 3) /me is written when action is sent in groupchat having one peer 4) /me is not saved in last message variable in friendd chat
This commit is contained in:
parent
2d29c3d9f4
commit
b4f72b620d
|
@ -67,7 +67,7 @@ ChatMessage::Ptr ChatMessage::createChatMessage(const QString &sender, const QSt
|
||||||
|
|
||||||
// Note: Eliding cannot be enabled for RichText items. (QTBUG-17207)
|
// Note: Eliding cannot be enabled for RichText items. (QTBUG-17207)
|
||||||
msg->addColumn(new Text(senderText, isMe ? Style::getFont(Style::BigBold) : Style::getFont(Style::Big), true, sender, type == ACTION ? actionColor : Qt::black), ColumnFormat(NAME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right));
|
msg->addColumn(new Text(senderText, isMe ? Style::getFont(Style::BigBold) : Style::getFont(Style::Big), true, sender, type == ACTION ? actionColor : Qt::black), ColumnFormat(NAME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right));
|
||||||
msg->addColumn(new Text(text, Style::getFont(Style::Big), false, type == ACTION ? QString("*%1 %2*").arg(sender, rawMessage) : rawMessage), ColumnFormat(1.0, ColumnFormat::VariableSize));
|
msg->addColumn(new Text(text, Style::getFont(Style::Big), false, type == (ACTION && isMe) ? QString("%1 %2").arg(sender, rawMessage) : rawMessage), ColumnFormat(1.0, ColumnFormat::VariableSize));
|
||||||
msg->addColumn(new Spinner(":/ui/chatArea/spinner.svg", QSize(16, 16), 360.0/1.6), ColumnFormat(TIME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right));
|
msg->addColumn(new Spinner(":/ui/chatArea/spinner.svg", QSize(16, 16), 360.0/1.6), ColumnFormat(TIME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right));
|
||||||
|
|
||||||
if(!date.isNull())
|
if(!date.isNull())
|
||||||
|
|
|
@ -58,7 +58,7 @@ ChatForm::ChatForm(Friend* chatFriend)
|
||||||
statusMessageLabel->setFont(Style::getFont(Style::Medium));
|
statusMessageLabel->setFont(Style::getFont(Style::Medium));
|
||||||
statusMessageLabel->setMinimumHeight(Style::getFont(Style::Medium).pixelSize());
|
statusMessageLabel->setMinimumHeight(Style::getFont(Style::Medium).pixelSize());
|
||||||
statusMessageLabel->setTextFormat(Qt::PlainText);
|
statusMessageLabel->setTextFormat(Qt::PlainText);
|
||||||
|
|
||||||
callConfirm = nullptr;
|
callConfirm = nullptr;
|
||||||
offlineEngine = new OfflineMsgEngine(f);
|
offlineEngine = new OfflineMsgEngine(f);
|
||||||
|
|
||||||
|
@ -116,6 +116,8 @@ void ChatForm::onSendTriggered()
|
||||||
if (msg.isEmpty())
|
if (msg.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
msgEdit->setLastMessage(msg); //set last message only when sending it
|
||||||
|
|
||||||
bool isAction = msg.startsWith("/me ");
|
bool isAction = msg.startsWith("/me ");
|
||||||
if (isAction)
|
if (isAction)
|
||||||
msg = msg = msg.right(msg.length() - 4);
|
msg = msg = msg.right(msg.length() - 4);
|
||||||
|
@ -123,8 +125,6 @@ void ChatForm::onSendTriggered()
|
||||||
QList<CString> splittedMsg = Core::splitMessage(msg, TOX_MAX_MESSAGE_LENGTH);
|
QList<CString> splittedMsg = Core::splitMessage(msg, TOX_MAX_MESSAGE_LENGTH);
|
||||||
QDateTime timestamp = QDateTime::currentDateTime();
|
QDateTime timestamp = QDateTime::currentDateTime();
|
||||||
|
|
||||||
msgEdit->setLastMessage(msg); //set last message only when sending it
|
|
||||||
|
|
||||||
bool status = !Settings::getInstance().getFauxOfflineMessaging();
|
bool status = !Settings::getInstance().getFauxOfflineMessaging();
|
||||||
|
|
||||||
for (CString& c_msg : splittedMsg)
|
for (CString& c_msg : splittedMsg)
|
||||||
|
@ -298,7 +298,7 @@ void ChatForm::onAvInvite(uint32_t FriendId, int CallId, bool video)
|
||||||
}
|
}
|
||||||
callButton->style()->polish(callButton);
|
callButton->style()->polish(callButton);
|
||||||
videoButton->style()->polish(videoButton);
|
videoButton->style()->polish(videoButton);
|
||||||
|
|
||||||
insertChatMessage(ChatMessage::createChatInfoMessage(tr("%1 calling").arg(f->getDisplayedName()), ChatMessage::INFO, QDateTime::currentDateTime()));
|
insertChatMessage(ChatMessage::createChatInfoMessage(tr("%1 calling").arg(f->getDisplayedName()), ChatMessage::INFO, QDateTime::currentDateTime()));
|
||||||
|
|
||||||
Widget* w = Widget::getInstance();
|
Widget* w = Widget::getInstance();
|
||||||
|
@ -357,7 +357,7 @@ void ChatForm::onAvStart(uint32_t FriendId, int CallId, bool video)
|
||||||
this, SLOT(onMicMuteToggle()));
|
this, SLOT(onMicMuteToggle()));
|
||||||
connect(volButton, SIGNAL(clicked()),
|
connect(volButton, SIGNAL(clicked()),
|
||||||
this, SLOT(onVolMuteToggle()));
|
this, SLOT(onVolMuteToggle()));
|
||||||
|
|
||||||
startCounter();
|
startCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +375,7 @@ void ChatForm::onAvCancel(uint32_t FriendId, int)
|
||||||
stopCounter();
|
stopCounter();
|
||||||
|
|
||||||
netcam->hide();
|
netcam->hide();
|
||||||
|
|
||||||
addSystemInfoMessage(tr("%1 stopped calling").arg(f->getDisplayedName()), ChatMessage::INFO, QDateTime::currentDateTime());
|
addSystemInfoMessage(tr("%1 stopped calling").arg(f->getDisplayedName()), ChatMessage::INFO, QDateTime::currentDateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,7 +395,7 @@ void ChatForm::onAvEnd(uint32_t FriendId, int)
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatForm::onAvRinging(uint32_t FriendId, int CallId, bool video)
|
void ChatForm::onAvRinging(uint32_t FriendId, int CallId, bool video)
|
||||||
{
|
{
|
||||||
if (FriendId != f->getFriendID())
|
if (FriendId != f->getFriendID())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -426,7 +426,7 @@ void ChatForm::onAvRinging(uint32_t FriendId, int CallId, bool video)
|
||||||
connect(callButton, SIGNAL(clicked()),
|
connect(callButton, SIGNAL(clicked()),
|
||||||
this, SLOT(onCancelCallTriggered()));
|
this, SLOT(onCancelCallTriggered()));
|
||||||
}
|
}
|
||||||
|
|
||||||
addSystemInfoMessage(tr("Calling to %1").arg(f->getDisplayedName()), ChatMessage::INFO, QDateTime::currentDateTime());
|
addSystemInfoMessage(tr("Calling to %1").arg(f->getDisplayedName()), ChatMessage::INFO, QDateTime::currentDateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -461,7 +461,7 @@ void ChatForm::onAvStarting(uint32_t FriendId, int CallId, bool video)
|
||||||
videoButton->setToolTip("");
|
videoButton->setToolTip("");
|
||||||
connect(callButton, SIGNAL(clicked()), this, SLOT(onHangupCallTriggered()));
|
connect(callButton, SIGNAL(clicked()), this, SLOT(onHangupCallTriggered()));
|
||||||
}
|
}
|
||||||
|
|
||||||
startCounter();
|
startCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,7 +477,7 @@ void ChatForm::onAvEnding(uint32_t FriendId, int)
|
||||||
|
|
||||||
enableCallButtons();
|
enableCallButtons();
|
||||||
stopCounter();
|
stopCounter();
|
||||||
|
|
||||||
netcam->hide();
|
netcam->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,7 +493,7 @@ void ChatForm::onAvRequestTimeout(uint32_t FriendId, int)
|
||||||
|
|
||||||
enableCallButtons();
|
enableCallButtons();
|
||||||
stopCounter();
|
stopCounter();
|
||||||
|
|
||||||
netcam->hide();
|
netcam->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,10 +506,10 @@ void ChatForm::onAvPeerTimeout(uint32_t FriendId, int)
|
||||||
|
|
||||||
delete callConfirm;
|
delete callConfirm;
|
||||||
callConfirm = nullptr;
|
callConfirm = nullptr;
|
||||||
|
|
||||||
enableCallButtons();
|
enableCallButtons();
|
||||||
stopCounter();
|
stopCounter();
|
||||||
|
|
||||||
netcam->hide();
|
netcam->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -524,7 +524,7 @@ void ChatForm::onAvRejected(uint32_t FriendId, int)
|
||||||
callConfirm = nullptr;
|
callConfirm = nullptr;
|
||||||
|
|
||||||
enableCallButtons();
|
enableCallButtons();
|
||||||
|
|
||||||
insertChatMessage(ChatMessage::createChatInfoMessage(tr("Call rejected"), ChatMessage::INFO, QDateTime::currentDateTime()));
|
insertChatMessage(ChatMessage::createChatInfoMessage(tr("Call rejected"), ChatMessage::INFO, QDateTime::currentDateTime()));
|
||||||
|
|
||||||
netcam->hide();
|
netcam->hide();
|
||||||
|
@ -586,7 +586,7 @@ void ChatForm::onRejectCallTriggered()
|
||||||
audioInputFlag = false;
|
audioInputFlag = false;
|
||||||
audioOutputFlag = false;
|
audioOutputFlag = false;
|
||||||
emit rejectCall(callId);
|
emit rejectCall(callId);
|
||||||
|
|
||||||
enableCallButtons();
|
enableCallButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,19 +638,19 @@ void ChatForm::onCancelCallTriggered()
|
||||||
void ChatForm::enableCallButtons()
|
void ChatForm::enableCallButtons()
|
||||||
{
|
{
|
||||||
qDebug() << "enableCallButtons";
|
qDebug() << "enableCallButtons";
|
||||||
|
|
||||||
audioInputFlag = false;
|
audioInputFlag = false;
|
||||||
audioOutputFlag = false;
|
audioOutputFlag = false;
|
||||||
|
|
||||||
micButton->setObjectName("grey");
|
micButton->setObjectName("grey");
|
||||||
micButton->style()->polish(micButton);
|
micButton->style()->polish(micButton);
|
||||||
micButton->setToolTip("");
|
micButton->setToolTip("");
|
||||||
micButton->disconnect();
|
micButton->disconnect();
|
||||||
volButton->setObjectName("grey");
|
volButton->setObjectName("grey");
|
||||||
volButton->style()->polish(volButton);
|
volButton->style()->polish(volButton);
|
||||||
volButton->setToolTip("");
|
volButton->setToolTip("");
|
||||||
volButton->disconnect();
|
volButton->disconnect();
|
||||||
|
|
||||||
callButton->setObjectName("grey");
|
callButton->setObjectName("grey");
|
||||||
callButton->style()->polish(callButton);
|
callButton->style()->polish(callButton);
|
||||||
callButton->setToolTip("");
|
callButton->setToolTip("");
|
||||||
|
@ -659,7 +659,7 @@ void ChatForm::enableCallButtons()
|
||||||
videoButton->style()->polish(videoButton);
|
videoButton->style()->polish(videoButton);
|
||||||
videoButton->setToolTip("");
|
videoButton->setToolTip("");
|
||||||
videoButton->disconnect();
|
videoButton->disconnect();
|
||||||
|
|
||||||
if(disableCallButtonsTimer == nullptr)
|
if(disableCallButtonsTimer == nullptr)
|
||||||
{
|
{
|
||||||
disableCallButtonsTimer = new QTimer();
|
disableCallButtonsTimer = new QTimer();
|
||||||
|
@ -668,7 +668,7 @@ void ChatForm::enableCallButtons()
|
||||||
disableCallButtonsTimer->start(1500); // 1.5sec
|
disableCallButtonsTimer->start(1500); // 1.5sec
|
||||||
qDebug() << "timer started!!";
|
qDebug() << "timer started!!";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatForm::onEnableCallButtons()
|
void ChatForm::onEnableCallButtons()
|
||||||
|
@ -683,7 +683,7 @@ void ChatForm::onEnableCallButtons()
|
||||||
videoButton->setObjectName("green");
|
videoButton->setObjectName("green");
|
||||||
videoButton->style()->polish(videoButton);
|
videoButton->style()->polish(videoButton);
|
||||||
videoButton->setToolTip(tr("Start video call"));
|
videoButton->setToolTip(tr("Start video call"));
|
||||||
|
|
||||||
connect(callButton, SIGNAL(clicked()),
|
connect(callButton, SIGNAL(clicked()),
|
||||||
this, SLOT(onCallTriggered()));
|
this, SLOT(onCallTriggered()));
|
||||||
connect(videoButton, SIGNAL(clicked()),
|
connect(videoButton, SIGNAL(clicked()),
|
||||||
|
@ -824,7 +824,7 @@ void ChatForm::loadHistory(QDateTime since, bool processUndelivered)
|
||||||
// Show the date every new day
|
// Show the date every new day
|
||||||
QDateTime msgDateTime = it.timestamp.toLocalTime();
|
QDateTime msgDateTime = it.timestamp.toLocalTime();
|
||||||
QDate msgDate = msgDateTime.date();
|
QDate msgDate = msgDateTime.date();
|
||||||
|
|
||||||
if (msgDate > lastDate)
|
if (msgDate > lastDate)
|
||||||
{
|
{
|
||||||
lastDate = msgDate;
|
lastDate = msgDate;
|
||||||
|
@ -860,7 +860,7 @@ void ChatForm::loadHistory(QDateTime since, bool processUndelivered)
|
||||||
rec = Core::getInstance()->sendMessage(f->getFriendID(), msg->toString());
|
rec = Core::getInstance()->sendMessage(f->getFriendID(), msg->toString());
|
||||||
else
|
else
|
||||||
rec = Core::getInstance()->sendAction(f->getFriendID(), msg->toString());
|
rec = Core::getInstance()->sendAction(f->getFriendID(), msg->toString());
|
||||||
|
|
||||||
getOfflineMsgEngine()->registerReceipt(rec, it.id, msg);
|
getOfflineMsgEngine()->registerReceipt(rec, it.id, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -910,7 +910,7 @@ void ChatForm::stopCounter()
|
||||||
callDurationTimer->stop();
|
callDurationTimer->stop();
|
||||||
callDuration->setText("");
|
callDuration->setText("");
|
||||||
callDuration->hide();
|
callDuration->hide();
|
||||||
|
|
||||||
delete callDurationTimer;
|
delete callDurationTimer;
|
||||||
callDurationTimer = nullptr;
|
callDurationTimer = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -931,13 +931,13 @@ QString ChatForm::secondsToDHMS(quint32 duration)
|
||||||
duration /= 60;
|
duration /= 60;
|
||||||
int hours = (int) (duration % 24);
|
int hours = (int) (duration % 24);
|
||||||
int days = (int) (duration / 24);
|
int days = (int) (duration / 24);
|
||||||
|
|
||||||
if (minutes == 0)
|
if (minutes == 0)
|
||||||
return cD + res.sprintf("%02ds", seconds);
|
return cD + res.sprintf("%02ds", seconds);
|
||||||
|
|
||||||
if (hours == 0 && days == 0)
|
if (hours == 0 && days == 0)
|
||||||
return cD + res.sprintf("%02dm %02ds", minutes, seconds);
|
return cD + res.sprintf("%02dm %02ds", minutes, seconds);
|
||||||
|
|
||||||
if (days == 0)
|
if (days == 0)
|
||||||
return cD + res.sprintf("%02dh %02dm %02ds", hours, minutes, seconds);
|
return cD + res.sprintf("%02dh %02dm %02ds", hours, minutes, seconds);
|
||||||
//I assume no one will ever have call longer than ~30days
|
//I assume no one will ever have call longer than ~30days
|
||||||
|
|
|
@ -65,14 +65,14 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
|
||||||
namesListLayout = new FlowLayout(0,5,0);
|
namesListLayout = new FlowLayout(0,5,0);
|
||||||
QStringList names(group->getPeerList());
|
QStringList names(group->getPeerList());
|
||||||
QLabel *l;
|
QLabel *l;
|
||||||
|
|
||||||
for (const QString& name : names)
|
for (const QString& name : names)
|
||||||
{
|
{
|
||||||
l = new QLabel(name);
|
l = new QLabel(name);
|
||||||
l->setTextFormat(Qt::PlainText);
|
l->setTextFormat(Qt::PlainText);
|
||||||
namesListLayout->addWidget(l);
|
namesListLayout->addWidget(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
headTextLayout->addWidget(nusersLabel);
|
headTextLayout->addWidget(nusersLabel);
|
||||||
headTextLayout->addLayout(namesListLayout);
|
headTextLayout->addLayout(namesListLayout);
|
||||||
headTextLayout->addStretch();
|
headTextLayout->addStretch();
|
||||||
|
@ -116,7 +116,10 @@ void GroupChatForm::onSendTriggered()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
addSelfMessage(msg, msg.startsWith("/me "), QDateTime::currentDateTime(), true);
|
if (msg.startsWith("/me "))
|
||||||
|
addSelfMessage(msg.right(msg.length() - 4), true, QDateTime::currentDateTime(), true);
|
||||||
|
else
|
||||||
|
addSelfMessage(msg, false, QDateTime::currentDateTime(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -737,7 +737,7 @@ void Widget::onFriendMessageReceived(int friendId, const QString& message, bool
|
||||||
QDateTime timestamp = QDateTime::currentDateTime();
|
QDateTime timestamp = QDateTime::currentDateTime();
|
||||||
f->getChatForm()->addMessage(f->getToxID(), message, isAction, timestamp, true);
|
f->getChatForm()->addMessage(f->getToxID(), message, isAction, timestamp, true);
|
||||||
|
|
||||||
HistoryKeeper::getInstance()->addChatEntry(f->getToxID().publicKey, isAction ? "/me " + message : message,
|
HistoryKeeper::getInstance()->addChatEntry(f->getToxID().publicKey, isAction ? "/me " + f->getDisplayedName() + " " + message : message,
|
||||||
f->getToxID().publicKey, timestamp, true);
|
f->getToxID().publicKey, timestamp, true);
|
||||||
|
|
||||||
f->setEventFlag(f->getFriendWidget() != activeChatroomWidget);
|
f->setEventFlag(f->getFriendWidget() != activeChatroomWidget);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user