diff --git a/callwidget.cpp b/callwidget.cpp index 52b055c9cbad33ad4911b58e17c09b8951e2f9ca..b61b80c68304391ee1bec5990b2cf033fa2bd7cb 100644 --- a/callwidget.cpp +++ b/callwidget.cpp @@ -44,7 +44,7 @@ CallWidget::CallWidget(QWidget *parent) : ui->muteSpeakerButton->setCheckable(true); ui->callInvite->setVisible(false); - actualCall_ = nullptr; + setActualCall(nullptr); videoRenderer_ = nullptr; try { @@ -154,7 +154,7 @@ CallWidget::callIncoming(Call *call) { if (!call->account()->isAutoAnswer()) ui->callInvite->setVisible(true); - actualCall_ = call; + setActualCall(call); } void @@ -171,7 +171,7 @@ CallWidget::on_refuseButton_clicked() if (actualCall_ == nullptr) return; actualCall_->performAction(Call::Action::REFUSE); - actualCall_ = nullptr; + setActualCall(nullptr); ui->callInvite->setVisible(false); } @@ -196,7 +196,7 @@ void CallWidget::addedCall(Call* call, Call* parent) { Q_UNUSED(parent); if (call->direction() == Call::Direction::OUTGOING) { - actualCall_ = call; + setActualCall(call); } } @@ -207,8 +207,8 @@ CallWidget::callStateChanged(Call* call, Call::State previousState) if (call == nullptr) return; ui->callList->setCurrentIndex(callModel_->getIndex(actualCall_)); - if (call->state() == Call::State::OVER) { - actualCall_ = nullptr; + if (call->state() == Call::State::OVER || call->state() == Call::State::ERROR) { + setActualCall(nullptr); ui->videoWidget->hide(); } else if (call->state() == Call::State::HOLD) { ui->videoWidget->hide(); @@ -230,7 +230,7 @@ CallWidget::on_callList_activated(const QModelIndex &index) ui->videoWidget->hide(); actualCall_->performAction(Call::Action::HOLD); } - actualCall_ = callSelected; + setActualCall(callSelected); actualCall_->performAction(Call::Action::HOLD); ui->videoWidget->show(); } @@ -300,7 +300,8 @@ CallWidget::on_contactView_doubleClicked(const QModelIndex &index) } } -void CallWidget::on_historyList_doubleClicked(const QModelIndex &index) +void +CallWidget::on_historyList_doubleClicked(const QModelIndex &index) { QString number = index.model()->data(index, static_cast<int>(Call::Role::Number)).toString(); if (not number.isEmpty()) { @@ -309,3 +310,11 @@ void CallWidget::on_historyList_doubleClicked(const QModelIndex &index) outCall->performAction(Call::Action::ACCEPT); } } + +void +CallWidget::setActualCall(Call* value) +{ + actualCall_ = value; + ui->holdButton->setEnabled(actualCall_ != nullptr); + ui->hangupButton->setEnabled(actualCall_ != nullptr); +} diff --git a/callwidget.h b/callwidget.h index 726a067efeed6939962003b1a95385e1f6353328..0ded03ed044f6a74aa09687a5f731795d185f8be 100644 --- a/callwidget.h +++ b/callwidget.h @@ -81,6 +81,7 @@ private: int outputVolume_; int inputVolume_; void findRingAccount(); + void setActualCall(Call *value); }; #endif // CALLWIDGET_H diff --git a/callwidget.ui b/callwidget.ui index 99dbbaf6f5ea71baa289c32890504c55d418ffba..9719cfb1d15048ae317fb47a035f74a9bf2f433b 100644 --- a/callwidget.ui +++ b/callwidget.ui @@ -135,6 +135,9 @@ </item> <item> <widget class="QPushButton" name="holdButton"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="text"> <string>Hold/Unhold</string> </property> @@ -146,6 +149,9 @@ </item> <item> <widget class="QPushButton" name="hangupButton"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="sizePolicy"> <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> <horstretch>0</horstretch>