X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/c2c075011c0924fb6af3ae345f839620ea78afc2..bd47eb2e6d:/src/panels/folders/folderspanel.cpp diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp index 276cf5672..cb35fd218 100644 --- a/src/panels/folders/folderspanel.cpp +++ b/src/panels/folders/folderspanel.cpp @@ -50,6 +50,7 @@ #include #include "dolphindebug.h" +#include "global.h" FoldersPanel::FoldersPanel(QWidget* parent) : Panel(parent), @@ -82,6 +83,17 @@ bool FoldersPanel::showHiddenFiles() const return FoldersPanelSettings::hiddenFilesShown(); } +void FoldersPanel::setLimitFoldersPanelToHome(bool enable) +{ + FoldersPanelSettings::setLimitFoldersPanelToHome(enable); + reloadTree(); +} + +bool FoldersPanel::limitFoldersPanelToHome() const +{ + return FoldersPanelSettings::limitFoldersPanelToHome(); +} + void FoldersPanel::setAutoScrolling(bool enable) { // TODO: Not supported yet in Dolphin 2.0 @@ -122,6 +134,14 @@ bool FoldersPanel::urlChanged() return true; } +void FoldersPanel::reloadTree() +{ + if (m_controller) { + loadTree(url()); + } +} + + void FoldersPanel::showEvent(QShowEvent* event) { if (event->spontaneous()) { @@ -260,7 +280,7 @@ void FoldersPanel::slotRoleEditingFinished(int index, const QByteArray& role, co KIO::Job* job = KIO::moveAs(oldUrl, newUrl); KJobWidgets::setWindow(job, this); KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, {oldUrl}, newUrl, job); - job->ui()->setAutoErrorHandlingEnabled(true); + job->uiDelegate()->setAutoErrorHandlingEnabled(true); } } } @@ -304,8 +324,13 @@ void FoldersPanel::loadTree(const QUrl& url) QUrl baseUrl; if (url.isLocalFile()) { - // Use the root directory as base for local URLs (#150941) - baseUrl = QUrl::fromLocalFile(QDir::rootPath()); + const bool isInHomeFolder = Dolphin::homeUrl().isParentOf(url) || (Dolphin::homeUrl() == url); + if (FoldersPanelSettings::limitFoldersPanelToHome() && isInHomeFolder) { + baseUrl = Dolphin::homeUrl(); + } else { + // Use the root directory as base for local URLs (#150941) + baseUrl = QUrl::fromLocalFile(QDir::rootPath()); + } } else { // Clear the path for non-local URLs and use it as base baseUrl = url; @@ -320,9 +345,13 @@ void FoldersPanel::loadTree(const QUrl& url) const int index = m_model->index(url); if (index >= 0) { updateCurrentItem(index); + } else if (url == baseUrl) { + // clear the selection when visiting the base url + updateCurrentItem(-1); } else { m_updateCurrentItem = true; m_model->expandParentDirectories(url); + // slotLoadingCompleted() will be invoked after the model has // expanded the url }