@@ -18,19 +18,24 @@ DesktopEntryMonitor::DesktopEntryMonitor(QObject* parent): QObject(parent) {
18
18
this ->watcher = new QFileSystemWatcher (this );
19
19
this ->debounceTimer = new QTimer (this );
20
20
this ->debounceTimer ->setSingleShot (true );
21
- this ->debounceTimer ->setInterval (500 ); // 500ms debounce
21
+ this ->debounceTimer ->setInterval (50 );
22
22
23
23
// Initialize XDG desktop paths
24
24
this ->initializeDesktopPaths ();
25
25
26
26
// Setup connections
27
- connect (
27
+ QObject:: connect (
28
28
this ->watcher ,
29
29
&QFileSystemWatcher::directoryChanged,
30
30
this ,
31
31
&DesktopEntryMonitor::onDirectoryChanged
32
32
);
33
- connect (this ->debounceTimer , &QTimer::timeout, this , &DesktopEntryMonitor::processChanges);
33
+ QObject::connect (
34
+ this ->debounceTimer ,
35
+ &QTimer::timeout,
36
+ this ,
37
+ &DesktopEntryMonitor::processChanges
38
+ );
34
39
35
40
// Start monitoring
36
41
this ->startMonitoring ();
@@ -44,17 +49,13 @@ void DesktopEntryMonitor::startMonitoring() {
44
49
for (const QString& path: this ->desktopPaths ) {
45
50
if (QDir (path).exists ()) {
46
51
qCDebug (logDesktopMonitor) << " Monitoring desktop entry path:" << path;
47
- this ->addDirectoryHierarchy (path);
52
+ this ->scanAndWatch (path);
48
53
}
49
54
}
50
55
}
51
56
52
- void DesktopEntryMonitor::addDirectoryHierarchy (const QString& dirPath) {
53
- this ->scanAndWatch (dirPath);
54
- }
55
-
56
57
void DesktopEntryMonitor::scanAndWatch (const QString& dirPath) {
57
- QDir dir (dirPath);
58
+ auto dir = QDir (dirPath);
58
59
if (!dir.exists ()) return ;
59
60
60
61
// Add directory to watcher
@@ -70,7 +71,7 @@ void DesktopEntryMonitor::scanAndWatch(const QString& dirPath) {
70
71
71
72
void DesktopEntryMonitor::onDirectoryChanged (const QString& path) {
72
73
qCDebug (logDesktopMonitor) << " Directory changed:" << path;
73
- QDir dir (path);
74
+ auto dir = QDir (path);
74
75
75
76
// Check if directory still exists - handle removal/unmounting
76
77
if (!dir.exists ()) {
@@ -82,7 +83,7 @@ void DesktopEntryMonitor::onDirectoryChanged(const QString& path) {
82
83
}
83
84
84
85
// Check for new subdirectories
85
- QList<QString> subdirs = dir.entryList (QDir::Dirs | QDir::NoDotAndDotDot);
86
+ auto subdirs = dir.entryList (QDir::Dirs | QDir::NoDotAndDotDot);
86
87
for (const QString& subdir: subdirs) {
87
88
QString subdirPath = dir.absoluteFilePath (subdir);
88
89
if (!this ->watcher ->directories ().contains (subdirPath)) {
0 commit comments