Commit a59b9b1f authored by Ming Rui Zhang's avatar Ming Rui Zhang

messagewebview: detect paste(ctrl + v) key press event in textarea

Change-Id: I4d4dbdebe0eb316b1eea1f576e5dae4867008659
parent 34c34096
......@@ -205,6 +205,9 @@ CallWidget::CallWidget(QWidget* parent) :
connect(ui->messageView, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(ShowContextMenu(const QPoint&)));
connect(ui->messageView, &MessageWebView::pasteKeyDetected,
this, &CallWidget::Paste);
// set first view to welcome view
ui->stackedWidget->setCurrentWidget(ui->welcomePage);
ui->btnConversations->setChecked(true);
......
......@@ -621,3 +621,14 @@ PrivateBridging::blockConversation()
}
return 0;
}
Q_INVOKABLE int
PrivateBridging::emitPasteKeyDetected()
{
if (auto messageView = qobject_cast<MessageWebView*>(this->parent())) {
emit messageView->pasteKeyDetected();
} else {
qDebug() << "JS bridging - exception during emitPasteKeyDetected";
}
return 0;
}
......@@ -48,6 +48,7 @@ public:
Q_INVOKABLE int blockConversation();
Q_INVOKABLE int emitMessagesCleared();
Q_INVOKABLE int emitMessagesLoaded();
Q_INVOKABLE int emitPasteKeyDetected();
};
class MessageWebView : public QWebEngineView
......@@ -101,6 +102,7 @@ signals:
void messagesCleared();
void messagesLoaded();
void textSelectedReady();
void pasteKeyDetected();
private slots:
void slotLoadFinished();
......
......@@ -34,6 +34,7 @@ var messages = document.getElementById("messages")
var backToBottomBtn = document.getElementById("back_to_bottom_button")
var sendContainer = document.getElementById("file_image_send_container")
messageBarInput.onpaste = pasteKeyDetected;
/* States: allows us to avoid re-doing something if it isn't meaningful */
var displayLinksEnabled = true
......@@ -1755,3 +1756,7 @@ function remove(e) {
sendContainer.style.visibility = "hidden";
}
}
function pasteKeyDetected() {
window.jsbridge.emitPasteKeyDetected();
}
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