diff options
| author | Robert Hoffmann <[email protected]> | 2017-09-01 10:15:03 +0200 |
|---|---|---|
| committer | Emmanuel Pescosta <[email protected]> | 2017-09-01 10:15:40 +0200 |
| commit | 94fab8c80ed60958043d13145aaf4c54412e052f (patch) | |
| tree | c5ea48b7829e6e100443127eea9420e975207616 /src/panels/folders/folderspanel.cpp | |
| parent | 652f57d28152491c42ad740d2bacd12a12d3d3d7 (diff) | |
Limit folder panel to home directory if inside home
Summary:
Added the option to limit the displayed folders in the folder panel (F7) to the tree below the user's home directory if the current URL is inside the home directory.
This can be configured in the preferences General/Behaviour tab by checking the corresponding check box.
Reviewers: #dolphin, elvisangelaccio, emmanuelp
Reviewed By: #dolphin, elvisangelaccio, emmanuelp
Subscribers: emmanuelp, elvisangelaccio, #konqueror, #dolphin
Differential Revision: https://phabricator.kde.org/D7477
Diffstat (limited to 'src/panels/folders/folderspanel.cpp')
| -rw-r--r-- | src/panels/folders/folderspanel.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp index 8b759d813..cb35fd218 100644 --- a/src/panels/folders/folderspanel.cpp +++ b/src/panels/folders/folderspanel.cpp @@ -50,6 +50,7 @@ #include <views/draganddrophelper.h> #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()) { @@ -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 } |
