Index: dataengines/soliddevice/CMakeLists.txt =================================================================== --- dataengines/soliddevice/CMakeLists.txt +++ dataengines/soliddevice/CMakeLists.txt @@ -18,6 +18,7 @@ KF5::Plasma KF5::Solid KF5::CoreAddons + KF5::Notifications ) kcoreaddons_desktop_to_json(plasma_engine_soliddevice plasma-dataengine-soliddevice.desktop) Index: dataengines/soliddevice/soliddeviceengine.h =================================================================== --- dataengines/soliddevice/soliddeviceengine.h +++ dataengines/soliddevice/soliddeviceengine.h @@ -35,6 +35,7 @@ #include "devicesignalmapmanager.h" #include "devicesignalmapper.h" #include "hddtemp.h" +#include enum State { Idle = 0, @@ -80,6 +82,8 @@ QMap m_devicemap; //udi, corresponding encrypted container udi; QMap m_encryptedContainerMap; + //path, corresponding timer + QSet m_paths; DeviceSignalMapManager *m_signalmanager; HddTemp *m_temperature; Index: dataengines/soliddevice/soliddeviceengine.cpp =================================================================== --- dataengines/soliddevice/soliddeviceengine.cpp +++ dataengines/soliddevice/soliddeviceengine.cpp @@ -24,9 +24,11 @@ #include #include +#include #include -#include #include +#include +#include #include @@ -547,12 +550,39 @@ return false; } - KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(storageaccess->filePath()); - if (info.isValid()) { - setData(udi, I18N_NOOP("Free Space"), QVariant(info.available())); - setData(udi, I18N_NOOP("Free Space Text"), KFormat().formatByteSize(info.available())); - setData(udi, I18N_NOOP("Size"), QVariant(info.size())); - return true; + QString path = storageaccess->filePath(); + if (!m_paths.contains(path)) { + QTimer *timer = new QTimer(this); + timer->setSingleShot(true); + connect(timer, &QTimer::timeout, [path]() { + KNotification::event(KNotification::Error, i18n("Filesystem is not responding", path), + i18n("Filesystem mounted at '%1' is not responding", path)); + }); + + m_paths.insert(path); + + // create job + KIO::FileSystemFreeSpaceJob *job = KIO::fileSystemFreeSpace(QUrl::fromLocalFile(path)); + + // delete later timer + connect(job, &KIO::FileSystemFreeSpaceJob::result, timer, &QTimer::deleteLater); + + // collect and process info + connect(job, &KIO::FileSystemFreeSpaceJob::result, this, + [this, timer, path, udi](KIO::Job *job, KIO::filesize_t size, KIO::filesize_t available) { + timer->stop(); + + if (!job->error()) { + setData(udi, I18N_NOOP("Free Space"), QVariant(available)); + setData(udi, I18N_NOOP("Free Space Text"), KFormat().formatByteSize(available)); + setData(udi, I18N_NOOP("Size"), QVariant(size)); + } + + m_paths.remove(path); + }); + + // start timer: after 15 seconds we will get an error + timer->start(15000); } return false;