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
wilder-5.24
Nate Graham 4 years ago
parent 1a165a41fb
commit a5b4065b2c
  1. 15
      kcms/feedback/feedback.cpp

@ -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;
}

Loading…
Cancel
Save