diff --git a/callwidget.cpp b/callwidget.cpp index 24b3078caeed30f24f85c91ec437e391f254c64c..8dbd78e1f79d6eec4dfa540a491d2663270be972 100644 --- a/callwidget.cpp +++ b/callwidget.cpp @@ -218,6 +218,7 @@ CallWidget::CallWidget(QWidget* parent) : // hide the call stack ui->callStackWidget->hide(); + ui->messagingHeaderWidget->show(); ui->containerWidget->setVisible(false); } @@ -245,6 +246,15 @@ CallWidget::navigated(bool to) } } catch (...) {} ui->currentAccountComboBox->updateComboBoxDisplay(); + auto selectedConvUid = LRCInstance::getSelectedConvUid(); + auto convModel = LRCInstance::getCurrentConversationModel(); + auto conversation = Utils::getConversationFromUid(selectedConvUid, *convModel); + if (!selectedConvUid.empty() && conversation != convModel->allFilteredConversations().end()) { + selectSmartlistItem(selectedConvUid); + ui->stackedWidget->setCurrentWidget(ui->mainActivityWidget); + } else { + backToWelcomePage(); + } } else { QObject::disconnect(smartlistSelectionConnection_); smartListModel_.reset(nullptr); @@ -270,6 +280,9 @@ CallWidget::onIncomingMessage(const std::string& convUid, if (!QApplication::focusWidget()) { auto convModel = LRCInstance::getCurrentConversationModel(); auto conversation = Utils::getConversationFromUid(convUid, *convModel); + if (conversation == convModel->allFilteredConversations().end()) { + return; + } auto bestName = Utils::bestNameForConversation(*conversation, *convModel); Utils::showSystemNotification(this, QString(tr("Message incoming from %1")) @@ -627,7 +640,7 @@ void CallWidget::slotShowCallView(const std::string& accountId, Q_UNUSED(accountId); Q_UNUSED(convInfo); qDebug() << "slotShowCallView"; - ui->callStackWidget->show(); + showCallPanel(); ui->callStackWidget->setCurrentWidget(ui->videoPage); ui->videoWidget->showChatviewIfToggled(); hideMiniSpinner(); @@ -657,10 +670,9 @@ void CallWidget::slotShowIncomingCallView(const std::string& accountId, if (call.isOutgoing) { if (isCallSelected) { miniSpinner_->start(); - ui->stackedWidget->setCurrentWidget(ui->mainActivityWidget); ui->spinnerLabel->show(); ui->callStackWidget->setCurrentWidget(ui->outgoingCallPage); - ui->callStackWidget->show(); + showCallPanel(); } } else { if (!QApplication::focusWidget()) { @@ -672,12 +684,11 @@ void CallWidget::slotShowIncomingCallView(const std::string& accountId, auto selectedAccountId = LRCInstance::getCurrentAccountInfo().id; auto accountProperties = LRCInstance::accountModel().getAccountConfig(selectedAccountId); if (accountProperties.autoAnswer) { - ui->stackedWidget->setCurrentWidget(ui->mainActivityWidget); ui->callStackWidget->setCurrentWidget(ui->videoPage); + showCallPanel(); } else if (isCallSelected) { - ui->stackedWidget->setCurrentWidget(ui->mainActivityWidget); ui->callStackWidget->setCurrentWidget(ui->incomingCallPage); - ui->callStackWidget->show(); + showCallPanel(); } } @@ -709,6 +720,7 @@ void CallWidget::slotShowChatView(const std::string& accountId, Q_UNUSED(convInfo); ui->callStackWidget->hide(); + ui->messagingHeaderWidget->show(); showConversationView(); } @@ -873,6 +885,7 @@ CallWidget::on_ringContactLineEdit_textChanged(const QString& text) void CallWidget::backToWelcomePage() { + qDebug() << "backToWelcomePage"; deselectConversation(); ui->messageView->hideMessages(); ui->stackedWidget->setCurrentWidget(ui->welcomePage); @@ -1065,11 +1078,11 @@ CallWidget::selectConversation(const QModelIndex& index) auto conversation = Utils::getConversationFromUid(convUid, *currentConversationModel); const auto item = currentConversationModel->filteredConversation(index.row()); if (callModel->hasCall(conversation->callId) && item.callId == conversation->callId) { - ui->stackedWidget->setCurrentWidget(ui->mainActivityWidget); - ui->callStackWidget->show(); + showCallPanel(); return; } ui->callStackWidget->hide(); + ui->messagingHeaderWidget->show(); } } @@ -1179,6 +1192,7 @@ CallWidget::connectAccount(const std::string& accId) case lrc::api::call::Status::TERMINATING: { ui->callStackWidget->hide(); + ui->messagingHeaderWidget->show(); showConversationView(); break; } @@ -1201,4 +1215,15 @@ CallWidget::connectAccount(const std::string& accId) ui->messageView->printHistory(*convModel, currentConversation->interactions); } }); -} \ No newline at end of file +} + +void +CallWidget::showCallPanel() +{ + ui->stackedWidget->setCurrentWidget(ui->mainActivityWidget); + ui->callStackWidget->show(); + ui->imBackButton->hide(); + ui->imBackButton->hide(); + ui->btnAudioCall->hide(); + ui->btnVideoCall->hide(); +} diff --git a/callwidget.h b/callwidget.h index 94b7d09f5ddf9531b50a908b9e8c336bafee5585..bb2771898af0a844b174aa2d7deb653500826110 100644 --- a/callwidget.h +++ b/callwidget.h @@ -114,7 +114,6 @@ private: void setupQRCode(QString ringID); void backToWelcomePage(); - // lrc void selectConversation(const QModelIndex& index); bool selectConversation(const lrc::api::conversation::Info& item, lrc::api::ConversationModel& convModel); @@ -134,6 +133,7 @@ private: void updateConversationsFilterWidget(); void updateComboBox(); void connectAccount(const std::string& accId); + void showCallPanel(); QMenu* menu_; diff --git a/deleteaccountdialog.cpp b/deleteaccountdialog.cpp index b9d93997ad62879fb9a6dda74ff72c6f14a71dac..2c2a6912c0f56c1b5217fa20bb74ca70e4382e2b 100644 --- a/deleteaccountdialog.cpp +++ b/deleteaccountdialog.cpp @@ -46,12 +46,12 @@ DeleteAccountDialog::~DeleteAccountDialog() void DeleteAccountDialog::on_deleteCancelBtn_clicked() { - done(0); + done(DialogCode::Rejected); } void DeleteAccountDialog::on_deleteAcceptBtn_clicked() { LRCInstance::editableAccountModel()->removeAccount(LRCInstance::getCurrAccId()); - done(0); + done(DialogCode::Accepted); } \ No newline at end of file diff --git a/settingswidget.cpp b/settingswidget.cpp index 2a149c2d66f36b392ea3510f0fed97ee2af0ec9d..e8016b1f432914c52676cb4af5348e82c8cf24e7 100644 --- a/settingswidget.cpp +++ b/settingswidget.cpp @@ -500,13 +500,15 @@ void SettingsWidget::delAccountSlot() { DeleteAccountDialog delDialog(this); - delDialog.exec(); - - LRCInstance::setSelectedAccountId(""); - if (!LRCInstance::accountModel().getAccountList().size()) { - emit NavigationRequested(ScreenEnum::WizardScreen); - } else { - emit NavigationRequested(ScreenEnum::CallScreen); + auto ret = delDialog.exec(); + if (ret == QDialog::Accepted) { + LRCInstance::setSelectedAccountId(""); + if (!LRCInstance::accountModel().getAccountList().size()) { + emit NavigationRequested(ScreenEnum::WizardScreen); + } else { + LRCInstance::setSelectedConvId(""); + emit NavigationRequested(ScreenEnum::CallScreen); + } } }