diff options
| author | Kai Uwe Broulik <[email protected]> | 2026-01-09 17:01:27 +0100 |
|---|---|---|
| committer | Kai Uwe Broulik <[email protected]> | 2026-01-31 15:07:30 +0000 |
| commit | d54fb877d7a875d1f1bcb37782410ba92ecc4890 (patch) | |
| tree | a0d3e649af4d850d346f642aeadfc669f1523dfa /src/statusbar | |
| parent | 66676e7a705f7da841c29e11eb315cb5b0f54abd (diff) | |
mountpointobservercache: Use Solid for determining mountpoint
KFilePlacesModel already has all the devices, so we can use it
rather than having KMountPoint query the list of mounts all the time.
Diffstat (limited to 'src/statusbar')
| -rw-r--r-- | src/statusbar/mountpointobservercache.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/statusbar/mountpointobservercache.cpp b/src/statusbar/mountpointobservercache.cpp index a7d74764d..e1c08fec5 100644 --- a/src/statusbar/mountpointobservercache.cpp +++ b/src/statusbar/mountpointobservercache.cpp @@ -10,6 +10,9 @@ #include <KMountPoint> +#include <Solid/Device> +#include <Solid/StorageAccess> + #include <QTimer> class MountPointObserverCacheSingleton @@ -40,9 +43,11 @@ MountPointObserver *MountPointObserverCache::observerForUrl(const QUrl &url) // If the url is a local path we can extract the root dir by checking the mount points. if (url.isLocalFile()) { // Try to share the observer with other paths that have the same mount point. - KMountPoint::Ptr mountPoint = KMountPoint::currentMountPoints().findByPath(url.toLocalFile()); - if (mountPoint) { - cachedObserverUrl = QUrl::fromLocalFile(mountPoint->mountPoint()); + // Use Solid (rather than KMountPoint) which will likely already have the info from KFilePlacesModel. + const auto device = Solid::Device::storageAccessFromPath(url.toLocalFile()); + const auto *deviceAccess = device.as<Solid::StorageAccess>(); + if (deviceAccess) { + cachedObserverUrl = QUrl::fromLocalFile(deviceAccess->filePath()); } else { // Even if determining the mount point failed, the observer might still // be able to retrieve information about the url. |
