@@ -247,8 +247,8 @@ bool DesktopEntry::isValid() const { return !this->bName.value().isEmpty(); }
247
247
QVector<DesktopAction*> DesktopEntry::actions () const { return this ->mActions .values (); }
248
248
249
249
QVector<QString> DesktopEntry::parseExecString (const QString& execString) {
250
- auto arguments = QVector<QString>() ;
251
- auto currentArgument = QString () ;
250
+ QVector<QString> arguments ;
251
+ QString currentArgument;
252
252
auto parsingString = false ;
253
253
auto escape = 0 ;
254
254
auto percent = false ;
@@ -334,22 +334,28 @@ void DesktopEntryScanner::run() {
334
334
auto file = QFileInfo (path);
335
335
if (!file.isDir ()) continue ;
336
336
337
- this ->scanDirectory (QDir (path), scanResults);
337
+ this ->scanDirectory (QDir (path), QString (), scanResults);
338
338
}
339
339
340
340
QMetaObject::invokeMethod (
341
341
this ->manager ,
342
- [mgr = this ->manager , results = std::move (scanResults)]() { mgr->onScanCompleted (results); },
343
- Qt::QueuedConnection
342
+ &DesktopEntryManager::onScanCompleted,
343
+ Qt::QueuedConnection,
344
+ scanResults
344
345
);
345
346
}
346
347
347
- void DesktopEntryScanner::scanDirectory (const QDir& dir, QList<ParsedDesktopEntryData>& entries) {
348
+ void DesktopEntryScanner::scanDirectory (
349
+ const QDir& dir,
350
+ const QString& idPrefix,
351
+ QList<ParsedDesktopEntryData>& entries
352
+ ) {
348
353
auto dirEntries = dir.entryInfoList (QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
349
354
350
355
for (auto & entry: dirEntries) {
351
356
if (entry.isDir ()) {
352
- this ->scanDirectory (QDir (entry.absoluteFilePath ()), entries);
357
+ auto subdirPrefix = idPrefix.isEmpty () ? entry.fileName () : idPrefix + ' -' + entry.fileName ();
358
+ this ->scanDirectory (QDir (entry.absoluteFilePath ()), subdirPrefix, entries);
353
359
} else if (entry.isFile ()) {
354
360
auto path = entry.filePath ();
355
361
if (!path.endsWith (" .desktop" )) {
@@ -363,7 +369,8 @@ void DesktopEntryScanner::scanDirectory(const QDir& dir, QList<ParsedDesktopEntr
363
369
continue ;
364
370
}
365
371
366
- auto id = DesktopEntryManager::extractIdFromPath (entry.absoluteFilePath ());
372
+ auto basename = QFileInfo (entry.fileName ()).completeBaseName ();
373
+ auto id = idPrefix.isEmpty () ? basename : idPrefix + ' -' + basename;
367
374
auto content = QString::fromUtf8 (file.readAll ());
368
375
369
376
auto data = DesktopEntry::parseText (id, content);
@@ -481,8 +488,9 @@ const QStringList& DesktopEntryManager::desktopPaths() {
481
488
auto dataDirs = qEnvironmentVariable (" XDG_DATA_DIRS" );
482
489
if (dataDirs.isEmpty ()) dataDirs = " /usr/local/share:/usr/share" ;
483
490
484
- for (const auto & dir: dataDirs.split (' :' , Qt::SkipEmptyParts))
491
+ for (const auto & dir: dataDirs.split (' :' , Qt::SkipEmptyParts)) {
485
492
dataPaths.append (dir + " /applications" );
493
+ }
486
494
487
495
return dataPaths;
488
496
}();
@@ -557,9 +565,8 @@ void DesktopEntryManager::onScanCompleted(const QList<ParsedDesktopEntryData>& s
557
565
}
558
566
559
567
DesktopEntries::DesktopEntries () {
560
- auto * mgr = DesktopEntryManager::instance ();
561
568
QObject::connect (
562
- mgr ,
569
+ DesktopEntryManager::instance () ,
563
570
&DesktopEntryManager::applicationsChanged,
564
571
this ,
565
572
&DesktopEntries::applicationsChanged
0 commit comments