mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-22 01:56:44 +00:00
feat(GODT-2794): Clear cached answers when report is sent.
This commit is contained in:
committed by
Romain Le Jeune
parent
c4bcc38c53
commit
3d64c5f894
@ -243,6 +243,15 @@ void QMLBackend::setQuestionAnswer(quint8 questionId, QString const &answer) {
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] questionId The id of the question.
|
||||
/// \return answer for the given question.
|
||||
//****************************************************************************************************************************************************
|
||||
QString QMLBackend::getQuestionAnswer(quint8 questionId) const {
|
||||
return reportFlow_.getAnswer(questionId);
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] categoryId The id of the question set.
|
||||
/// \return concatenate answers for set of questions.
|
||||
@ -252,6 +261,14 @@ QString QMLBackend::collectAnswers(quint8 categoryId) const {
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
void QMLBackend::clearAnswers() {
|
||||
reportFlow_.clearAnswers();
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The value for the 'showOnStartup' property.
|
||||
//****************************************************************************************************************************************************
|
||||
|
||||
@ -60,7 +60,9 @@ public: // member functions.
|
||||
Q_INVOKABLE bool areSameFileOrFolder(QUrl const &lhs, QUrl const &rhs) const; ///< Check if two local URL point to the same file.
|
||||
Q_INVOKABLE QVariantList getQuestionSet(quint8 categoryId) const; ///< Retrieve the set of question for a given bug category.
|
||||
Q_INVOKABLE void setQuestionAnswer(quint8 questionId, QString const &answer); ///< Feed an answer for a given question.
|
||||
Q_INVOKABLE QString getQuestionAnswer(quint8 questionId) const; ///< Get the answer for a given question.
|
||||
Q_INVOKABLE QString collectAnswers(quint8 categoryId) const; ///< Collect answer for a given set of questions.
|
||||
Q_INVOKABLE void clearAnswers(); ///< Clear all collected answers.
|
||||
|
||||
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)
|
||||
|
||||
@ -65,6 +65,13 @@ SettingsView {
|
||||
onAnswerChanged:{
|
||||
Backend.setQuestionAnswer(modelData, answer);
|
||||
}
|
||||
|
||||
Connections {
|
||||
function onVisibleChanged() {
|
||||
setDefaultValue(Backend.getQuestionAnswer(modelData))
|
||||
}
|
||||
target:root
|
||||
}
|
||||
}
|
||||
}
|
||||
// fill height so the footer label will always be attached to the bottom
|
||||
|
||||
@ -96,6 +96,7 @@ Item {
|
||||
root.showBugQuestion();
|
||||
}
|
||||
onBugReportWasSent: {
|
||||
Backend.clearAnswers();
|
||||
root.bugReportWasSent();
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,6 +46,12 @@ Item {
|
||||
return ""
|
||||
}
|
||||
|
||||
function setDefaultValue(defaultValue) {
|
||||
textInput.setDefaultValue(defaultValue)
|
||||
selectionRadio.setDefaultValue(defaultValue)
|
||||
selectionCheckBox.setDefaultValue(defaultValue)
|
||||
}
|
||||
|
||||
implicitHeight: children[0].implicitHeight + children[0].anchors.topMargin + children[0].anchors.bottomMargin
|
||||
|
||||
ColumnLayout {
|
||||
@ -75,6 +81,10 @@ Item {
|
||||
hint: mandatory ? textInput.text.length + "/" + _maxLength : ""
|
||||
placeholderText: mandatory ? qsTr("%1... (min. %2 characters)").arg(root.text).arg(_minLength) : ""
|
||||
|
||||
function setDefaultValue(defaultValue) {
|
||||
textInput.text = root.type === QuestionItem.InputType.TextInput ? defaultValue : ""
|
||||
}
|
||||
|
||||
validator: function (text) {
|
||||
if (!mandatory)
|
||||
return;
|
||||
@ -101,6 +111,13 @@ Item {
|
||||
property string text: {
|
||||
return checkedButton ? checkedButton.text : "";
|
||||
}
|
||||
|
||||
function setDefaultValue(defaultValue) {
|
||||
const values = root.type === QuestionItem.InputType.Radio ? defaultValue : [];
|
||||
for (var i = 0; i < buttons.length; ++i) {
|
||||
buttons[i].checked = values.includes(buttons[i].text);
|
||||
}
|
||||
}
|
||||
}
|
||||
Repeater {
|
||||
model: root.answerList
|
||||
@ -115,14 +132,22 @@ Item {
|
||||
ButtonGroup {
|
||||
id: selectionCheckBox
|
||||
exclusive: false
|
||||
property string delimitor: ", "
|
||||
property string text: {
|
||||
var str = "";
|
||||
for (var i = 0; i < buttons.length; ++i) {
|
||||
if (buttons[i].checked) {
|
||||
str += buttons[i].text + ", ";
|
||||
str += buttons[i].text + delimitor;
|
||||
}
|
||||
}
|
||||
return str.slice(0, -2);
|
||||
return str.slice(0, -delimitor.length);
|
||||
}
|
||||
|
||||
function setDefaultValue(defaultValue) {
|
||||
const values = root.type === QuestionItem.InputType.Checkbox ? defaultValue.split(delimitor) : [];
|
||||
for (var i = 0; i < buttons.length; ++i) {
|
||||
buttons[i].checked = values.includes(buttons[i].text);
|
||||
}
|
||||
}
|
||||
}
|
||||
Repeater {
|
||||
|
||||
@ -59,9 +59,9 @@
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"text": "Are you running any of these software?",
|
||||
"text": "Can you list the software you are running?",
|
||||
"type": 3,
|
||||
"answerList": ["VPN", "Antivirus", "Firewall", "Cache cleaner", "None of the above"]
|
||||
"answerList": ["VPN", "Antivirus", "Firewall", "Cache cleaner"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user