Blacklist for applicationsmodel

This allows hiding applications on the homescreen. It's useful because
everybody and her dog puts .desktop files into /usr/share/applications,
and many of them are not at all useful. We'll try to do some more
elaborate filtering (watch the next commits), but this provides a
baseline to really hide some things that we don't want to show.

Reviewed-by: notmart
This commit is contained in:
Sebastian Kügler 2015-06-15 20:08:12 -07:00
parent ab62a5cdcd
commit fbcf4fa457

View file

@ -30,6 +30,7 @@
#include <KService>
#include <KServiceGroup>
#include <KServiceTypeTrader>
#include <KSharedConfig>
#include <KSycoca>
#include <KSycocaEntry>
#include <QDebug>
@ -76,6 +77,10 @@ bool appNameLessThan(const ApplicationData &a1, const ApplicationData &a2)
void ApplicationListModel::loadApplications()
{
auto cfg = KSharedConfig::openConfig("applications-blacklistrc");
auto blgroup = KConfigGroup(cfg, QStringLiteral("Applications"));
QStringList blacklist = blgroup.readEntry("blacklist", QStringList());
beginResetModel();
m_applicationList.clear();
@ -103,7 +108,8 @@ void ApplicationListModel::loadApplications()
if (entry->property("Exec").isValid()) {
KService::Ptr service(static_cast<KService* >(entry.data()));
if (service->isApplication()) {
if (service->isApplication() &&
!blacklist.contains(service->desktopEntryName() + QStringLiteral(".desktop")) ) {
data.name = service->name();
data.icon = service->icon();
data.storageId = service->storageId();