Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(chatform): Fixed call buttons
Browse files Browse the repository at this point in the history
Fix #3521.
  • Loading branch information
Diadlo committed Jul 28, 2016
1 parent 1c8a7e4 commit dbe0a15
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/widget/form/chatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ ChatForm::ChatForm(Friend* chatFriend)
} );

setAcceptDrops(true);

disableCallButtons();
retranslateUi();
Translator::registerHandler(std::bind(&ChatForm::retranslateUi, this), this);
}
Expand Down Expand Up @@ -628,10 +628,17 @@ 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() && status == Status::Offline)
if(friendId != f->getFriendID())
return;

Status old = oldStatus.value(friendId, Status::Offline);

if (old != Status::Offline && status == Status::Offline)
disableCallButtons();
else
onEnableCallButtons();
else if (old == Status::Offline && status != Status::Offline)
enableCallButtons();

oldStatus[friendId] = status;
}

void ChatForm::onAvatarChange(uint32_t FriendId, const QPixmap &pic)
Expand Down Expand Up @@ -935,12 +942,6 @@ void ChatForm::show(ContentLayout* contentLayout)
{
GenericChatForm::show(contentLayout);

// Disable call buttons if friend is offline
if(f->getStatus() == Status::Offline)
disableCallButtons();
else
onEnableCallButtons();

if (callConfirm)
callConfirm->show();
}
Expand Down
1 change: 1 addition & 0 deletions src/widget/form/chatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ private slots:
QAction* copyStatusAction;

QHash<uint, FileTransferInstance*> ftransWidgets;
QMap<uint32_t, Status> oldStatus;
CallConfirmWidget *callConfirm;
bool isTyping;
};
Expand Down

0 comments on commit dbe0a15

Please sign in to comment.