Commit 68306ef1 authored by Ahmad Samir's avatar Ahmad Samir Committed by David Faure

kio_desktop: Fix creating a new folder while at "desktop:"

If you navigate to "desktop:" (without a / at the end) then create a new
folder, you'll end up with "/home/user/DesktopNew Folder", that's because
the path part of the url is empty. Change the code to always add / to the
beginning of the path when needed.

Drive-by change: silence a compiler warning about an unused parameter.
parent 1fd9988a
......@@ -109,16 +109,18 @@ void DesktopProtocol::checkLocalInstall()
bool DesktopProtocol::rewriteUrl(const QUrl &url, QUrl &newUrl)
QString desktopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
if (desktopPath.endsWith('/')) {
QString oldPath = url.path();
// So that creating a new folder while at "desktop:" (without a '/' after ':')
// doesn't create "/home/user/DesktopNew Folder" instead of "/home/user/Desktop/New Folder".
if (oldPath.isEmpty() || !oldPath.startsWith(QLatin1Char('/'))) {
QString filePath = desktopPath + url.path();
if (filePath.endsWith('/')) {
filePath.chop(1); // ForwardingSlaveBase always appends a '/'
const QString desktopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
newUrl.setPath(desktopPath + oldPath);
newUrl = newUrl.adjusted(QUrl::StripTrailingSlash);
return true;
......@@ -240,6 +242,8 @@ void DesktopProtocol::virtual_hook(int id, void *data)
void DesktopProtocol::fileSystemFreeSpace(const QUrl &url)
const QString desktopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
const KDiskFreeSpaceInfo spaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(desktopPath);
if (spaceInfo.isValid()) {
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