Commit 065ba968 authored by Ahmad Samir's avatar Ahmad Samir
Browse files

[kio_desktop] Implement SlaveBase::GetFileSystemFreeSpace

This enables reporting the actual free space info for desktop:/ in e.g.
the Dolphin status bar.

BUG: 417851

FIXED-IN: 5.19.80
parent 7c7d28ee
......@@ -23,8 +23,9 @@
#include <KDesktopFile>
#include <KDirNotify>
#include <KLocalizedString>
#include <kio/udsentry.h>
#include <KDiskFreeSpaceInfo>
#include <KIO/StatJob>
#include <KIO/UDSEntry>
#include <QCoreApplication>
#include <QFile>
......@@ -226,3 +227,27 @@ void DesktopProtocol::rename(const QUrl &_src, const QUrl &_dest, KIO::JobFlags
void DesktopProtocol::virtual_hook(int id, void *data)
switch(id) {
case SlaveBase::GetFileSystemFreeSpace: {
QUrl *url = static_cast<QUrl *>(data);
} break;
SlaveBase::virtual_hook(id, data);
void DesktopProtocol::fileSystemFreeSpace(const QUrl &url)
const QString desktopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
const KDiskFreeSpaceInfo spaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(desktopPath);
if (spaceInfo.isValid()) {
setMetaData(QStringLiteral("total"), QString::number(spaceInfo.size()));
setMetaData(QStringLiteral("available"), QString::number(spaceInfo.available()));
} else {
error(KIO::ERR_CANNOT_STAT, desktopPath);
......@@ -36,6 +36,11 @@ protected:
void listDir(const QUrl &url) override;
void prepareUDSEntry(KIO::UDSEntry &entry, bool listing=false) const override;
void rename(const QUrl &, const QUrl &, KIO::JobFlags flags) override;
void virtual_hook(int id, void *data) override;
void fileSystemFreeSpace(const QUrl &url);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment