pull/16/merge
std::_Rb_tree 1 year ago committed by GitHub
commit 4db201d8e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -61,7 +61,15 @@ LauncherModel::LauncherModel(QObject *parent)
QtConcurrent::run(LauncherModel::refresh, this); QtConcurrent::run(LauncherModel::refresh, this);
m_fileWatcher->addPath("/usr/share/applications"); m_appPaths << "/usr/share/applications";
m_appPaths << QDir::homePath() + "/.local/share/applications";
m_appPaths << "/var/lib/flatpak/exports/share/applications";
m_appPaths << QDir::homePath() + "/.local/share/flatpak/exports/share/applications";
for (const auto & appPath : m_appPaths) {
m_fileWatcher->addPath(appPath);
}
connect(m_fileWatcher, &QFileSystemWatcher::fileChanged, this, &LauncherModel::onFileChanged); connect(m_fileWatcher, &QFileSystemWatcher::fileChanged, this, &LauncherModel::onFileChanged);
connect(m_fileWatcher, &QFileSystemWatcher::directoryChanged, this, [this](const QString &) { connect(m_fileWatcher, &QFileSystemWatcher::directoryChanged, this, [this](const QString &) {
QtConcurrent::run(LauncherModel::refresh, this); QtConcurrent::run(LauncherModel::refresh, this);
@ -224,7 +232,9 @@ void LauncherModel::refresh(LauncherModel *manager)
addedEntries.append(item.id); addedEntries.append(item.id);
QStringList allEntries; QStringList allEntries;
QDirIterator it("/usr/share/applications", { "*.desktop" }, QDir::NoFilter, QDirIterator::Subdirectories);
for (const auto & appPath : manager->m_appPaths) {
QDirIterator it(appPath, { "*.desktop" }, QDir::NoFilter, QDirIterator::Subdirectories);
while (it.hasNext()) { while (it.hasNext()) {
const auto fileName = it.next(); const auto fileName = it.next();
@ -233,6 +243,7 @@ void LauncherModel::refresh(LauncherModel *manager)
allEntries.append(fileName); allEntries.append(fileName);
} }
}
for (const QString &fileName : allEntries) { for (const QString &fileName : allEntries) {
QMetaObject::invokeMethod(manager, "addApp", Q_ARG(QString, fileName)); QMetaObject::invokeMethod(manager, "addApp", Q_ARG(QString, fileName));

@ -94,6 +94,8 @@ private Q_SLOTS:
void removeApp(const QString &fileName); void removeApp(const QString &fileName);
private: private:
QList<QString> m_appPaths;
QList<AppItem> m_appItems; QList<AppItem> m_appItems;
QList<AppItem> m_searchItems; QList<AppItem> m_searchItems;

Loading…
Cancel
Save