1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge branch 'pr1496' into back_in_the_game

This commit is contained in:
tux3 2015-04-24 22:28:10 +02:00
commit 2954ee3c95
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
4 changed files with 36 additions and 33 deletions

View File

@ -67,7 +67,7 @@ ChatMessage::Ptr ChatMessage::createChatMessage(const QString &sender, const QSt
// 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(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));
if(!date.isNull())

View File

@ -58,7 +58,7 @@ ChatForm::ChatForm(Friend* chatFriend)
statusMessageLabel->setFont(Style::getFont(Style::Medium));
statusMessageLabel->setMinimumHeight(Style::getFont(Style::Medium).pixelSize());
statusMessageLabel->setTextFormat(Qt::PlainText);
callConfirm = nullptr;
offlineEngine = new OfflineMsgEngine(f);
@ -116,6 +116,8 @@ void ChatForm::onSendTriggered()
if (msg.isEmpty())
return;
msgEdit->setLastMessage(msg); //set last message only when sending it
bool isAction = msg.startsWith("/me ");
if (isAction)
msg = msg = msg.right(msg.length() - 4);
@ -123,8 +125,6 @@ void ChatForm::onSendTriggered()
QList<CString> splittedMsg = Core::splitMessage(msg, TOX_MAX_MESSAGE_LENGTH);
QDateTime timestamp = QDateTime::currentDateTime();
msgEdit->setLastMessage(msg); //set last message only when sending it
bool status = !Settings::getInstance().getFauxOfflineMessaging();
for (CString& c_msg : splittedMsg)
@ -298,7 +298,7 @@ void ChatForm::onAvInvite(uint32_t FriendId, int CallId, bool video)
}
callButton->style()->polish(callButton);
videoButton->style()->polish(videoButton);
insertChatMessage(ChatMessage::createChatInfoMessage(tr("%1 calling").arg(f->getDisplayedName()), ChatMessage::INFO, QDateTime::currentDateTime()));
Widget* w = Widget::getInstance();
@ -357,7 +357,7 @@ void ChatForm::onAvStart(uint32_t FriendId, int CallId, bool video)
this, SLOT(onMicMuteToggle()));
connect(volButton, SIGNAL(clicked()),
this, SLOT(onVolMuteToggle()));
startCounter();
}
@ -375,7 +375,7 @@ void ChatForm::onAvCancel(uint32_t FriendId, int)
stopCounter();
netcam->hide();
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)
{
{
if (FriendId != f->getFriendID())
return;
@ -426,7 +426,7 @@ void ChatForm::onAvRinging(uint32_t FriendId, int CallId, bool video)
connect(callButton, SIGNAL(clicked()),
this, SLOT(onCancelCallTriggered()));
}
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("");
connect(callButton, SIGNAL(clicked()), this, SLOT(onHangupCallTriggered()));
}
startCounter();
}
@ -477,7 +477,7 @@ void ChatForm::onAvEnding(uint32_t FriendId, int)
enableCallButtons();
stopCounter();
netcam->hide();
}
@ -493,7 +493,7 @@ void ChatForm::onAvRequestTimeout(uint32_t FriendId, int)
enableCallButtons();
stopCounter();
netcam->hide();
}
@ -506,10 +506,10 @@ void ChatForm::onAvPeerTimeout(uint32_t FriendId, int)
delete callConfirm;
callConfirm = nullptr;
enableCallButtons();
stopCounter();
netcam->hide();
}
@ -524,7 +524,7 @@ void ChatForm::onAvRejected(uint32_t FriendId, int)
callConfirm = nullptr;
enableCallButtons();
insertChatMessage(ChatMessage::createChatInfoMessage(tr("Call rejected"), ChatMessage::INFO, QDateTime::currentDateTime()));
netcam->hide();
@ -586,7 +586,7 @@ void ChatForm::onRejectCallTriggered()
audioInputFlag = false;
audioOutputFlag = false;
emit rejectCall(callId);
enableCallButtons();
}
@ -638,19 +638,19 @@ void ChatForm::onCancelCallTriggered()
void ChatForm::enableCallButtons()
{
qDebug() << "enableCallButtons";
audioInputFlag = false;
audioOutputFlag = false;
micButton->setObjectName("grey");
micButton->style()->polish(micButton);
micButton->setToolTip("");
micButton->disconnect();
micButton->disconnect();
volButton->setObjectName("grey");
volButton->style()->polish(volButton);
volButton->setToolTip("");
volButton->disconnect();
callButton->setObjectName("grey");
callButton->style()->polish(callButton);
callButton->setToolTip("");
@ -659,7 +659,7 @@ void ChatForm::enableCallButtons()
videoButton->style()->polish(videoButton);
videoButton->setToolTip("");
videoButton->disconnect();
if(disableCallButtonsTimer == nullptr)
{
disableCallButtonsTimer = new QTimer();
@ -668,7 +668,7 @@ void ChatForm::enableCallButtons()
disableCallButtonsTimer->start(1500); // 1.5sec
qDebug() << "timer started!!";
}
}
void ChatForm::onEnableCallButtons()
@ -683,7 +683,7 @@ void ChatForm::onEnableCallButtons()
videoButton->setObjectName("green");
videoButton->style()->polish(videoButton);
videoButton->setToolTip(tr("Start video call"));
connect(callButton, SIGNAL(clicked()),
this, SLOT(onCallTriggered()));
connect(videoButton, SIGNAL(clicked()),
@ -824,7 +824,7 @@ void ChatForm::loadHistory(QDateTime since, bool processUndelivered)
// Show the date every new day
QDateTime msgDateTime = it.timestamp.toLocalTime();
QDate msgDate = msgDateTime.date();
if (msgDate > lastDate)
{
lastDate = msgDate;
@ -860,7 +860,7 @@ void ChatForm::loadHistory(QDateTime since, bool processUndelivered)
rec = Core::getInstance()->sendMessage(f->getFriendID(), msg->toString());
else
rec = Core::getInstance()->sendAction(f->getFriendID(), msg->toString());
getOfflineMsgEngine()->registerReceipt(rec, it.id, msg);
}
}
@ -910,7 +910,7 @@ void ChatForm::stopCounter()
callDurationTimer->stop();
callDuration->setText("");
callDuration->hide();
delete callDurationTimer;
callDurationTimer = nullptr;
}
@ -931,13 +931,13 @@ QString ChatForm::secondsToDHMS(quint32 duration)
duration /= 60;
int hours = (int) (duration % 24);
int days = (int) (duration / 24);
if (minutes == 0)
return cD + res.sprintf("%02ds", seconds);
if (hours == 0 && days == 0)
return cD + res.sprintf("%02dm %02ds", minutes, seconds);
if (days == 0)
return cD + res.sprintf("%02dh %02dm %02ds", hours, minutes, seconds);
//I assume no one will ever have call longer than ~30days

View File

@ -65,14 +65,14 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
namesListLayout = new FlowLayout(0,5,0);
QStringList names(group->getPeerList());
QLabel *l;
for (const QString& name : names)
{
l = new QLabel(name);
l->setTextFormat(Qt::PlainText);
namesListLayout->addWidget(l);
}
headTextLayout->addWidget(nusersLabel);
headTextLayout->addLayout(namesListLayout);
headTextLayout->addStretch();
@ -116,7 +116,10 @@ void GroupChatForm::onSendTriggered()
}
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);
}
}

View File

@ -737,7 +737,7 @@ void Widget::onFriendMessageReceived(int friendId, const QString& message, bool
QDateTime timestamp = QDateTime::currentDateTime();
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->setEventFlag(f->getFriendWidget() != activeChatroomWidget);