Commit 44821ced authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Fix KCM duplicates in landingpage

In systemsettings, we no longer write a ".desktop" at the end of the KCM ids.
This change was made during Plasma 5.24. However, it causes duplicates on some setups.
To avoid this, we ignore all of the old .desktop URLs. To ensure that we fill all of the 6 available
items, the limit is increased to 12 and we check against a list how many results we have ignored.

BUG: 449563


(cherry picked from commit 9a78c778)
parent 08f25bd5
Pipeline #220709 passed with stage
in 3 minutes and 34 seconds
......@@ -104,8 +104,15 @@ QHash<int, QByteArray> MostUsedModel::roleNames() const
bool MostUsedModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
const QString desktopName = sourceModel()->index(source_row, 0, source_parent).data(ResultModel::ResourceRole).toUrl().path();
if (desktopName.endsWith(QLatin1String(".desktop"))) {
const bool isAlreadyIgnored = ignoredKCMs.contains(desktopName);
if (!isAlreadyIgnored) {
ignoredKCMs.append(desktopName);
}
return false;
}
KService::Ptr service = KService::serviceByStorageId(desktopName);
return service;
return service && (source_row - ignoredKCMs.size() < 6);
}
QVariant MostUsedModel::data(const QModelIndex &index, int role) const
......@@ -179,7 +186,7 @@ KCMLandingPage::KCMLandingPage(QObject *parent, const QVariantList &args)
setButtons(Apply | Help);
m_mostUsedModel = new MostUsedModel(this);
m_mostUsedModel->setResultModel(new ResultModel(AllResources | Agent(QStringLiteral("org.kde.systemsettings")) | HighScoredFirst | Limit(6), this));
m_mostUsedModel->setResultModel(new ResultModel(AllResources | Agent(QStringLiteral("org.kde.systemsettings")) | HighScoredFirst | Limit(12), this));
m_defaultLightLookAndFeel = new LookAndFeelGroup(this);
m_defaultDarkLookAndFeel = new LookAndFeelGroup(this);
......
......@@ -48,6 +48,7 @@ private:
QStandardItemModel *m_defaultModel = nullptr;
// Model fed by kactivities-stats
KActivities::Stats::ResultModel *m_resultModel = nullptr;
mutable QStringList ignoredKCMs;
};
class LookAndFeelGroup : public QObject
......
Supports Markdown
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