mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 20:56:51 +00:00
feat(GODT-3121): forward user input to bridge.
This commit is contained in:
@ -304,11 +304,11 @@ void QMLBackend::openExternalLink(QString const &url) {
|
|||||||
|
|
||||||
|
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
//
|
/// \param[in] categoryID The ID of the bug report category.
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
void QMLBackend::requestKnowledgeBaseSuggestions() const {
|
void QMLBackend::requestKnowledgeBaseSuggestions(qint8 categoryID) const {
|
||||||
HANDLE_EXCEPTION(
|
HANDLE_EXCEPTION(
|
||||||
app().grpc().requestKnowledgeBaseSuggestions("Test");
|
app().grpc().requestKnowledgeBaseSuggestions(reportFlow_.collectUserInput(categoryID));
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -66,7 +66,7 @@ public: // member functions.
|
|||||||
Q_INVOKABLE void clearAnswers(); ///< Clear all collected answers.
|
Q_INVOKABLE void clearAnswers(); ///< Clear all collected answers.
|
||||||
Q_INVOKABLE bool isTLSCertificateInstalled(); ///< Check if the bridge certificate is installed in the OS keychain.
|
Q_INVOKABLE bool isTLSCertificateInstalled(); ///< Check if the bridge certificate is installed in the OS keychain.
|
||||||
Q_INVOKABLE void openExternalLink(QString const & url = QString()); ///< Open a knowledge base article.
|
Q_INVOKABLE void openExternalLink(QString const & url = QString()); ///< Open a knowledge base article.
|
||||||
Q_INVOKABLE void requestKnowledgeBaseSuggestions() const; ///< Request knowledgebase article suggestions.
|
Q_INVOKABLE void requestKnowledgeBaseSuggestions(qint8 categoryID) const; ///< Request knowledgebase article suggestions.
|
||||||
|
|
||||||
public: // Qt/QML properties. Note that the NOTIFY-er signal is required even for read-only properties (QML warning otherwise)
|
public: // Qt/QML properties. Note that the NOTIFY-er signal is required even for read-only properties (QML warning otherwise)
|
||||||
Q_PROPERTY(bool showOnStartup READ showOnStartup NOTIFY showOnStartupChanged)
|
Q_PROPERTY(bool showOnStartup READ showOnStartup NOTIFY showOnStartupChanged)
|
||||||
|
|||||||
@ -78,7 +78,7 @@ Item {
|
|||||||
root.showBugCategory();
|
root.showBugCategory();
|
||||||
}
|
}
|
||||||
onQuestionAnswered: {
|
onQuestionAnswered: {
|
||||||
Backend.requestKnowledgeBaseSuggestions();
|
Backend.requestKnowledgeBaseSuggestions(categoryId);
|
||||||
root.showBugReport();
|
root.showBugReport();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,13 +30,6 @@ namespace {
|
|||||||
namespace bridgepp {
|
namespace bridgepp {
|
||||||
|
|
||||||
|
|
||||||
//****************************************************************************************************************************************************
|
|
||||||
//
|
|
||||||
//****************************************************************************************************************************************************
|
|
||||||
BugReportFlow::BugReportFlow() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
/// \param[in] filepath The path of the file to parse.
|
/// \param[in] filepath The path of the file to parse.
|
||||||
/// \return True iff the file can be properly parsed.
|
/// \return True iff the file can be properly parsed.
|
||||||
@ -92,7 +85,7 @@ bool BugReportFlow::setAnswer(quint8 questionId, QString const &answer) {
|
|||||||
|
|
||||||
|
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
/// \param[in] questionId The id of the question.
|
/// \param[in] categoryId The id of the question.
|
||||||
/// \return answer the given question.
|
/// \return answer the given question.
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
QString BugReportFlow::getCategory(quint8 categoryId) const {
|
QString BugReportFlow::getCategory(quint8 categoryId) const {
|
||||||
@ -128,7 +121,7 @@ QString BugReportFlow::collectAnswers(quint8 categoryId) const {
|
|||||||
|
|
||||||
QVariantList sets = this->questionSet(categoryId);
|
QVariantList sets = this->questionSet(categoryId);
|
||||||
for (QVariant const &var: sets) {
|
for (QVariant const &var: sets) {
|
||||||
const QString& answer = getAnswer(var.toInt());
|
const QString answer = getAnswer(var.toInt());
|
||||||
if (answer.isEmpty())
|
if (answer.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
answers += "#### " + questions_[var.toInt()].toMap()["text"].toString() + "\n\r";
|
answers += "#### " + questions_[var.toInt()].toMap()["text"].toString() + "\n\r";
|
||||||
@ -139,6 +132,24 @@ QString BugReportFlow::collectAnswers(quint8 categoryId) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
/// \param[in] categoryId The id of the question set.
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
QString BugReportFlow::collectUserInput(quint8 categoryId) const {
|
||||||
|
if (categoryId > categories_.count() - 1)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
QString input = this->getCategory(categoryId);
|
||||||
|
for (QVariant const &var: this->questionSet(categoryId)) {
|
||||||
|
QString const answer = getAnswer(var.toInt());
|
||||||
|
if (!answer.isEmpty())
|
||||||
|
input += " " + answer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
//
|
//
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
|
|||||||
@ -28,7 +28,7 @@ namespace bridgepp {
|
|||||||
class BugReportFlow {
|
class BugReportFlow {
|
||||||
|
|
||||||
public: // member functions.
|
public: // member functions.
|
||||||
BugReportFlow(); ///< Default constructor.
|
BugReportFlow() = default; ///< Default constructor.
|
||||||
BugReportFlow(BugReportFlow const &) = delete; ///< Disabled copy-constructor.
|
BugReportFlow(BugReportFlow const &) = delete; ///< Disabled copy-constructor.
|
||||||
BugReportFlow(BugReportFlow &&) = delete; ///< Disabled assignment copy-constructor.
|
BugReportFlow(BugReportFlow &&) = delete; ///< Disabled assignment copy-constructor.
|
||||||
~BugReportFlow() = default; ///< Destructor.
|
~BugReportFlow() = default; ///< Destructor.
|
||||||
@ -42,6 +42,7 @@ public: // member functions.
|
|||||||
[[nodiscard]] QString getCategory(quint8 categoryId) const; ///< Get category name.
|
[[nodiscard]] QString getCategory(quint8 categoryId) const; ///< Get category name.
|
||||||
[[nodiscard]] QString getAnswer(quint8 questionId) const; ///< Get answer for a given question.
|
[[nodiscard]] QString getAnswer(quint8 questionId) const; ///< Get answer for a given question.
|
||||||
[[nodiscard]] QString collectAnswers(quint8 categoryId) const; ///< Collect answer for a given set of questions.
|
[[nodiscard]] QString collectAnswers(quint8 categoryId) const; ///< Collect answer for a given set of questions.
|
||||||
|
[[nodiscard]] QString collectUserInput(quint8 categoryId) const; ///< Collect the user input (user answers without quesitons) for a given set of questions.
|
||||||
void clearAnswers(); ///< Clear all collected answers.
|
void clearAnswers(); ///< Clear all collected answers.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user