Commit 9a78c778 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
parent da00e533
Pipeline #220476 passed with stage
in 3 minutes and 7 seconds
......@@ -103,8 +103,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
......@@ -169,7 +176,7 @@ KCMLandingPage::KCMLandingPage(QObject *parent, const KPluginMetaData &metaData,
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);
......
......@@ -52,6 +52,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