mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor(friend): Small refactoring
Method renamed to be same with `Group` i.e. `getGroupId`, changed Friend eventFlag type on bool
This commit is contained in:
parent
6bad4ad3ba
commit
29bb319025
|
@ -175,8 +175,8 @@ bool CoreAV::anyActiveCalls() const
|
|||
*/
|
||||
bool CoreAV::isCallActive(const Friend* f) const
|
||||
{
|
||||
return f && calls.contains(f->getFriendID())
|
||||
? !(calls[f->getFriendID()].inactive)
|
||||
return f && calls.contains(f->getFriendId())
|
||||
? !(calls[f->getFriendId()].inactive)
|
||||
: false;
|
||||
}
|
||||
|
||||
|
@ -194,8 +194,8 @@ bool CoreAV::isCallActive(const Group* g) const
|
|||
|
||||
bool CoreAV::isCallVideoEnabled(const Friend* f) const
|
||||
{
|
||||
return f && calls.contains(f->getFriendID())
|
||||
? calls[f->getFriendID()].videoEnabled
|
||||
return f && calls.contains(f->getFriendId())
|
||||
? calls[f->getFriendId()].videoEnabled
|
||||
: false;
|
||||
}
|
||||
|
||||
|
@ -422,9 +422,9 @@ void CoreAV::sendCallVideo(uint32_t callId, std::shared_ptr<VideoFrame> vframe)
|
|||
*/
|
||||
void CoreAV::toggleMuteCallInput(const Friend* f)
|
||||
{
|
||||
if (f && calls.contains(f->getFriendID()))
|
||||
if (f && calls.contains(f->getFriendId()))
|
||||
{
|
||||
ToxCall& call = calls[f->getFriendID()];
|
||||
ToxCall& call = calls[f->getFriendId()];
|
||||
call.muteMic = !call.muteMic;
|
||||
}
|
||||
}
|
||||
|
@ -435,9 +435,9 @@ void CoreAV::toggleMuteCallInput(const Friend* f)
|
|||
*/
|
||||
void CoreAV::toggleMuteCallOutput(const Friend* f)
|
||||
{
|
||||
if (f && calls.contains(f->getFriendID()))
|
||||
if (f && calls.contains(f->getFriendId()))
|
||||
{
|
||||
ToxCall& call = calls[f->getFriendID()];
|
||||
ToxCall& call = calls[f->getFriendId()];
|
||||
call.muteVol = !call.muteVol;
|
||||
}
|
||||
}
|
||||
|
@ -618,8 +618,8 @@ bool CoreAV::isGroupAvEnabled(int groupId) const
|
|||
*/
|
||||
bool CoreAV::isCallInputMuted(const Friend* f) const
|
||||
{
|
||||
return f && calls.contains(f->getFriendID())
|
||||
? calls[f->getFriendID()].muteMic
|
||||
return f && calls.contains(f->getFriendId())
|
||||
? calls[f->getFriendId()].muteMic
|
||||
: false;
|
||||
}
|
||||
|
||||
|
@ -630,8 +630,8 @@ bool CoreAV::isCallInputMuted(const Friend* f) const
|
|||
*/
|
||||
bool CoreAV::isCallOutputMuted(const Friend* f) const
|
||||
{
|
||||
return f && calls.contains(f->getFriendID())
|
||||
? calls[f->getFriendID()].muteVol
|
||||
return f && calls.contains(f->getFriendId())
|
||||
? calls[f->getFriendId()].muteVol
|
||||
: false;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,8 @@
|
|||
|
||||
|
||||
#include "friend.h"
|
||||
#include "friendlist.h"
|
||||
#include "widget/friendwidget.h"
|
||||
#include "widget/form/chatform.h"
|
||||
#include "widget/friendwidget.h"
|
||||
#include "widget/gui.h"
|
||||
#include "src/core/core.h"
|
||||
#include "src/persistence/settings.h"
|
||||
|
@ -30,16 +29,20 @@
|
|||
#include "src/grouplist.h"
|
||||
#include "src/group.h"
|
||||
|
||||
Friend::Friend(uint32_t FriendId, const ToxPk& FriendPk)
|
||||
: userName{Core::getInstance()->getPeerName(FriendPk)}
|
||||
, friendPk(FriendPk), friendId(FriendId)
|
||||
, hasNewEvents(0), friendStatus(Status::Offline)
|
||||
|
||||
Friend::Friend(uint32_t friendId, const ToxPk& friendPk)
|
||||
: userName{Core::getInstance()->getPeerName(friendPk)}
|
||||
, userAlias(Settings::getInstance().getFriendAlias(friendPk))
|
||||
, friendPk(friendPk)
|
||||
, friendId(friendId)
|
||||
, hasNewEvents(false)
|
||||
, friendStatus(Status::Offline)
|
||||
{
|
||||
if (userName.size() == 0)
|
||||
userName = FriendPk.toString();
|
||||
if (userName.isEmpty())
|
||||
{
|
||||
userName = friendPk.toString();
|
||||
}
|
||||
|
||||
userAlias = Settings::getInstance().getFriendAlias(FriendPk);
|
||||
userAlias = Settings::getInstance().getFriendAlias(friendPk);
|
||||
|
||||
chatForm = new ChatForm(this);
|
||||
}
|
||||
|
@ -129,17 +132,17 @@ const ToxPk& Friend::getPublicKey() const
|
|||
return friendPk;
|
||||
}
|
||||
|
||||
uint32_t Friend::getFriendID() const
|
||||
uint32_t Friend::getFriendId() const
|
||||
{
|
||||
return friendId;
|
||||
}
|
||||
|
||||
void Friend::setEventFlag(int f)
|
||||
void Friend::setEventFlag(bool flag)
|
||||
{
|
||||
hasNewEvents = f;
|
||||
hasNewEvents = flag;
|
||||
}
|
||||
|
||||
int Friend::getEventFlag() const
|
||||
bool Friend::getEventFlag() const
|
||||
{
|
||||
return hasNewEvents;
|
||||
}
|
||||
|
|
12
src/friend.h
12
src/friend.h
|
@ -47,11 +47,11 @@ public:
|
|||
void setStatusMessage(QString message);
|
||||
QString getStatusMessage();
|
||||
|
||||
void setEventFlag(int f);
|
||||
int getEventFlag() const;
|
||||
void setEventFlag(bool f);
|
||||
bool getEventFlag() const;
|
||||
|
||||
const ToxPk& getPublicKey() const;
|
||||
uint32_t getFriendID() const;
|
||||
uint32_t getFriendId() const;
|
||||
|
||||
void setStatus(Status s);
|
||||
Status getStatus() const;
|
||||
|
@ -66,10 +66,12 @@ signals:
|
|||
void displayedNameChanged(FriendWidget* widget, Status s, int hasNewEvents);
|
||||
|
||||
private:
|
||||
QString userAlias, userName, statusMessage;
|
||||
QString userName;
|
||||
QString userAlias;
|
||||
QString statusMessage;
|
||||
ToxPk friendPk;
|
||||
uint32_t friendId;
|
||||
int hasNewEvents;
|
||||
bool hasNewEvents;
|
||||
Status friendStatus;
|
||||
|
||||
FriendWidget* widget;
|
||||
|
|
|
@ -107,9 +107,13 @@ void OfflineMsgEngine::deliverOfflineMsgs()
|
|||
QString messageText = val.msg->toString();
|
||||
int rec;
|
||||
if (val.msg->isAction())
|
||||
rec = Core::getInstance()->sendAction(f->getFriendID(), messageText);
|
||||
{
|
||||
rec = Core::getInstance()->sendAction(f->getFriendId(), messageText);
|
||||
}
|
||||
else
|
||||
rec = Core::getInstance()->sendMessage(f->getFriendID(), messageText);
|
||||
{
|
||||
rec = Core::getInstance()->sendMessage(f->getFriendId(), messageText);
|
||||
}
|
||||
|
||||
registerReceipt(rec, key, val.msg);
|
||||
}
|
||||
|
|
|
@ -545,7 +545,7 @@ void ContentDialog::dragEnterEvent(QDragEnterEvent *event)
|
|||
if (!contact)
|
||||
return;
|
||||
|
||||
int friendId = contact->getFriendID();
|
||||
int friendId = contact->getFriendId();
|
||||
auto iter = friendList.find(friendId);
|
||||
|
||||
// If friend is already in a dialog then you can't drop friend where it already is.
|
||||
|
@ -580,7 +580,7 @@ void ContentDialog::dropEvent(QDropEvent *event)
|
|||
if (!contact)
|
||||
return;
|
||||
|
||||
int friendId = contact->getFriendID();
|
||||
int friendId = contact->getFriendId();
|
||||
auto iter = friendList.find(friendId);
|
||||
if (iter != friendList.end())
|
||||
std::get<0>(iter.value())->removeFriend(friendId);
|
||||
|
@ -644,7 +644,7 @@ void ContentDialog::onChatroomWidgetClicked(GenericChatroomWidget *widget, bool
|
|||
|
||||
if (widget->getFriend() != nullptr)
|
||||
{
|
||||
removeFriend(widget->getFriend()->getFriendID());
|
||||
removeFriend(widget->getFriend()->getFriendId());
|
||||
Widget::getInstance()->addFriendDialog(widget->getFriend(), contentDialog);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -160,7 +160,7 @@ ChatForm::ChatForm(Friend* chatFriend)
|
|||
});
|
||||
|
||||
connect(&typingTimer, &QTimer::timeout, this, [=] {
|
||||
Core::getInstance()->sendTyping(f->getFriendID(), false);
|
||||
Core::getInstance()->sendTyping(f->getFriendId(), false);
|
||||
isTyping = false;
|
||||
});
|
||||
|
||||
|
@ -200,7 +200,7 @@ void ChatForm::onTextEditChanged()
|
|||
if (!Settings::getInstance().getTypingNotification())
|
||||
{
|
||||
if (isTyping)
|
||||
Core::getInstance()->sendTyping(f->getFriendID(), false);
|
||||
Core::getInstance()->sendTyping(f->getFriendId(), false);
|
||||
|
||||
isTyping = false;
|
||||
return;
|
||||
|
@ -210,11 +210,11 @@ void ChatForm::onTextEditChanged()
|
|||
{
|
||||
typingTimer.start(3000);
|
||||
if (!isTyping)
|
||||
Core::getInstance()->sendTyping(f->getFriendID(), (isTyping = true));
|
||||
Core::getInstance()->sendTyping(f->getFriendId(), (isTyping = true));
|
||||
}
|
||||
else
|
||||
{
|
||||
Core::getInstance()->sendTyping(f->getFriendID(), (isTyping = false));
|
||||
Core::getInstance()->sendTyping(f->getFriendId(), (isTyping = false));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,14 +254,13 @@ void ChatForm::onAttachClicked()
|
|||
file.close();
|
||||
QFileInfo fi(path);
|
||||
|
||||
core->sendFile(f->getFriendID(), fi.fileName(), path,
|
||||
filesize);
|
||||
core->sendFile(f->getFriendId(), fi.fileName(), path, filesize);
|
||||
}
|
||||
}
|
||||
|
||||
void ChatForm::startFileSend(ToxFile file)
|
||||
{
|
||||
if (file.friendId != f->getFriendID())
|
||||
if (file.friendId != f->getFriendId())
|
||||
return;
|
||||
|
||||
QString name;
|
||||
|
@ -280,7 +279,7 @@ void ChatForm::startFileSend(ToxFile file)
|
|||
|
||||
void ChatForm::onFileRecvRequest(ToxFile file)
|
||||
{
|
||||
if (file.friendId != f->getFriendID())
|
||||
if (file.friendId != f->getFriendId())
|
||||
return;
|
||||
|
||||
Widget::getInstance()->newFriendMessageAlert(file.friendId);
|
||||
|
@ -315,7 +314,7 @@ void ChatForm::onFileRecvRequest(ToxFile file)
|
|||
|
||||
void ChatForm::onAvInvite(uint32_t friendId, bool video)
|
||||
{
|
||||
if (friendId != f->getFriendID())
|
||||
if (friendId != f->getFriendId())
|
||||
return;
|
||||
|
||||
callConfirm = new CallConfirmWidget(video ? videoButton : callButton, *f);
|
||||
|
@ -326,7 +325,7 @@ void ChatForm::onAvInvite(uint32_t friendId, bool video)
|
|||
if ((video && Settings::getInstance().getAutoAcceptCall(f->getPublicKey()).testFlag(Settings::AutoAcceptCall::Video)) ||
|
||||
(!video && Settings::getInstance().getAutoAcceptCall(f->getPublicKey()).testFlag(Settings::AutoAcceptCall::Audio)))
|
||||
{
|
||||
uint32_t friendId = f->getFriendID();
|
||||
uint32_t friendId = f->getFriendId();
|
||||
qDebug() << "automatic call answer";
|
||||
CoreAV* coreav = Core::getInstance()->getAv();
|
||||
QMetaObject::invokeMethod(coreav, "answerCall", Qt::QueuedConnection, Q_ARG(uint32_t, friendId));
|
||||
|
@ -355,7 +354,7 @@ void ChatForm::onAvInvite(uint32_t friendId, bool video)
|
|||
|
||||
void ChatForm::onAvStart(uint32_t FriendId, bool video)
|
||||
{
|
||||
if (FriendId != f->getFriendID())
|
||||
if (FriendId != f->getFriendId())
|
||||
return;
|
||||
|
||||
if (video)
|
||||
|
@ -369,7 +368,7 @@ void ChatForm::onAvStart(uint32_t FriendId, bool video)
|
|||
|
||||
void ChatForm::onAvEnd(uint32_t FriendId)
|
||||
{
|
||||
if (FriendId != f->getFriendID())
|
||||
if (FriendId != f->getFriendId())
|
||||
return;
|
||||
|
||||
delete callConfirm;
|
||||
|
@ -416,7 +415,7 @@ void ChatForm::onAnswerCallTriggered()
|
|||
updateCallButtons();
|
||||
|
||||
CoreAV* av = Core::getInstance()->getAv();
|
||||
if (!av->answerCall(f->getFriendID()))
|
||||
if (!av->answerCall(f->getFriendId()))
|
||||
{
|
||||
updateCallButtons();
|
||||
stopCounter();
|
||||
|
@ -424,7 +423,7 @@ void ChatForm::onAnswerCallTriggered()
|
|||
return;
|
||||
}
|
||||
|
||||
onAvStart(f->getFriendID(), av->isCallVideoEnabled(f));
|
||||
onAvStart(f->getFriendId(), av->isCallVideoEnabled(f));
|
||||
}
|
||||
|
||||
void ChatForm::onRejectCallTriggered()
|
||||
|
@ -434,7 +433,7 @@ void ChatForm::onRejectCallTriggered()
|
|||
Audio::getInstance().stopLoop();
|
||||
|
||||
CoreAV* av = Core::getInstance()->getAv();
|
||||
av->cancelCall(f->getFriendID());
|
||||
av->cancelCall(f->getFriendId());
|
||||
}
|
||||
|
||||
void ChatForm::onCallTriggered()
|
||||
|
@ -442,9 +441,9 @@ void ChatForm::onCallTriggered()
|
|||
CoreAV* av = Core::getInstance()->getAv();
|
||||
if (av->isCallActive(f))
|
||||
{
|
||||
av->cancelCall(f->getFriendID());
|
||||
av->cancelCall(f->getFriendId());
|
||||
}
|
||||
else if (av->startCall(f->getFriendID(), false))
|
||||
else if (av->startCall(f->getFriendId(), false))
|
||||
{
|
||||
showOutgoingCall(false);
|
||||
}
|
||||
|
@ -457,9 +456,11 @@ void ChatForm::onVideoCallTriggered()
|
|||
{
|
||||
// TODO: We want to activate video on the active call.
|
||||
if (av->isCallVideoEnabled(f))
|
||||
av->cancelCall(f->getFriendID());
|
||||
{
|
||||
av->cancelCall(f->getFriendId());
|
||||
}
|
||||
}
|
||||
else if (av->startCall(f->getFriendID(), true))
|
||||
else if (av->startCall(f->getFriendId(), true))
|
||||
{
|
||||
showOutgoingCall(true);
|
||||
}
|
||||
|
@ -523,7 +524,7 @@ void ChatForm::onVolMuteToggle()
|
|||
|
||||
void ChatForm::onFileSendFailed(uint32_t friendId, const QString &fname)
|
||||
{
|
||||
if (friendId != f->getFriendID())
|
||||
if (friendId != f->getFriendId())
|
||||
return;
|
||||
|
||||
addSystemInfoMessage(tr("Failed to send file \"%1\"").arg(fname), ChatMessage::ERROR, QDateTime::currentDateTime());
|
||||
|
@ -532,7 +533,7 @@ void ChatForm::onFileSendFailed(uint32_t friendId, const QString &fname)
|
|||
void ChatForm::onFriendStatusChanged(uint32_t friendId, Status status)
|
||||
{
|
||||
// Disable call buttons if friend is offline
|
||||
if(friendId != f->getFriendID())
|
||||
if(friendId != f->getFriendId())
|
||||
return;
|
||||
|
||||
if (status == Status::Offline)
|
||||
|
@ -570,7 +571,7 @@ void ChatForm::onFriendStatusChanged(uint32_t friendId, Status status)
|
|||
|
||||
void ChatForm::onFriendTypingChanged(quint32 friendId, bool isTyping)
|
||||
{
|
||||
if (friendId == f->getFriendID())
|
||||
if (friendId == f->getFriendId())
|
||||
setFriendTyping(isTyping);
|
||||
}
|
||||
|
||||
|
@ -583,8 +584,10 @@ void ChatForm::onFriendNameChanged(const QString& name)
|
|||
void ChatForm::onFriendMessageReceived(quint32 friendId, const QString& message,
|
||||
bool isAction)
|
||||
{
|
||||
if (friendId != f->getFriendID())
|
||||
if (friendId != f->getFriendId())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QDateTime timestamp = QDateTime::currentDateTime();
|
||||
addMessage(f->getPublicKey(), message, isAction, timestamp, true);
|
||||
|
@ -593,19 +596,25 @@ void ChatForm::onFriendMessageReceived(quint32 friendId, const QString& message,
|
|||
void ChatForm::onStatusMessage(const QString& message)
|
||||
{
|
||||
if (sender() == f)
|
||||
{
|
||||
setStatusMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
void ChatForm::onReceiptReceived(quint32 friendId, int receipt)
|
||||
{
|
||||
if (friendId == f->getFriendID())
|
||||
if (friendId == f->getFriendId())
|
||||
{
|
||||
f->getChatForm()->getOfflineMsgEngine()->dischargeReceipt(receipt);
|
||||
}
|
||||
}
|
||||
|
||||
void ChatForm::onAvatarChange(uint32_t friendId, const QPixmap &pic)
|
||||
{
|
||||
if (friendId != f->getFriendID())
|
||||
if (friendId != f->getFriendId())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
avatar->setPixmap(pic);
|
||||
}
|
||||
|
@ -613,15 +622,19 @@ void ChatForm::onAvatarChange(uint32_t friendId, const QPixmap &pic)
|
|||
GenericNetCamView *ChatForm::createNetcam()
|
||||
{
|
||||
qDebug() << "creating netcam";
|
||||
NetCamView* view = new NetCamView(f->getFriendID(), this);
|
||||
view->show(Core::getInstance()->getAv()->getVideoSourceFromCall(f->getFriendID()), f->getDisplayedName());
|
||||
uint32_t friendId = f->getFriendId();
|
||||
NetCamView* view = new NetCamView(friendId, this);
|
||||
CoreAV* av = Core::getInstance()->getAv();
|
||||
view->show(av->getVideoSourceFromCall(friendId), f->getDisplayedName());
|
||||
return view;
|
||||
}
|
||||
|
||||
void ChatForm::dragEnterEvent(QDragEnterEvent *ev)
|
||||
{
|
||||
if (ev->mimeData()->hasUrls())
|
||||
{
|
||||
ev->acceptProposedAction();
|
||||
}
|
||||
}
|
||||
|
||||
void ChatForm::dropEvent(QDropEvent *ev)
|
||||
|
@ -665,15 +678,17 @@ void ChatForm::dropEvent(QDropEvent *ev)
|
|||
file.close();
|
||||
|
||||
if (info.exists())
|
||||
core->sendFile(f->getFriendID(), info.fileName(),
|
||||
{
|
||||
core->sendFile(f->getFriendId(), info.fileName(),
|
||||
info.absoluteFilePath(), info.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChatForm::onAvatarRemoved(uint32_t FriendId)
|
||||
{
|
||||
if (FriendId != f->getFriendID())
|
||||
if (FriendId != f->getFriendId())
|
||||
return;
|
||||
|
||||
avatar->setPixmap(QPixmap(":/img/contact_dark.svg"));
|
||||
|
@ -781,9 +796,9 @@ void ChatForm::loadHistory(QDateTime since, bool processUndelivered)
|
|||
{
|
||||
int rec;
|
||||
if (!isAction)
|
||||
rec = Core::getInstance()->sendMessage(f->getFriendID(), msg->toString());
|
||||
rec = Core::getInstance()->sendMessage(f->getFriendId(), msg->toString());
|
||||
else
|
||||
rec = Core::getInstance()->sendAction(f->getFriendID(), msg->toString());
|
||||
rec = Core::getInstance()->sendAction(f->getFriendId(), msg->toString());
|
||||
|
||||
getOfflineMsgEngine()->registerReceipt(rec, it.id, msg);
|
||||
}
|
||||
|
@ -844,13 +859,14 @@ void ChatForm::onScreenshotTaken(const QPixmap &pixmap) {
|
|||
file.close();
|
||||
QFileInfo fi(file);
|
||||
|
||||
Core::getInstance()->sendFile(f->getFriendID(), fi.fileName(),
|
||||
Core::getInstance()->sendFile(f->getFriendId(), fi.fileName(),
|
||||
fi.filePath(), filesize);
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::warning(this,
|
||||
tr("Failed to open temporary file", "Temporary file for screenshot"),
|
||||
tr("Failed to open temporary file",
|
||||
"Temporary file for screenshot"),
|
||||
tr("qTox wasn't able to save the screenshot"));
|
||||
}
|
||||
}
|
||||
|
@ -858,7 +874,9 @@ void ChatForm::onScreenshotTaken(const QPixmap &pixmap) {
|
|||
void ChatForm::onLoadHistory()
|
||||
{
|
||||
if (!Nexus::getProfile()->isHistoryEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LoadHistoryDialog dlg;
|
||||
|
||||
|
@ -874,7 +892,9 @@ void ChatForm::insertChatMessage(ChatMessage::Ptr msg)
|
|||
GenericChatForm::insertChatMessage(msg);
|
||||
|
||||
if (netcam && bodySplitter->sizes()[1] == 0)
|
||||
{
|
||||
netcam->setShowMessages(true, true);
|
||||
}
|
||||
}
|
||||
|
||||
void ChatForm::onCopyStatusMessage()
|
||||
|
@ -942,6 +962,7 @@ void ChatForm::startCounter()
|
|||
callDurationTimer = new QTimer();
|
||||
connect(callDurationTimer, &QTimer::timeout,
|
||||
this, &ChatForm::onUpdateTime);
|
||||
|
||||
callDurationTimer->start(1000);
|
||||
timeElapsed.start();
|
||||
callDuration->show();
|
||||
|
@ -952,8 +973,11 @@ void ChatForm::stopCounter()
|
|||
{
|
||||
if (callDurationTimer)
|
||||
{
|
||||
addSystemInfoMessage(tr("Call with %1 ended. %2").arg(f->getDisplayedName(),secondsToDHMS(timeElapsed.elapsed()/1000)),
|
||||
QString dhms = secondsToDHMS(timeElapsed.elapsed()/1000);
|
||||
QString name = f->getDisplayedName();
|
||||
addSystemInfoMessage(tr("Call with %1 ended. %2").arg(name, dhms),
|
||||
ChatMessage::INFO, QDateTime::currentDateTime());
|
||||
|
||||
callDurationTimer->stop();
|
||||
callDuration->setText("");
|
||||
callDuration->hide();
|
||||
|
@ -995,7 +1019,8 @@ void ChatForm::setFriendTyping(bool isTyping)
|
|||
chatWidget->setTypingNotificationVisible(isTyping);
|
||||
|
||||
Text* text = static_cast<Text*>(chatWidget->getTypingNotification()->getContent(1));
|
||||
text->setText("<div class=typing>" + tr("%1 is typing").arg(f->getDisplayedName().toHtmlEscaped()) + "</div>");
|
||||
QString name = f->getDisplayedName();
|
||||
text->setText("<div class=typing>" + tr("%1 is typing").arg(name) + "</div>");
|
||||
}
|
||||
|
||||
void ChatForm::show(ContentLayout* contentLayout)
|
||||
|
@ -1003,13 +1028,17 @@ void ChatForm::show(ContentLayout* contentLayout)
|
|||
GenericChatForm::show(contentLayout);
|
||||
|
||||
if (callConfirm)
|
||||
{
|
||||
callConfirm->show();
|
||||
}
|
||||
}
|
||||
|
||||
void ChatForm::showEvent(QShowEvent* event)
|
||||
{
|
||||
if (callConfirm)
|
||||
{
|
||||
callConfirm->show();
|
||||
}
|
||||
|
||||
GenericChatForm::showEvent(event);
|
||||
}
|
||||
|
@ -1017,7 +1046,9 @@ void ChatForm::showEvent(QShowEvent* event)
|
|||
void ChatForm::hideEvent(QHideEvent* event)
|
||||
{
|
||||
if (callConfirm)
|
||||
{
|
||||
callConfirm->hide();
|
||||
}
|
||||
|
||||
GenericChatForm::hideEvent(event);
|
||||
}
|
||||
|
@ -1030,11 +1061,15 @@ OfflineMsgEngine *ChatForm::getOfflineMsgEngine()
|
|||
void ChatForm::SendMessageStr(QString msg)
|
||||
{
|
||||
if (msg.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool isAction = msg.startsWith(ACTION_PREFIX, Qt::CaseInsensitive);
|
||||
if (isAction)
|
||||
{
|
||||
msg.remove(0, ACTION_PREFIX.length());
|
||||
}
|
||||
|
||||
QList<CString> splittedMsg = Core::splitMessage(msg, TOX_MAX_MESSAGE_LENGTH);
|
||||
QDateTime timestamp = QDateTime::currentDateTime();
|
||||
|
@ -1044,7 +1079,9 @@ void ChatForm::SendMessageStr(QString msg)
|
|||
QString qt_msg = CString::toString(c_msg.data(), c_msg.size());
|
||||
QString qt_msg_hist = qt_msg;
|
||||
if (isAction)
|
||||
{
|
||||
qt_msg_hist = ACTION_PREFIX + qt_msg;
|
||||
}
|
||||
|
||||
bool status = !Settings::getInstance().getFauxOfflineMessaging();
|
||||
|
||||
|
@ -1052,9 +1089,9 @@ void ChatForm::SendMessageStr(QString msg)
|
|||
|
||||
int rec;
|
||||
if (isAction)
|
||||
rec = Core::getInstance()->sendAction(f->getFriendID(), qt_msg);
|
||||
rec = Core::getInstance()->sendAction(f->getFriendId(), qt_msg);
|
||||
else
|
||||
rec = Core::getInstance()->sendMessage(f->getFriendID(), qt_msg);
|
||||
rec = Core::getInstance()->sendMessage(f->getFriendId(), qt_msg);
|
||||
|
||||
|
||||
Profile* profile = Nexus::getProfile();
|
||||
|
|
|
@ -295,7 +295,7 @@ void GroupChatForm::dropEvent(QDropEvent *ev)
|
|||
if (!frnd)
|
||||
return;
|
||||
|
||||
int friendId = frnd->getFriendID();
|
||||
int friendId = frnd->getFriendId();
|
||||
int groupId = group->getGroupId();
|
||||
Core::getInstance()->groupInviteFriend(friendId, groupId);
|
||||
}
|
||||
|
|
|
@ -295,21 +295,21 @@ void FriendWidget::updateStatusLight()
|
|||
Friend* f = FriendList::findFriend(friendId);
|
||||
Status status = f->getStatus();
|
||||
|
||||
if (status == Status::Online && f->getEventFlag() == 0)
|
||||
if (status == Status::Online && !f->getEventFlag())
|
||||
statusPic.setPixmap(QPixmap(":img/status/dot_online.svg"));
|
||||
else if (status == Status::Online && f->getEventFlag() == 1)
|
||||
else if (status == Status::Online && f->getEventFlag())
|
||||
statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.svg"));
|
||||
else if (status == Status::Away && f->getEventFlag() == 0)
|
||||
else if (status == Status::Away && !f->getEventFlag())
|
||||
statusPic.setPixmap(QPixmap(":img/status/dot_away.svg"));
|
||||
else if (status == Status::Away && f->getEventFlag() == 1)
|
||||
else if (status == Status::Away && f->getEventFlag())
|
||||
statusPic.setPixmap(QPixmap(":img/status/dot_away_notification.svg"));
|
||||
else if (status == Status::Busy && f->getEventFlag() == 0)
|
||||
else if (status == Status::Busy && !f->getEventFlag())
|
||||
statusPic.setPixmap(QPixmap(":img/status/dot_busy.svg"));
|
||||
else if (status == Status::Busy && f->getEventFlag() == 1)
|
||||
else if (status == Status::Busy && f->getEventFlag())
|
||||
statusPic.setPixmap(QPixmap(":img/status/dot_busy_notification.svg"));
|
||||
else if (status == Status::Offline && f->getEventFlag() == 0)
|
||||
else if (status == Status::Offline && !f->getEventFlag())
|
||||
statusPic.setPixmap(QPixmap(":img/status/dot_offline.svg"));
|
||||
else if (status == Status::Offline && f->getEventFlag() == 1)
|
||||
else if (status == Status::Offline && f->getEventFlag())
|
||||
statusPic.setPixmap(QPixmap(":img/status/dot_offline_notification.svg"));
|
||||
|
||||
if (f->getEventFlag())
|
||||
|
@ -332,7 +332,7 @@ QString FriendWidget::getStatusString() const
|
|||
Friend* f = FriendList::findFriend(friendId);
|
||||
Status status = f->getStatus();
|
||||
|
||||
if (f->getEventFlag() == 1)
|
||||
if (f->getEventFlag())
|
||||
return tr("New message");
|
||||
else if (status == Status::Online)
|
||||
return tr("Online");
|
||||
|
|
|
@ -257,7 +257,7 @@ void GroupWidget::dropEvent(QDropEvent *ev)
|
|||
if (!frnd)
|
||||
return;
|
||||
|
||||
int friendId = frnd->getFriendID();
|
||||
int friendId = frnd->getFriendId();
|
||||
Core::getInstance()->groupInviteFriend(friendId, groupId);
|
||||
|
||||
if (!active)
|
||||
|
|
|
@ -1253,16 +1253,16 @@ void Widget::onReceiptRecieved(int friendId, int receipt)
|
|||
|
||||
void Widget::addFriendDialog(Friend *frnd, ContentDialog *dialog)
|
||||
{
|
||||
ContentDialog *contentDialog = ContentDialog::getFriendDialog(frnd->getFriendID());
|
||||
ContentDialog *contentDialog = ContentDialog::getFriendDialog(frnd->getFriendId());
|
||||
bool isSeparate = Settings::getInstance().getSeparateWindow();
|
||||
FriendWidget* widget = friendWidgets[frnd->getFriendID()];
|
||||
|
||||
if (!contentDialog && !isSeparate && activeChatroomWidget == widget)
|
||||
FriendWidget* widget = friendWidgets[frnd->getFriendId()];
|
||||
bool isCurrent = activeChatroomWidget == widget;
|
||||
if (!contentDialog && !isSeparate && isCurrent)
|
||||
{
|
||||
onAddClicked();
|
||||
}
|
||||
|
||||
FriendWidget* friendWidget = dialog->addFriend(frnd->getFriendID(), frnd->getDisplayedName());
|
||||
FriendWidget* friendWidget = dialog->addFriend(frnd->getFriendId(), frnd->getDisplayedName());
|
||||
|
||||
friendWidget->setStatusMsg(widget->getStatusMsg());
|
||||
|
||||
|
@ -1280,7 +1280,7 @@ void Widget::addFriendDialog(Friend *frnd, ContentDialog *dialog)
|
|||
QPixmap avatar = Nexus::getProfile()->loadAvatar(frnd->getPublicKey().toString());
|
||||
if (!avatar.isNull())
|
||||
{
|
||||
friendWidget->onAvatarChange(frnd->getFriendID(), avatar);
|
||||
friendWidget->onAvatarChange(frnd->getFriendId(), avatar);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1289,7 +1289,8 @@ void Widget::addGroupDialog(Group *group, ContentDialog *dialog)
|
|||
int groupId = group->getGroupId();
|
||||
ContentDialog* groupDialog = ContentDialog::getGroupDialog(groupId);
|
||||
bool separated = Settings::getInstance().getSeparateWindow();
|
||||
bool isCurrentWindow = activeChatroomWidget == group->getGroupWidget();
|
||||
GroupWidget* widget = group->getGroupWidget();
|
||||
bool isCurrentWindow = activeChatroomWidget == widget;
|
||||
if (!groupDialog && !separated && isCurrentWindow)
|
||||
{
|
||||
onAddClicked();
|
||||
|
@ -1479,13 +1480,15 @@ void Widget::onFriendRequestReceived(const ToxPk& friendPk, const QString& messa
|
|||
|
||||
void Widget::updateFriendActivity(Friend *frnd)
|
||||
{
|
||||
QDate date = Settings::getInstance().getFriendActivity(frnd->getPublicKey());
|
||||
const ToxPk &pk = frnd->getPublicKey();
|
||||
QDate date = Settings::getInstance().getFriendActivity(pk);
|
||||
if (date != QDate::currentDate())
|
||||
{
|
||||
// Update old activity before after new one. Store old date first.
|
||||
QDate oldDate = Settings::getInstance().getFriendActivity(frnd->getPublicKey());
|
||||
Settings::getInstance().setFriendActivity(frnd->getPublicKey(), QDate::currentDate());
|
||||
contactListWidget->moveWidget(friendWidgets[frnd->getFriendID()], frnd->getStatus());
|
||||
QDate oldDate = Settings::getInstance().getFriendActivity(pk);
|
||||
Settings::getInstance().setFriendActivity(pk, QDate::currentDate());
|
||||
FriendWidget* widget = friendWidgets[frnd->getFriendId()];
|
||||
contactListWidget->moveWidget(widget, frnd->getStatus());
|
||||
contactListWidget->updateActivityDate(oldDate);
|
||||
}
|
||||
}
|
||||
|
@ -1508,7 +1511,7 @@ void Widget::removeFriend(Friend* f, bool fake)
|
|||
}
|
||||
}
|
||||
|
||||
FriendWidget *widget = friendWidgets[f->getFriendID()];
|
||||
FriendWidget *widget = friendWidgets[f->getFriendId()];
|
||||
widget->setAsInactiveChatroom();
|
||||
if (widget == activeChatroomWidget)
|
||||
{
|
||||
|
@ -1518,15 +1521,15 @@ void Widget::removeFriend(Friend* f, bool fake)
|
|||
|
||||
contactListWidget->removeFriendWidget(widget);
|
||||
|
||||
ContentDialog* lastDialog = ContentDialog::getFriendDialog(f->getFriendID());
|
||||
ContentDialog* lastDialog = ContentDialog::getFriendDialog(f->getFriendId());
|
||||
|
||||
if (lastDialog != nullptr)
|
||||
{
|
||||
lastDialog->removeFriend(f->getFriendID());
|
||||
lastDialog->removeFriend(f->getFriendId());
|
||||
}
|
||||
|
||||
FriendList::removeFriend(f->getFriendID(), fake);
|
||||
Nexus::getCore()->removeFriend(f->getFriendID(), fake);
|
||||
FriendList::removeFriend(f->getFriendId(), fake);
|
||||
Nexus::getCore()->removeFriend(f->getFriendId(), fake);
|
||||
|
||||
delete f;
|
||||
if (contentLayout != nullptr && contentLayout->mainHead->layout()->isEmpty())
|
||||
|
@ -1570,7 +1573,7 @@ void Widget::onDialogShown(GenericChatroomWidget* widget)
|
|||
|
||||
void Widget::onFriendDialogShown(Friend* f)
|
||||
{
|
||||
int friendId = f->getFriendID();
|
||||
int friendId = f->getFriendId();
|
||||
onDialogShown(friendWidgets[friendId]);
|
||||
}
|
||||
|
||||
|
@ -1668,7 +1671,8 @@ void Widget::copyFriendIdToClipboard(int friendId)
|
|||
if (f != nullptr)
|
||||
{
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
clipboard->setText(Nexus::getCore()->getFriendPublicKey(f->getFriendID()).toString(), QClipboard::Clipboard);
|
||||
const ToxPk& pk = Nexus::getCore()->getFriendPublicKey(f->getFriendId());
|
||||
clipboard->setText(pk.toString(), QClipboard::Clipboard);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2203,7 +2207,7 @@ void Widget::reloadTheme()
|
|||
|
||||
for (Friend* f : FriendList::getAllFriends())
|
||||
{
|
||||
int friendId = f->getFriendID();
|
||||
int friendId = f->getFriendId();
|
||||
friendWidgets[friendId]->reloadTheme();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user