Commit b4988375 authored by Andreas Traczyk's avatar Andreas Traczyk

chatview: restore webview navbar invitations

- Complete navbar can be added by removing the TODO in
  callwidget.cpp, and bridging the button functionality.

Change-Id: Ia8bd8b1a37c4273c80200d918c8735c7017823eb
parent b54c2f51
......@@ -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)
{
......
......@@ -133,6 +133,7 @@ private:
void updateComboBox();
void connectAccount(const std::string& accId);
void setCallPanelVisibility(bool visible);
void updateChatviewFrame();
QMenu* menu_;
QClipboard* clipboard_;
......
......@@ -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>
......
......@@ -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
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment