Commit a5b4065b authored by Nate Graham's avatar Nate Graham
Browse files

kcms/feedback: Only add audit locations to the model that exist

This prevents audit locations that don't appear on disk from showing up
as clickable links in the KCM, which produces a bad UX whereby you can
try to open the nonexistent location and then you get an ugly error
message instead. So let's just not even show them if they don't exist

BUG: 445959
FIXED-IN: 5.24
parent 1a165a41
Pipeline #106988 passed with stage
in 8 minutes and 10 seconds
......@@ -10,6 +10,8 @@
#include <KConfigGroup>
#include <KLocalizedString>
#include <KPluginFactory>
#include <QFileInfo>
#include <QVector>
#include <KUserFeedback/FeedbackConfigUiController>
......@@ -120,10 +122,15 @@ QJsonArray Feedback::audits() const
{
QJsonArray ret;
for (auto it = s_programs.constBegin(); it != s_programs.constEnd(); ++it) {
ret += QJsonObject {
{ "program", it.key() },
{ "audits", QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + '/' + it->kuserfeedbackComponent + QStringLiteral("/kuserfeedback/audit")).toString() },
};
QString feedbackLocation =
QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + '/' + it->kuserfeedbackComponent + QStringLiteral("/kuserfeedback/audit");
if (QFileInfo::exists(feedbackLocation)) {
ret += QJsonObject{
{"program", it.key()},
{"audits", feedbackLocation},
};
}
}
return ret;
}
......
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