diff --git a/callwidget.cpp b/callwidget.cpp index a3e028fd046fc194d82e6c5b11043b19818967cc..ebf43de773493397e523cd87cd4429a89b538e1f 100644 --- a/callwidget.cpp +++ b/callwidget.cpp @@ -503,6 +503,7 @@ CallWidget::showConversationView() if (ui->messagesWidget->isHidden()) { ui->messagesWidget->show(); } + updateChatviewFrame(); } bool @@ -1398,6 +1399,40 @@ CallWidget::setCallPanelVisibility(bool visible) ui->messageView->setRecordButtonsVisibility(!visible); } +void +CallWidget::updateChatviewFrame() +{ + // TODO: remove this to start using webview navbar + // instead of native qt + if (1) { + ui->messageView->displayNavbar(false); + return; + } + + auto& accInfo = LRCInstance::getCurrentAccountInfo(); + auto& convInfo = LRCInstance::getCurrentConversation(); + if (convInfo.uid.empty()) { + return; + } + auto contactUri = convInfo.participants.front(); + + lrc::api::contact::Info contactInfo; + try { + contactInfo = accInfo.contactModel->getContact(contactUri); + } catch (const std::out_of_range&) { + qDebug() << "updateChatviewFrame: failed to retrieve contactInfo"; + return; + } + + bool temp = contactInfo.profileInfo.type == lrc::api::profile::Type::TEMPORARY || + contactInfo.profileInfo.type == lrc::api::profile::Type::PENDING; + + auto bestName = QString::fromStdString(Utils::bestNameForContact(contactInfo)); + auto bestId = QString::fromStdString(Utils::bestIdForContact(contactInfo)); + + ui->messageView->updateChatviewFrame(accInfo.enabled, contactInfo.isBanned, temp, bestName, bestId); +} + void CallWidget::ShowContextMenu(const QPoint& pos) { diff --git a/callwidget.h b/callwidget.h index 8da3fbe0a8d1d2ca49baf568c4abe357fde1485a..fe05fa65a9af59081bc225ede22600c718c967a1 100644 --- a/callwidget.h +++ b/callwidget.h @@ -133,6 +133,7 @@ private: void updateComboBox(); void connectAccount(const std::string& accId); void setCallPanelVisibility(bool visible); + void updateChatviewFrame(); QMenu* menu_; QClipboard* clipboard_; diff --git a/callwidget.ui b/callwidget.ui index 41e00b03344722a67efcddcebe970e92ec788ece..3f83ff0215e6a3addddc1d963802dc220653be47 100644 --- a/callwidget.ui +++ b/callwidget.ui @@ -2071,7 +2071,7 @@ Copy and share it with your friends! </property> <property name="maximumSize"> <size> - <width>1000</width> + <width>16777215</width> <height>16777215</height> </size> </property> diff --git a/messagewebview.cpp b/messagewebview.cpp index 9ca20aaaf6734e90a555b27ad950c5e785915430..0553c8429b4d091a12bf54fa680f7bb201ff308e 100644 --- a/messagewebview.cpp +++ b/messagewebview.cpp @@ -114,6 +114,7 @@ MessageWebView::MessageWebView(QWidget *parent) break; } }); + recordWidget_ = new RecordWidget(this); recordWidget_->getContainer()->hide(); } @@ -302,6 +303,8 @@ MessageWebView::slotLoadFinished() QString s = QString::fromLatin1("init_i18n();"); page()->runJavaScript(s, QWebEngineScript::MainWorld); + + displayNavbar(false); } void @@ -349,7 +352,7 @@ void MessageWebView::clear() void MessageWebView::setDisplayLinks(bool display) { - QString s = QString::fromLatin1("setDisplayLinks('%1');") + QString s = QString::fromLatin1("setDisplayLinks(%1);") .arg(display ? "true" : "false"); page()->runJavaScript(s, QWebEngineScript::MainWorld); } @@ -432,6 +435,28 @@ MessageWebView::setMessagesVisibility(bool visible) page()->runJavaScript(s, QWebEngineScript::MainWorld); } +void +MessageWebView::updateChatviewFrame(bool accountEnabled, bool isBanned, bool isTemporary, + const QString& alias, const QString& bestId) +{ + QString s = QString::fromLatin1("update_chatview_frame(%1, %2, %3, \"%4\", \"%5\")") + .arg(accountEnabled ? "true" : "false") + .arg(isBanned ? "true" : "false") + .arg(isTemporary ? "true" : "false") + .arg(alias) + .arg(bestId); + + page()->runJavaScript(s, QWebEngineScript::MainWorld); +} + +void +MessageWebView::displayNavbar(bool display) +{ + QString s = QString::fromLatin1("displayNavbar(%1);") + .arg(display ? "true" : "false"); + page()->runJavaScript(s, QWebEngineScript::MainWorld); +} + // JS bridging incoming Q_INVOKABLE int PrivateBridging::log(const QString& arg) @@ -603,7 +628,7 @@ PrivateBridging::sendImage(const QString& arg) } Q_INVOKABLE int -PrivateBridging::sendFile(const QString&path) +PrivateBridging::sendFile(const QString& path) { qDebug() << "JS bridging - MessageWebView::sendFile"; QFileInfo fi(path); @@ -716,4 +741,4 @@ PrivateBridging::openVideoRecorder(int spikePosX, int spikePosY) qDebug() << "JS bridging - exception during openVideoRecorder!"; } return 0; -} +} \ No newline at end of file diff --git a/messagewebview.h b/messagewebview.h index 74859ca2a32d76dde64de880a55049960a6742c4..d782aff8fe9844549750910af61b9ac21d681c26 100644 --- a/messagewebview.h +++ b/messagewebview.h @@ -94,6 +94,9 @@ public: void openAudioRecorder(int spikePosX,int spikePosY); void openVideoRecorder(int spikePosX,int spikePosY); void setRecordButtonsVisibility(bool visible); + void updateChatviewFrame(bool accountEnabled, bool isBanned, bool isTemporary, + const QString& alias, const QString& bestId); + void displayNavbar(bool display); protected: