Commit 1db68856 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Update preferred browser when KSycoca changes

BUG: 416161
parent 58542f49
......@@ -64,6 +64,15 @@ AppEntry::AppEntry(AbstractModel *owner, const QString &id) : AbstractEntry(owne
if (url.scheme() == QLatin1String("preferred")) {
m_service = defaultAppByName(url.host());
m_id = id;
m_con = QObject::connect(KSycoca::self(), QOverload<>::of(&KSycoca::databaseChanged), owner, [this, owner, id](){
KSharedConfig::openConfig()->reparseConfiguration();
m_service = defaultAppByName(QUrl(id).host());
if (m_service) {
init((NameFormat)owner->rootModel()->property("appNameFormat").toInt());
m_icon = QIcon();
Q_EMIT owner->layoutChanged();
}
});
} else {
m_service = KService::serviceByStorageId(id);
}
......@@ -275,6 +284,12 @@ KService::Ptr AppEntry::defaultAppByName(const QString& name)
return KService::Ptr();
}
AppEntry::~AppEntry() {
if (m_con){
QObject::disconnect(m_con);
}
}
AppGroupEntry::AppGroupEntry(AppsModel *parentModel, KServiceGroup::Ptr group,
bool paginate, int pageSize, bool flat, bool sorted, bool separators, int appNameFormat) : AbstractGroupEntry(parentModel),
m_group(group)
......
......@@ -40,6 +40,7 @@ class AppEntry : public AbstractEntry
explicit AppEntry(AbstractModel *owner, KService::Ptr service, NameFormat nameFormat);
explicit AppEntry(AbstractModel *owner, const QString &id);
~AppEntry() override;
EntryType type() const override { return RunnableType; }
......@@ -72,6 +73,7 @@ class AppEntry : public AbstractEntry
mutable QIcon m_icon;
KService::Ptr m_service;
static MenuEntryEditor *m_menuEntryEditor;
QMetaObject::Connection m_con;
};
class AppGroupEntry : public AbstractGroupEntry
......
......@@ -379,10 +379,16 @@ public:
}
const QString id = data(index(row, 0), Kicker::UrlRole).toString();
return m_itemEntries.contains(id)
? m_itemEntries[id]->run(actionId, argument)
: false;
if (m_itemEntries.contains(id)) {
return m_itemEntries[id]->run(actionId, argument);
}
// Entries with preferred:// can be changed by the user, BUG: 416161
// then the list of entries could be out of sync
const auto entry = m_itemEntries[m_items[row].value()];
if (QUrl(entry->id()).scheme() == QLatin1String("preferred")) {
return entry->run(actionId, argument);
}
return false;
}
void move(int from, int to)
......
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