@@ -102,7 +102,6 @@ ParsedDesktopEntryData DesktopEntry::parseText(const QString& id, const QString&
102
102
auto finishCategory = [&data, &groupName, &entries]() {
103
103
if (groupName == " Desktop Entry" ) {
104
104
if (entries.value (" Type" ).second != " Application" ) return ;
105
-
106
105
if (entries.value (" Hidden" ).second == " true" ) return ;
107
106
108
107
for (const auto & [key, pair]: entries.asKeyValueRange ()) {
@@ -146,8 +145,8 @@ ParsedDesktopEntryData DesktopEntry::parseText(const QString& id, const QString&
146
145
entries.clear ();
147
146
};
148
147
149
- for (auto & line: text.split (u' \n ' )) {
150
- if (line.isEmpty () || line. startsWith (u' #' )) continue ;
148
+ for (auto & line: text.split (u' \n ' , Qt::SkipEmptyParts )) {
149
+ if (line.startsWith (u' #' )) continue ;
151
150
152
151
if (line.startsWith (u' [' ) && line.endsWith (u' ]' )) {
153
152
finishCategory ();
@@ -213,7 +212,6 @@ void DesktopEntry::updateActions(const QHash<QString, DesktopActionData>& newAct
213
212
auto old = this ->mActions ;
214
213
215
214
for (const auto & [key, d]: newActions.asKeyValueRange ()) {
216
-
217
215
DesktopAction* act = nullptr ;
218
216
if (auto found = old.find (key); found != old.end ()) {
219
217
act = found.value ();
@@ -311,7 +309,7 @@ QVector<QString> DesktopEntry::parseExecString(const QString& execString) {
311
309
}
312
310
313
311
void DesktopEntry::doExec (const QList<QString>& execString, const QString& workingDirectory) {
314
- auto ctx = qs::io::process::ProcessContext () ;
312
+ qs::io::process::ProcessContext ctx ;
315
313
ctx.setCommand (execString);
316
314
ctx.setWorkingDirectory (workingDirectory);
317
315
QuickshellGlobal::execDetached (ctx);
@@ -326,11 +324,10 @@ DesktopEntryScanner::DesktopEntryScanner(DesktopEntryManager* manager): manager(
326
324
}
327
325
328
326
void DesktopEntryScanner::run () {
329
- auto desktopPaths = DesktopEntryManager::desktopPaths ();
327
+ const auto & desktopPaths = DesktopEntryManager::desktopPaths ();
330
328
auto scanResults = QList<ParsedDesktopEntryData>();
331
329
332
- for (int i = desktopPaths.size () - 1 ; i >= 0 ; --i) {
333
- const auto & path = desktopPaths.at (i);
330
+ for (const auto & path: desktopPaths | std::views::reverse) {
334
331
auto file = QFileInfo (path);
335
332
if (!file.isDir ()) continue ;
336
333
@@ -395,11 +392,13 @@ void DesktopEntryManager::scanDesktopEntries() {
395
392
qCDebug (logDesktopEntry) << " Starting desktop entry scan" ;
396
393
397
394
if (this ->scanInProgress ) {
398
- qCDebug (logDesktopEntry) << " Scan already in progress, skipping" ;
395
+ qCDebug (logDesktopEntry) << " Scan already in progress, queuing another scan" ;
396
+ this ->scanQueued = true ;
399
397
return ;
400
398
}
401
399
402
400
this ->scanInProgress = true ;
401
+ this ->scanQueued = false ;
403
402
auto * scanner = new DesktopEntryScanner (this );
404
403
QThreadPool::globalInstance ()->start (scanner);
405
404
}
@@ -444,11 +443,13 @@ void DesktopEntryManager::handleFileChanges() {
444
443
qCDebug (logDesktopEntry) << " Directory change detected, performing full rescan" ;
445
444
446
445
if (this ->scanInProgress ) {
447
- qCDebug (logDesktopEntry) << " Scan already in progress, skipping" ;
446
+ qCDebug (logDesktopEntry) << " Scan already in progress, queuing another scan" ;
447
+ this ->scanQueued = true ;
448
448
return ;
449
449
}
450
450
451
451
this ->scanInProgress = true ;
452
+ this ->scanQueued = false ;
452
453
auto * scanner = new DesktopEntryScanner (this );
453
454
QThreadPool::globalInstance ()->start (scanner);
454
455
}
@@ -476,7 +477,13 @@ const QStringList& DesktopEntryManager::desktopPaths() {
476
477
}
477
478
478
479
void DesktopEntryManager::onScanCompleted (const QList<ParsedDesktopEntryData>& scanResults) {
479
- auto guard = qScopeGuard ([this ] { this ->scanInProgress = false ; });
480
+ auto guard = qScopeGuard ([this ] {
481
+ this ->scanInProgress = false ;
482
+ if (this ->scanQueued ) {
483
+ this ->scanQueued = false ;
484
+ this ->scanDesktopEntries ();
485
+ }
486
+ });
480
487
481
488
auto oldEntries = this ->desktopEntries ;
482
489
auto newEntries = QHash<QString, DesktopEntry*>();
@@ -536,9 +543,9 @@ void DesktopEntryManager::onScanCompleted(const QList<ParsedDesktopEntryData>& s
536
543
537
544
this ->mApplications .diffUpdate (newApplications);
538
545
539
- for (auto * e: oldEntries) e->deleteLater ();
540
-
541
546
emit applicationsChanged ();
547
+
548
+ for (auto * e: oldEntries) e->deleteLater ();
542
549
}
543
550
544
551
DesktopEntries::DesktopEntries () {
0 commit comments