Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 5b1e5301 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

When apps backend isn't found use whatever application backend we have

parent 75bd8490
......@@ -370,14 +370,16 @@ AbstractResourcesBackend* ResourcesModel::currentApplicationBackend() const
return m_currentApplicationBackend;
}
void ResourcesModel::setCurrentApplicationBackend(AbstractResourcesBackend* backend)
void ResourcesModel::setCurrentApplicationBackend(AbstractResourcesBackend* backend, bool write)
{
if (backend != m_currentApplicationBackend) {
KConfigGroup settings(KSharedConfig::openConfig(), "ResourcesModel");
if (backend)
settings.writeEntry("currentApplicationBackend", backend->name());
else
settings.deleteEntry("currentApplicationBackend");
if (write) {
KConfigGroup settings(KSharedConfig::openConfig(), "ResourcesModel");
if (backend)
settings.writeEntry("currentApplicationBackend", backend->name());
else
settings.deleteEntry("currentApplicationBackend");
}
qDebug() << "setting currentApplicationBackend" << backend;
m_currentApplicationBackend = backend;
......@@ -392,5 +394,9 @@ void ResourcesModel::initApplicationsBackend()
const auto backends = applicationBackends();
auto idx = kIndexOf(backends, [name](AbstractResourcesBackend* b) { return b->name() == name; });
setCurrentApplicationBackend(backends.value(idx, nullptr));
if (idx<0) {
idx = kIndexOf(backends, [](AbstractResourcesBackend* b) { return b->hasApplications(); });
qDebug() << "falling back applications backend to" << idx;
}
setCurrentApplicationBackend(backends.value(idx, nullptr), false);
}
......@@ -81,7 +81,7 @@ class DISCOVERCOMMON_EXPORT ResourcesModel : public QObject
QVariantList applicationBackendsVariant() const;
QVector<AbstractResourcesBackend*> applicationBackends() const;
void setCurrentApplicationBackend(AbstractResourcesBackend* backend);
void setCurrentApplicationBackend(AbstractResourcesBackend* backend, bool writeConfig = true);
AbstractResourcesBackend* currentApplicationBackend() const;
public Q_SLOTS:
......
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