diff --git a/containments/desktop/plugins/folder/foldermodel.h b/containments/desktop/plugins/folder/foldermodel.h --- a/containments/desktop/plugins/folder/foldermodel.h +++ b/containments/desktop/plugins/folder/foldermodel.h @@ -142,7 +142,7 @@ QString url() const; void setUrl(const QString &url); - QString iconName() const; + QString iconName(); QUrl resolvedUrl() const; Q_INVOKABLE QUrl resolve(const QString& url); diff --git a/containments/desktop/plugins/folder/foldermodel.cpp b/containments/desktop/plugins/folder/foldermodel.cpp --- a/containments/desktop/plugins/folder/foldermodel.cpp +++ b/containments/desktop/plugins/folder/foldermodel.cpp @@ -315,13 +315,6 @@ m_dirWatch = nullptr; } - if (resolvedNewUrl.isValid()) { - m_dirWatch = new KDirWatch(this); - connect(m_dirWatch, &KDirWatch::created, this, &FolderModel::iconNameChanged); - connect(m_dirWatch, &KDirWatch::dirty, this, &FolderModel::iconNameChanged); - m_dirWatch->addFile(resolvedNewUrl.toLocalFile() + QLatin1String("/.directory")); - } - if (m_dragInProgress) { m_urlChangedWhileDragging = true; } @@ -352,10 +345,20 @@ return resolvedUrl; } -QString FolderModel::iconName() const +QString FolderModel::iconName() { const KFileItem rootItem(m_dirModel->dirLister()->url()); + if (!m_dirWatch) { + const QString localPath = rootItem.localPath(); + if (!localPath.isEmpty()) { + m_dirWatch = new KDirWatch(this); + connect(m_dirWatch, &KDirWatch::created, this, &FolderModel::iconNameChanged); + connect(m_dirWatch, &KDirWatch::dirty, this, &FolderModel::iconNameChanged); + m_dirWatch->addFile(localPath + QLatin1String("/.directory")); + } + } + if (!rootItem.isFinalIconKnown()) { rootItem.determineMimeType(); }