From 94fab8c80ed60958043d13145aaf4c54412e052f Mon Sep 17 00:00:00 2001 From: Robert Hoffmann Date: Fri, 1 Sep 2017 10:15:03 +0200 Subject: 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 --- src/panels/folders/treeviewcontextmenu.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/panels/folders/treeviewcontextmenu.cpp') diff --git a/src/panels/folders/treeviewcontextmenu.cpp b/src/panels/folders/treeviewcontextmenu.cpp index 51fc229c1..6381a88ff 100644 --- a/src/panels/folders/treeviewcontextmenu.cpp +++ b/src/panels/folders/treeviewcontextmenu.cpp @@ -43,6 +43,7 @@ #include #include #include +#include "global.h" TreeViewContextMenu::TreeViewContextMenu(FoldersPanel* parent, const KFileItem& fileInfo) : @@ -124,6 +125,17 @@ void TreeViewContextMenu::open() popup->addAction(showHiddenFilesAction); connect(showHiddenFilesAction, &QAction::toggled, this, &TreeViewContextMenu::setShowHiddenFiles); + // insert 'Limit to Home Directory' + const QUrl url = m_fileItem.url(); + const bool showLimitToHomeDirectory = url.isLocalFile() && (Dolphin::homeUrl().isParentOf(url) || (Dolphin::homeUrl() == url)); + if (showLimitToHomeDirectory) { + QAction* limitFoldersPanelToHomeAction = new QAction(i18nc("@action:inmenu", "Limit to Home Directory"), this); + limitFoldersPanelToHomeAction->setCheckable(true); + limitFoldersPanelToHomeAction->setChecked(m_parent->limitFoldersPanelToHome()); + popup->addAction(limitFoldersPanelToHomeAction); + connect(limitFoldersPanelToHomeAction, &QAction::toggled, this, &TreeViewContextMenu::setLimitFoldersPanelToHome); + } + // insert 'Automatic Scrolling' QAction* autoScrollingAction = new QAction(i18nc("@action:inmenu", "Automatic Scrolling"), this); autoScrollingAction->setCheckable(true); @@ -229,6 +241,11 @@ void TreeViewContextMenu::setShowHiddenFiles(bool show) m_parent->setShowHiddenFiles(show); } +void TreeViewContextMenu::setLimitFoldersPanelToHome(bool enable) +{ + m_parent->setLimitFoldersPanelToHome(enable); +} + void TreeViewContextMenu::setAutoScrolling(bool enable) { m_parent->setAutoScrolling(enable); -- cgit v1.3