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

Add_www_link_possibility

This commit is contained in:
PKEv 2015-04-12 21:24:33 +03:00 committed by tux3
parent d697e06b56
commit 91c192487a
2 changed files with 45 additions and 35 deletions

View File

@ -115,41 +115,7 @@ void ChatForm::setStatusMessage(QString newMessage)
void ChatForm::onSendTriggered()
{
QString msg = msgEdit->toPlainText();
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);
QList<CString> splittedMsg = Core::splitMessage(msg, TOX_MAX_MESSAGE_LENGTH);
QDateTime timestamp = QDateTime::currentDateTime();
bool status = !Settings::getInstance().getFauxOfflineMessaging();
for (CString& c_msg : splittedMsg)
{
QString qt_msg = CString::toString(c_msg.data(), c_msg.size());
QString qt_msg_hist = qt_msg;
if (isAction)
qt_msg_hist = "/me " + qt_msg;
int id = HistoryKeeper::getInstance()->addChatEntry(f->getToxID().publicKey, qt_msg_hist,
Core::getInstance()->getSelfId().publicKey, timestamp, status);
ChatMessage::Ptr ma = addSelfMessage(qt_msg, isAction, timestamp, false);
int rec;
if (isAction)
rec = Core::getInstance()->sendAction(f->getFriendID(), qt_msg);
else
rec = Core::getInstance()->sendMessage(f->getFriendID(), qt_msg);
getOfflineMsgEngine()->registerReceipt(rec, id, ma);
}
SendMessageStr(msgEdit->toPlainText());
msgEdit->clear();
}
@ -768,6 +734,11 @@ void ChatForm::dropEvent(QDropEvent *ev)
QFileInfo info(url.path());
QFile file(info.absoluteFilePath());
if (url.isValid() && !url.isLocalFile() && (url.toString().length() < TOX_MAX_MESSAGE_LENGTH))
{
SendMessageStr(url.toString());
continue;
}
if (!file.exists() || !file.open(QIODevice::ReadOnly))
{
info.setFile(url.toLocalFile());
@ -981,3 +952,41 @@ OfflineMsgEngine *ChatForm::getOfflineMsgEngine()
{
return offlineEngine;
}
void ChatForm::SendMessageStr(QString msg)
{
if (msg.isEmpty())
return;
bool isAction = msg.startsWith("/me ");
if (isAction)
msg = msg = msg.right(msg.length() - 4);
QList<CString> splittedMsg = Core::splitMessage(msg, TOX_MAX_MESSAGE_LENGTH);
QDateTime timestamp = QDateTime::currentDateTime();
for (CString& c_msg : splittedMsg)
{
QString qt_msg = CString::toString(c_msg.data(), c_msg.size());
QString qt_msg_hist = qt_msg;
if (isAction)
qt_msg_hist = "/me " + qt_msg;
bool status = !Settings::getInstance().getFauxOfflineMessaging();
int id = HistoryKeeper::getInstance()->addChatEntry(f->getToxID().publicKey, qt_msg_hist,
Core::getInstance()->getSelfId().publicKey, timestamp, status);
ChatMessage::Ptr ma = addSelfMessage(msg, isAction, timestamp, false);
int rec;
if (isAction)
rec = Core::getInstance()->sendAction(f->getFriendID(), qt_msg);
else
rec = Core::getInstance()->sendMessage(f->getFriendID(), qt_msg);
getOfflineMsgEngine()->registerReceipt(rec, id, ma);
msgEdit->setLastMessage(msg); //set last message only when sending it
}
}

View File

@ -121,6 +121,7 @@ private:
CallConfirmWidget *callConfirm;
void enableCallButtons();
bool isTyping;
void SendMessageStr(QString msg);
};
#endif // CHATFORM_H