mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
feat(chatform): Disable call buttons if friend is offline
Call buttons would be enabled but non-functional if you were looking at a friend who was offline. We now check if the friend is offline and disable the call buttons if so.
This commit is contained in:
parent
2c49ada955
commit
bbefe0119d
|
@ -114,6 +114,7 @@ ChatForm::ChatForm(Friend* chatFriend)
|
||||||
connect(msgEdit, &ChatTextEdit::enterPressed, this, &ChatForm::onSendTriggered);
|
connect(msgEdit, &ChatTextEdit::enterPressed, this, &ChatForm::onSendTriggered);
|
||||||
connect(msgEdit, &ChatTextEdit::textChanged, this, &ChatForm::onTextEditChanged);
|
connect(msgEdit, &ChatTextEdit::textChanged, this, &ChatForm::onTextEditChanged);
|
||||||
connect(core, &Core::fileSendFailed, this, &ChatForm::onFileSendFailed);
|
connect(core, &Core::fileSendFailed, this, &ChatForm::onFileSendFailed);
|
||||||
|
connect(core, &Core::friendStatusChanged, this, &ChatForm::onFriendStatusChanged);
|
||||||
connect(this, &ChatForm::chatAreaCleared, getOfflineMsgEngine(), &OfflineMsgEngine::removeAllReceipts);
|
connect(this, &ChatForm::chatAreaCleared, getOfflineMsgEngine(), &OfflineMsgEngine::removeAllReceipts);
|
||||||
connect(statusMessageLabel, &CroppingLabel::customContextMenuRequested, this, [&](const QPoint& pos)
|
connect(statusMessageLabel, &CroppingLabel::customContextMenuRequested, this, [&](const QPoint& pos)
|
||||||
{
|
{
|
||||||
|
@ -516,13 +517,10 @@ void ChatForm::enableCallButtons()
|
||||||
disableCallButtonsTimer->start(1500); // 1.5sec
|
disableCallButtonsTimer->start(1500); // 1.5sec
|
||||||
qDebug() << "timer started!!";
|
qDebug() << "timer started!!";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatForm::disableCallButtons()
|
void ChatForm::disableCallButtons()
|
||||||
{
|
{
|
||||||
qDebug() << "disableCallButtons";
|
|
||||||
|
|
||||||
// Prevents race enable / disable / onEnable, when it should be disabled
|
// Prevents race enable / disable / onEnable, when it should be disabled
|
||||||
if (disableCallButtonsTimer)
|
if (disableCallButtonsTimer)
|
||||||
{
|
{
|
||||||
|
@ -552,7 +550,6 @@ void ChatForm::disableCallButtons()
|
||||||
|
|
||||||
void ChatForm::onEnableCallButtons()
|
void ChatForm::onEnableCallButtons()
|
||||||
{
|
{
|
||||||
qDebug() << "onEnableCallButtons";
|
|
||||||
audioInputFlag = false;
|
audioInputFlag = false;
|
||||||
audioOutputFlag = false;
|
audioOutputFlag = false;
|
||||||
|
|
||||||
|
@ -568,9 +565,12 @@ void ChatForm::onEnableCallButtons()
|
||||||
connect(videoButton, SIGNAL(clicked()),
|
connect(videoButton, SIGNAL(clicked()),
|
||||||
this, SLOT(onVideoCallTriggered()));
|
this, SLOT(onVideoCallTriggered()));
|
||||||
|
|
||||||
disableCallButtonsTimer->stop();
|
if (disableCallButtonsTimer != nullptr)
|
||||||
delete disableCallButtonsTimer;
|
{
|
||||||
disableCallButtonsTimer = nullptr;
|
disableCallButtonsTimer->stop();
|
||||||
|
delete disableCallButtonsTimer;
|
||||||
|
disableCallButtonsTimer = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatForm::onMicMuteToggle()
|
void ChatForm::onMicMuteToggle()
|
||||||
|
@ -621,6 +621,15 @@ void ChatForm::onFileSendFailed(uint32_t FriendId, const QString &fname)
|
||||||
addSystemInfoMessage(tr("Failed to send file \"%1\"").arg(fname), ChatMessage::ERROR, QDateTime::currentDateTime());
|
addSystemInfoMessage(tr("Failed to send file \"%1\"").arg(fname), ChatMessage::ERROR, QDateTime::currentDateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatForm::onFriendStatusChanged(uint32_t friendId, Status status)
|
||||||
|
{
|
||||||
|
// Disable call buttons if friend is offline
|
||||||
|
if(friendId == f->getFriendID() && status == Status::Offline)
|
||||||
|
disableCallButtons();
|
||||||
|
else
|
||||||
|
onEnableCallButtons();
|
||||||
|
}
|
||||||
|
|
||||||
void ChatForm::onAvatarChange(uint32_t FriendId, const QPixmap &pic)
|
void ChatForm::onAvatarChange(uint32_t FriendId, const QPixmap &pic)
|
||||||
{
|
{
|
||||||
if (FriendId != f->getFriendID())
|
if (FriendId != f->getFriendID())
|
||||||
|
@ -916,6 +925,12 @@ void ChatForm::show(ContentLayout* contentLayout)
|
||||||
{
|
{
|
||||||
GenericChatForm::show(contentLayout);
|
GenericChatForm::show(contentLayout);
|
||||||
|
|
||||||
|
// Disable call buttons if friend is offline
|
||||||
|
if(f->getStatus() == Status::Offline)
|
||||||
|
disableCallButtons();
|
||||||
|
else
|
||||||
|
onEnableCallButtons();
|
||||||
|
|
||||||
if (callConfirm)
|
if (callConfirm)
|
||||||
callConfirm->show();
|
callConfirm->show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,7 @@ private slots:
|
||||||
void onMicMuteToggle();
|
void onMicMuteToggle();
|
||||||
void onVolMuteToggle();
|
void onVolMuteToggle();
|
||||||
void onFileSendFailed(uint32_t FriendId, const QString &fname);
|
void onFileSendFailed(uint32_t FriendId, const QString &fname);
|
||||||
|
void onFriendStatusChanged(uint32_t friendId, Status status);
|
||||||
void onLoadHistory();
|
void onLoadHistory();
|
||||||
void onUpdateTime();
|
void onUpdateTime();
|
||||||
void onEnableCallButtons();
|
void onEnableCallButtons();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user