diff --git a/internal/frontend/bridge-gui/bridge-gui-tester/GRPCService.cpp b/internal/frontend/bridge-gui/bridge-gui-tester/GRPCService.cpp index 9c7e7aa6..03ce14db 100644 --- a/internal/frontend/bridge-gui/bridge-gui-tester/GRPCService.cpp +++ b/internal/frontend/bridge-gui/bridge-gui-tester/GRPCService.cpp @@ -360,11 +360,11 @@ Status GRPCService::SetMainExecutable(ServerContext *, StringValue const *reques //**************************************************************************************************************************************************** grpc::Status GRPCService::RequestKnowledgeBaseSuggestions(ServerContext*, StringValue const* request, Empty*) { app().log().info(QString("RequestKnowledgeBaseSuggestions: %1").arg(QString::fromStdString(request->value()).left(10) + "...")); - QList suggestions(3); - for (qsizetype i = 0; i < 3; ++i) { + QList suggestions; + for (qsizetype i = 1; i <= 3; ++i) { suggestions.push_back( { .title = QString("Suggested link %1").arg(i), - .url = "https://proton.me/support/bridge" + .url = QString("https://proton.me/support/bridge#%1").arg(i), }); } qtProxy_.sendDelayedEvent(newKnowledgeBaseSuggestionsEvent(suggestions)); diff --git a/internal/frontend/bridge-gui/bridge-gui/QMLBackend.cpp b/internal/frontend/bridge-gui/bridge-gui/QMLBackend.cpp index 54f552af..69b8cc96 100644 --- a/internal/frontend/bridge-gui/bridge-gui/QMLBackend.cpp +++ b/internal/frontend/bridge-gui/bridge-gui/QMLBackend.cpp @@ -1315,6 +1315,7 @@ void QMLBackend::connectGrpcEvents() { connect(client, &GRPCClient::certificateInstallCanceled, this, &QMLBackend::certificateInstallCanceled); connect(client, &GRPCClient::certificateInstallFailed, this, &QMLBackend::certificateInstallFailed); connect(client, &GRPCClient::showMainWindow, [&]() { this->showMainWindow("gRPC showMainWindow event"); }); + connect(client, &GRPCClient::knowledgeBasSuggestionsReceived, this, &QMLBackend::receivedKnowledgeBaseSuggestions); // cache events connect(client, &GRPCClient::cantMoveDiskCache, this, &QMLBackend::cantMoveDiskCache); diff --git a/internal/frontend/bridge-gui/bridge-gui/QMLBackend.h b/internal/frontend/bridge-gui/bridge-gui/QMLBackend.h index 63392643..5e22e990 100644 --- a/internal/frontend/bridge-gui/bridge-gui/QMLBackend.h +++ b/internal/frontend/bridge-gui/bridge-gui/QMLBackend.h @@ -279,6 +279,7 @@ signals: // Signals received from the Go backend, to be forwarded to QML void selectUser(QString const& userID, bool forceShowWindow); ///< Signal emitted in order to selected a user with a given ID in the list. void genericError(QString const &title, QString const &description); ///< Signal for the 'genericError' gRPC stream event. void imapLoginWhileSignedOut(QString const& username); ///< Signal for the notification of IMAP login attempt on a signed out account. + void receivedKnowledgeBaseSuggestions(QList const& suggestions); ///< Signal for the reception of knowledgebase article suggestions. // This signal is emitted when an exception is intercepted is calls triggered by QML. QML engine would intercept the exception otherwise. void fatalError(bridgepp::Exception const& e) const; ///< Signal emitted when an fatal error occurs. diff --git a/internal/frontend/bridge-gui/bridge-gui/qml/BugReport/BugReportView.qml b/internal/frontend/bridge-gui/bridge-gui/qml/BugReport/BugReportView.qml index af3fd397..7b8c1566 100644 --- a/internal/frontend/bridge-gui/bridge-gui/qml/BugReport/BugReportView.qml +++ b/internal/frontend/bridge-gui/bridge-gui/qml/BugReport/BugReportView.qml @@ -155,7 +155,12 @@ SettingsView { function onReportBugFinished() { sendButton.loading = false; } - + function onReceivedKnowledgeBaseSuggestions(suggestions) { + console.error("QML: onReceivedKnowledgeBaseSuggestions() - len = %1".arg(suggestions.length)) + console.error("QML: %1: %2".arg(suggestions[0].title).arg(suggestions[0].url)) + console.error("QML: %1: %2".arg(suggestions[1].title).arg(suggestions[1].url)) + console.error("QML: %1: %2".arg(suggestions[2].title).arg(suggestions[2].url)) + } target: Backend } } diff --git a/internal/frontend/bridge-gui/bridgepp/bridgepp/GRPC/GRPCClient.cpp b/internal/frontend/bridge-gui/bridgepp/bridgepp/GRPC/GRPCClient.cpp index eaaa45f6..c1b68794 100644 --- a/internal/frontend/bridge-gui/bridgepp/bridgepp/GRPC/GRPCClient.cpp +++ b/internal/frontend/bridge-gui/bridgepp/bridgepp/GRPC/GRPCClient.cpp @@ -1182,7 +1182,7 @@ void GRPCClient::processAppEvent(AppEvent const &event) { .title = QString::fromUtf8(suggestion.title()) }); } - emit knowledgeBasSuggestions(suggestions); + emit knowledgeBasSuggestionsReceived(suggestions); break; } default: diff --git a/internal/frontend/bridge-gui/bridgepp/bridgepp/GRPC/GRPCClient.h b/internal/frontend/bridge-gui/bridgepp/bridgepp/GRPC/GRPCClient.h index 84d79d9a..18c0e699 100644 --- a/internal/frontend/bridge-gui/bridgepp/bridgepp/GRPC/GRPCClient.h +++ b/internal/frontend/bridge-gui/bridgepp/bridgepp/GRPC/GRPCClient.h @@ -46,6 +46,11 @@ typedef std::unique_ptr UPClientContext; /// \brief A struct for knowledge base suggestion. //**************************************************************************************************************************************************** struct KnowledgeBaseSuggestion { + // The following lines make the type transmissible to QML (but not instanciable there) + Q_GADGET + Q_PROPERTY(QString url MEMBER url) + Q_PROPERTY(QString title MEMBER title) +public: QString url; ///< The URL of the knowledge base article QString title; ///< The title of the knowledge base article. }; @@ -116,7 +121,7 @@ signals: // app related signals void certificateInstallCanceled(); void certificateInstallFailed(); void showMainWindow(); - void knowledgeBasSuggestions(QList const& suggestions); + void knowledgeBasSuggestionsReceived(QList const& suggestions); public: // cache related calls